@xibosignage/xibo-layout-renderer 1.0.9 → 1.0.10

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.
@@ -663,7 +663,8 @@ var XiboLayoutRenderer = (function (exports) {
663
663
  },
664
664
  emitter: {},
665
665
  index: -1,
666
- actionController: undefined
666
+ actionController: undefined,
667
+ enableStat: false
667
668
  };
668
669
 
669
670
  function nextId(options) {
@@ -69556,7 +69557,8 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
69556
69557
  on: function on(event, callback) {
69557
69558
  return {};
69558
69559
  },
69559
- emitter: {}
69560
+ emitter: {},
69561
+ enableStat: false
69560
69562
  };
69561
69563
 
69562
69564
  /*
@@ -72811,6 +72813,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
72811
72813
  var mediaTimeCount = 0;
72812
72814
  var emitter = createNanoEvents();
72813
72815
  var mediaObject = _objectSpread2(_objectSpread2({}, initialMedia), props);
72816
+ var statsBC = new BroadcastChannel('statsBC');
72814
72817
  var startMediaTimer = function startMediaTimer(media) {
72815
72818
  mediaTimer = setInterval(function () {
72816
72819
  mediaTimeCount++;
@@ -72834,12 +72837,32 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
72834
72837
  } else {
72835
72838
  startMediaTimer(media);
72836
72839
  }
72840
+ // Check if stats are enabled for the layout
72841
+ if (media.enableStat) {
72842
+ statsBC.postMessage({
72843
+ action: 'START_STAT',
72844
+ mediaId: parseInt(media.id),
72845
+ layoutId: media.region.layout.id,
72846
+ scheduleId: media.region.layout.scheduleId,
72847
+ type: 'media'
72848
+ });
72849
+ }
72837
72850
  });
72838
72851
  emitter.on('end', function (media) {
72839
72852
  if (mediaTimer) {
72840
72853
  clearInterval(mediaTimer);
72841
72854
  mediaTimeCount = 0;
72842
72855
  }
72856
+ // Check if stats are enabled for the layout
72857
+ if (media.enableStat) {
72858
+ statsBC.postMessage({
72859
+ action: 'END_STAT',
72860
+ mediaId: parseInt(media.id),
72861
+ layoutId: media.region.layout.id,
72862
+ scheduleId: media.region.layout.scheduleId,
72863
+ type: 'media'
72864
+ });
72865
+ }
72843
72866
  media.region.playNextMedia();
72844
72867
  });
72845
72868
  mediaObject.on = function (event, callback) {
@@ -72847,7 +72870,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
72847
72870
  };
72848
72871
  mediaObject.emitter = emitter;
72849
72872
  mediaObject.init = function () {
72850
- var _self$xml, _self$xml2, _self$xml3, _self$xml4, _self$xml5;
72873
+ var _self$xml, _self$xml2, _self$xml3, _self$xml4, _self$xml5, _self$xml6;
72851
72874
  var self = mediaObject;
72852
72875
  self.id = props.mediaId;
72853
72876
  self.fileId = ((_self$xml = self.xml) === null || _self$xml === void 0 ? void 0 : _self$xml.getAttribute('fileId')) || '';
@@ -72857,9 +72880,10 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
72857
72880
  self.mediaType = ((_self$xml2 = self.xml) === null || _self$xml2 === void 0 ? void 0 : _self$xml2.getAttribute('type')) || '';
72858
72881
  self.render = ((_self$xml3 = self.xml) === null || _self$xml3 === void 0 ? void 0 : _self$xml3.getAttribute('render')) || '';
72859
72882
  self.duration = parseInt((_self$xml4 = self.xml) === null || _self$xml4 === void 0 ? void 0 : _self$xml4.getAttribute('duration')) || 0;
72883
+ self.enableStat = Boolean(((_self$xml5 = self.xml) === null || _self$xml5 === void 0 ? void 0 : _self$xml5.getAttribute('enableStat')) || false);
72860
72884
  self.options = _objectSpread2({}, props.options);
72861
72885
  var $mediaIframe = document.createElement('iframe');
72862
- var mediaOptions = (_self$xml5 = self.xml) === null || _self$xml5 === void 0 ? void 0 : _self$xml5.getElementsByTagName('options');
72886
+ var mediaOptions = (_self$xml6 = self.xml) === null || _self$xml6 === void 0 ? void 0 : _self$xml6.getElementsByTagName('options');
72863
72887
  if (mediaOptions) {
72864
72888
  for (var _i = 0, _Array$from = Array.from(mediaOptions); _i < _Array$from.length; _i++) {
72865
72889
  var _options = _Array$from[_i];
@@ -73887,9 +73911,19 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
73887
73911
  layout: layout || initialLayout
73888
73912
  };
73889
73913
  var emitter = createNanoEvents();
73914
+ var statsBC = new BroadcastChannel('statsBC');
73890
73915
  emitter.on('start', function (layout) {
73891
73916
  layout.done = false;
73892
73917
  console.debug('Layout start emitted > Layout ID > ', layout.id);
73918
+ // Check if stats are enabled for the layout
73919
+ if (layout.enableStat) {
73920
+ statsBC.postMessage({
73921
+ action: 'START_STAT',
73922
+ layoutId: layout.id,
73923
+ scheduleId: layout.scheduleId,
73924
+ type: 'layout'
73925
+ });
73926
+ }
73893
73927
  });
73894
73928
  emitter.on('end', /*#__PURE__*/function () {
73895
73929
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(layout) {
@@ -73907,13 +73941,22 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
73907
73941
  if ($layout !== null) {
73908
73942
  $layout.remove();
73909
73943
  }
73944
+ // Check if stats are enabled for the layout
73945
+ if (layout.enableStat) {
73946
+ statsBC.postMessage({
73947
+ action: 'END_STAT',
73948
+ layoutId: layout.id,
73949
+ scheduleId: layout.scheduleId,
73950
+ type: 'layout'
73951
+ });
73952
+ }
73910
73953
  if (xlr.config.platform !== 'CMS') {
73911
73954
  // Transition next layout to current layout and prepare next layout if exist
73912
73955
  xlr.prepareLayouts().then(function (parent) {
73913
73956
  xlr.playSchedules(parent);
73914
73957
  });
73915
73958
  }
73916
- case 6:
73959
+ case 7:
73917
73960
  case "end":
73918
73961
  return _context.stop();
73919
73962
  }
@@ -73951,7 +73994,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
73951
73994
  layoutObject.parseXlf();
73952
73995
  };
73953
73996
  layoutObject.parseXlf = function () {
73954
- var _layout$layoutNode, _layout$layoutNode2, _layout$layoutNode3, _layout$layoutNode4, _layout$layoutNode5, _layout$layoutNode6, _layout$layoutNode7, _layout$layoutNode8;
73997
+ var _layout$layoutNode, _layout$layoutNode2, _layout$layoutNode3, _layout$layoutNode4, _layout$layoutNode5, _layout$layoutNode6, _layout$layoutNode7, _layout$layoutNode8, _layout$layoutNode9;
73955
73998
  var layout = this;
73956
73999
  var options = layout.options;
73957
74000
  layout.done = false;
@@ -73980,6 +74023,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
73980
74023
  layout.xw = Number((_layout$layoutNode = layout.layoutNode) === null || _layout$layoutNode === void 0 || (_layout$layoutNode = _layout$layoutNode.firstElementChild) === null || _layout$layoutNode === void 0 ? void 0 : _layout$layoutNode.getAttribute('width'));
73981
74024
  layout.xh = Number((_layout$layoutNode2 = layout.layoutNode) === null || _layout$layoutNode2 === void 0 || (_layout$layoutNode2 = _layout$layoutNode2.firstElementChild) === null || _layout$layoutNode2 === void 0 ? void 0 : _layout$layoutNode2.getAttribute('height'));
73982
74025
  layout.zIndex = Number((_layout$layoutNode3 = layout.layoutNode) === null || _layout$layoutNode3 === void 0 || (_layout$layoutNode3 = _layout$layoutNode3.firstElementChild) === null || _layout$layoutNode3 === void 0 ? void 0 : _layout$layoutNode3.getAttribute('zindex')) || 0;
74026
+ layout.enableStat = Boolean(((_layout$layoutNode4 = layout.layoutNode) === null || _layout$layoutNode4 === void 0 || (_layout$layoutNode4 = _layout$layoutNode4.firstElementChild) === null || _layout$layoutNode4 === void 0 ? void 0 : _layout$layoutNode4.getAttribute('enableStat')) || false);
73983
74027
  /* Calculate Scale Factor */
73984
74028
  layout.scaleFactor = Math.min(layout.sw / layout.xw, layout.sh / layout.xh);
73985
74029
  layout.sWidth = layout.xw * layout.scaleFactor;
@@ -73998,8 +74042,8 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
73998
74042
  $layout.style.zIndex = "".concat(layout.zIndex);
73999
74043
  }
74000
74044
  /* Set the layout background */
74001
- layout.bgColor = ((_layout$layoutNode4 = layout.layoutNode) === null || _layout$layoutNode4 === void 0 || (_layout$layoutNode4 = _layout$layoutNode4.firstElementChild) === null || _layout$layoutNode4 === void 0 ? void 0 : _layout$layoutNode4.getAttribute('bgcolor')) || '';
74002
- layout.bgImage = ((_layout$layoutNode5 = layout.layoutNode) === null || _layout$layoutNode5 === void 0 || (_layout$layoutNode5 = _layout$layoutNode5.firstElementChild) === null || _layout$layoutNode5 === void 0 ? void 0 : _layout$layoutNode5.getAttribute('background')) || '';
74045
+ layout.bgColor = ((_layout$layoutNode5 = layout.layoutNode) === null || _layout$layoutNode5 === void 0 || (_layout$layoutNode5 = _layout$layoutNode5.firstElementChild) === null || _layout$layoutNode5 === void 0 ? void 0 : _layout$layoutNode5.getAttribute('bgcolor')) || '';
74046
+ layout.bgImage = ((_layout$layoutNode6 = layout.layoutNode) === null || _layout$layoutNode6 === void 0 || (_layout$layoutNode6 = _layout$layoutNode6.firstElementChild) === null || _layout$layoutNode6 === void 0 ? void 0 : _layout$layoutNode6.getAttribute('background')) || '';
74003
74047
  if (!(layout.bgImage === "" || typeof layout.bgImage === 'undefined')) {
74004
74048
  /* Extract the image ID from the filename */
74005
74049
  layout.bgId = layout.bgImage.substring(0, layout.bgImage.indexOf('.'));
@@ -74022,19 +74066,19 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
74022
74066
  $layout.style.display = 'none';
74023
74067
  }
74024
74068
  // Create actions
74025
- var layoutActions = Array.from((layout === null || layout === void 0 || (_layout$layoutNode6 = layout.layoutNode) === null || _layout$layoutNode6 === void 0 ? void 0 : _layout$layoutNode6.getElementsByTagName('action')) || []);
74069
+ var layoutActions = Array.from((layout === null || layout === void 0 || (_layout$layoutNode7 = layout.layoutNode) === null || _layout$layoutNode7 === void 0 ? void 0 : _layout$layoutNode7.getElementsByTagName('action')) || []);
74026
74070
  Array.from(layoutActions).forEach(function (actionXml, indx) {
74027
74071
  layout.actions.push(new Action((actionXml === null || actionXml === void 0 ? void 0 : actionXml.getAttribute('id')) || '', actionXml));
74028
74072
  });
74029
74073
  // Create interactive actions
74030
74074
  layout.actionController = new ActionController(layout, layout.actions, options);
74031
74075
  // Create drawer
74032
- var layoutDrawers = Array.from((layout === null || layout === void 0 || (_layout$layoutNode7 = layout.layoutNode) === null || _layout$layoutNode7 === void 0 ? void 0 : _layout$layoutNode7.getElementsByTagName('drawer')) || []);
74076
+ var layoutDrawers = Array.from((layout === null || layout === void 0 || (_layout$layoutNode8 = layout.layoutNode) === null || _layout$layoutNode8 === void 0 ? void 0 : _layout$layoutNode8.getElementsByTagName('drawer')) || []);
74033
74077
  Array.from(layoutDrawers).forEach(function (layoutDrawerXml) {
74034
74078
  layout.drawer = layoutDrawerXml;
74035
74079
  });
74036
74080
  // Create regions
74037
- var layoutRegions = Array.from((layout === null || layout === void 0 || (_layout$layoutNode8 = layout.layoutNode) === null || _layout$layoutNode8 === void 0 ? void 0 : _layout$layoutNode8.getElementsByTagName('region')) || []);
74081
+ var layoutRegions = Array.from((layout === null || layout === void 0 || (_layout$layoutNode9 = layout.layoutNode) === null || _layout$layoutNode9 === void 0 ? void 0 : _layout$layoutNode9.getElementsByTagName('region')) || []);
74038
74082
  Array.from(layoutRegions).forEach(function (regionXml, indx) {
74039
74083
  var regionObj = Region(layout, regionXml, (regionXml === null || regionXml === void 0 ? void 0 : regionXml.getAttribute('id')) || '', options, xlr);
74040
74084
  regionObj.index = indx;
@@ -74552,6 +74596,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
74552
74596
  var xlrLayoutObj = initialLayout;
74553
74597
  xlrLayoutObj.id = Number(inputLayout.layoutId);
74554
74598
  xlrLayoutObj.layoutId = Number(inputLayout.layoutId);
74599
+ xlrLayoutObj.scheduleId = (inputLayout === null || inputLayout === void 0 ? void 0 : inputLayout.scheduleId) || undefined;
74555
74600
  xlrLayoutObj.options = newOptions;
74556
74601
  xlrLayoutObj.index = getIndexByLayoutId(_this3.inputLayouts, xlrLayoutObj.layoutId).index;
74557
74602
  resolve(Layout(layoutXlfNode, newOptions, self, xlrLayoutObj));