@xibosignage/xibo-layout-renderer 1.0.9 → 1.0.11

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.
@@ -71,6 +71,7 @@ interface IMedia {
71
71
  region: IRegion;
72
72
  fileId: string;
73
73
  emitter: Emitter<IMediaEvents>;
74
+ enableStat: boolean;
74
75
  }
75
76
  declare const initialMedia: IMedia;
76
77
 
@@ -190,6 +191,7 @@ type OptionsType = {
190
191
  interface ILayout {
191
192
  id: number | null;
192
193
  layoutId: number | null;
194
+ scheduleId?: number;
193
195
  sw: number | null;
194
196
  sh: number | null;
195
197
  xw: number | null;
@@ -228,6 +230,7 @@ interface ILayout {
228
230
  resetLayout(): Promise<void>;
229
231
  index: number;
230
232
  actionController: ActionController | undefined;
233
+ enableStat: boolean;
231
234
  }
232
235
  declare const initialLayout: ILayout;
233
236
  type GetLayoutParamType = {
@@ -660,7 +660,8 @@ var initialLayout = {
660
660
  },
661
661
  emitter: {},
662
662
  index: -1,
663
- actionController: undefined
663
+ actionController: undefined,
664
+ enableStat: false
664
665
  };
665
666
 
666
667
  function nextId(options) {
@@ -845,7 +846,9 @@ function composeMediaUrl(params) {
845
846
  function composeBgUrlByPlatform(platform, params) {
846
847
  var bgImageUrl = params.layoutBackgroundDownloadUrl.replace(":id", params.layout.id) + '?preview=1&width=' + params.layout.sWidth + '&height=' + params.layout.sHeight + '&dynamic&proportional=0';
847
848
  if (platform === 'chromeOS') {
848
- bgImageUrl = '/required-files/resource/' + params.layout.id + '?saveAs=' + params.layout.bgImage;
849
+ bgImageUrl = composeMediaUrl({
850
+ uri: params.layout.bgImage
851
+ });
849
852
  }
850
853
  return bgImageUrl;
851
854
  }
@@ -69553,7 +69556,8 @@ var initialMedia = {
69553
69556
  on: function on(event, callback) {
69554
69557
  return {};
69555
69558
  },
69556
- emitter: {}
69559
+ emitter: {},
69560
+ enableStat: false
69557
69561
  };
69558
69562
 
69559
69563
  /*
@@ -72808,6 +72812,7 @@ function Media(region, mediaId, xml, options, xlr) {
72808
72812
  var mediaTimeCount = 0;
72809
72813
  var emitter = createNanoEvents();
72810
72814
  var mediaObject = _objectSpread2(_objectSpread2({}, initialMedia), props);
72815
+ var statsBC = new BroadcastChannel('statsBC');
72811
72816
  var startMediaTimer = function startMediaTimer(media) {
72812
72817
  mediaTimer = setInterval(function () {
72813
72818
  mediaTimeCount++;
@@ -72831,12 +72836,32 @@ function Media(region, mediaId, xml, options, xlr) {
72831
72836
  } else {
72832
72837
  startMediaTimer(media);
72833
72838
  }
72839
+ // Check if stats are enabled for the layout
72840
+ if (media.enableStat) {
72841
+ statsBC.postMessage({
72842
+ action: 'START_STAT',
72843
+ mediaId: parseInt(media.id),
72844
+ layoutId: media.region.layout.id,
72845
+ scheduleId: media.region.layout.scheduleId,
72846
+ type: 'media'
72847
+ });
72848
+ }
72834
72849
  });
72835
72850
  emitter.on('end', function (media) {
72836
72851
  if (mediaTimer) {
72837
72852
  clearInterval(mediaTimer);
72838
72853
  mediaTimeCount = 0;
72839
72854
  }
72855
+ // Check if stats are enabled for the layout
72856
+ if (media.enableStat) {
72857
+ statsBC.postMessage({
72858
+ action: 'END_STAT',
72859
+ mediaId: parseInt(media.id),
72860
+ layoutId: media.region.layout.id,
72861
+ scheduleId: media.region.layout.scheduleId,
72862
+ type: 'media'
72863
+ });
72864
+ }
72840
72865
  media.region.playNextMedia();
72841
72866
  });
72842
72867
  mediaObject.on = function (event, callback) {
@@ -72844,7 +72869,7 @@ function Media(region, mediaId, xml, options, xlr) {
72844
72869
  };
72845
72870
  mediaObject.emitter = emitter;
72846
72871
  mediaObject.init = function () {
72847
- var _self$xml, _self$xml2, _self$xml3, _self$xml4, _self$xml5;
72872
+ var _self$xml, _self$xml2, _self$xml3, _self$xml4, _self$xml5, _self$xml6;
72848
72873
  var self = mediaObject;
72849
72874
  self.id = props.mediaId;
72850
72875
  self.fileId = ((_self$xml = self.xml) === null || _self$xml === void 0 ? void 0 : _self$xml.getAttribute('fileId')) || '';
@@ -72854,9 +72879,10 @@ function Media(region, mediaId, xml, options, xlr) {
72854
72879
  self.mediaType = ((_self$xml2 = self.xml) === null || _self$xml2 === void 0 ? void 0 : _self$xml2.getAttribute('type')) || '';
72855
72880
  self.render = ((_self$xml3 = self.xml) === null || _self$xml3 === void 0 ? void 0 : _self$xml3.getAttribute('render')) || '';
72856
72881
  self.duration = parseInt((_self$xml4 = self.xml) === null || _self$xml4 === void 0 ? void 0 : _self$xml4.getAttribute('duration')) || 0;
72882
+ self.enableStat = Boolean(((_self$xml5 = self.xml) === null || _self$xml5 === void 0 ? void 0 : _self$xml5.getAttribute('enableStat')) || false);
72857
72883
  self.options = _objectSpread2({}, props.options);
72858
72884
  var $mediaIframe = document.createElement('iframe');
72859
- var mediaOptions = (_self$xml5 = self.xml) === null || _self$xml5 === void 0 ? void 0 : _self$xml5.getElementsByTagName('options');
72885
+ var mediaOptions = (_self$xml6 = self.xml) === null || _self$xml6 === void 0 ? void 0 : _self$xml6.getElementsByTagName('options');
72860
72886
  if (mediaOptions) {
72861
72887
  for (var _i = 0, _Array$from = Array.from(mediaOptions); _i < _Array$from.length; _i++) {
72862
72888
  var _options = _Array$from[_i];
@@ -73884,9 +73910,19 @@ function Layout(data, options, xlr, layout) {
73884
73910
  layout: layout || initialLayout
73885
73911
  };
73886
73912
  var emitter = createNanoEvents();
73913
+ var statsBC = new BroadcastChannel('statsBC');
73887
73914
  emitter.on('start', function (layout) {
73888
73915
  layout.done = false;
73889
73916
  console.debug('Layout start emitted > Layout ID > ', layout.id);
73917
+ // Check if stats are enabled for the layout
73918
+ if (layout.enableStat) {
73919
+ statsBC.postMessage({
73920
+ action: 'START_STAT',
73921
+ layoutId: layout.id,
73922
+ scheduleId: layout.scheduleId,
73923
+ type: 'layout'
73924
+ });
73925
+ }
73890
73926
  });
73891
73927
  emitter.on('end', /*#__PURE__*/function () {
73892
73928
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(layout) {
@@ -73904,13 +73940,22 @@ function Layout(data, options, xlr, layout) {
73904
73940
  if ($layout !== null) {
73905
73941
  $layout.remove();
73906
73942
  }
73943
+ // Check if stats are enabled for the layout
73944
+ if (layout.enableStat) {
73945
+ statsBC.postMessage({
73946
+ action: 'END_STAT',
73947
+ layoutId: layout.id,
73948
+ scheduleId: layout.scheduleId,
73949
+ type: 'layout'
73950
+ });
73951
+ }
73907
73952
  if (xlr.config.platform !== 'CMS') {
73908
73953
  // Transition next layout to current layout and prepare next layout if exist
73909
73954
  xlr.prepareLayouts().then(function (parent) {
73910
73955
  xlr.playSchedules(parent);
73911
73956
  });
73912
73957
  }
73913
- case 6:
73958
+ case 7:
73914
73959
  case "end":
73915
73960
  return _context.stop();
73916
73961
  }
@@ -73948,7 +73993,7 @@ function Layout(data, options, xlr, layout) {
73948
73993
  layoutObject.parseXlf();
73949
73994
  };
73950
73995
  layoutObject.parseXlf = function () {
73951
- var _layout$layoutNode, _layout$layoutNode2, _layout$layoutNode3, _layout$layoutNode4, _layout$layoutNode5, _layout$layoutNode6, _layout$layoutNode7, _layout$layoutNode8;
73996
+ var _layout$layoutNode, _layout$layoutNode2, _layout$layoutNode3, _layout$layoutNode4, _layout$layoutNode5, _layout$layoutNode6, _layout$layoutNode7, _layout$layoutNode8, _layout$layoutNode9;
73952
73997
  var layout = this;
73953
73998
  var options = layout.options;
73954
73999
  layout.done = false;
@@ -73977,6 +74022,7 @@ function Layout(data, options, xlr, layout) {
73977
74022
  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'));
73978
74023
  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'));
73979
74024
  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;
74025
+ 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);
73980
74026
  /* Calculate Scale Factor */
73981
74027
  layout.scaleFactor = Math.min(layout.sw / layout.xw, layout.sh / layout.xh);
73982
74028
  layout.sWidth = layout.xw * layout.scaleFactor;
@@ -73995,8 +74041,8 @@ function Layout(data, options, xlr, layout) {
73995
74041
  $layout.style.zIndex = "".concat(layout.zIndex);
73996
74042
  }
73997
74043
  /* Set the layout background */
73998
- 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')) || '';
73999
- 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')) || '';
74044
+ 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')) || '';
74045
+ 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')) || '';
74000
74046
  if (!(layout.bgImage === "" || typeof layout.bgImage === 'undefined')) {
74001
74047
  /* Extract the image ID from the filename */
74002
74048
  layout.bgId = layout.bgImage.substring(0, layout.bgImage.indexOf('.'));
@@ -74019,19 +74065,19 @@ function Layout(data, options, xlr, layout) {
74019
74065
  $layout.style.display = 'none';
74020
74066
  }
74021
74067
  // Create actions
74022
- var layoutActions = Array.from((layout === null || layout === void 0 || (_layout$layoutNode6 = layout.layoutNode) === null || _layout$layoutNode6 === void 0 ? void 0 : _layout$layoutNode6.getElementsByTagName('action')) || []);
74068
+ var layoutActions = Array.from((layout === null || layout === void 0 || (_layout$layoutNode7 = layout.layoutNode) === null || _layout$layoutNode7 === void 0 ? void 0 : _layout$layoutNode7.getElementsByTagName('action')) || []);
74023
74069
  Array.from(layoutActions).forEach(function (actionXml, indx) {
74024
74070
  layout.actions.push(new Action((actionXml === null || actionXml === void 0 ? void 0 : actionXml.getAttribute('id')) || '', actionXml));
74025
74071
  });
74026
74072
  // Create interactive actions
74027
74073
  layout.actionController = new ActionController(layout, layout.actions, options);
74028
74074
  // Create drawer
74029
- var layoutDrawers = Array.from((layout === null || layout === void 0 || (_layout$layoutNode7 = layout.layoutNode) === null || _layout$layoutNode7 === void 0 ? void 0 : _layout$layoutNode7.getElementsByTagName('drawer')) || []);
74075
+ var layoutDrawers = Array.from((layout === null || layout === void 0 || (_layout$layoutNode8 = layout.layoutNode) === null || _layout$layoutNode8 === void 0 ? void 0 : _layout$layoutNode8.getElementsByTagName('drawer')) || []);
74030
74076
  Array.from(layoutDrawers).forEach(function (layoutDrawerXml) {
74031
74077
  layout.drawer = layoutDrawerXml;
74032
74078
  });
74033
74079
  // Create regions
74034
- var layoutRegions = Array.from((layout === null || layout === void 0 || (_layout$layoutNode8 = layout.layoutNode) === null || _layout$layoutNode8 === void 0 ? void 0 : _layout$layoutNode8.getElementsByTagName('region')) || []);
74080
+ var layoutRegions = Array.from((layout === null || layout === void 0 || (_layout$layoutNode9 = layout.layoutNode) === null || _layout$layoutNode9 === void 0 ? void 0 : _layout$layoutNode9.getElementsByTagName('region')) || []);
74035
74081
  Array.from(layoutRegions).forEach(function (regionXml, indx) {
74036
74082
  var regionObj = Region(layout, regionXml, (regionXml === null || regionXml === void 0 ? void 0 : regionXml.getAttribute('id')) || '', options, xlr);
74037
74083
  regionObj.index = indx;
@@ -74549,6 +74595,7 @@ function XiboLayoutRenderer(inputLayouts, options) {
74549
74595
  var xlrLayoutObj = initialLayout;
74550
74596
  xlrLayoutObj.id = Number(inputLayout.layoutId);
74551
74597
  xlrLayoutObj.layoutId = Number(inputLayout.layoutId);
74598
+ xlrLayoutObj.scheduleId = (inputLayout === null || inputLayout === void 0 ? void 0 : inputLayout.scheduleId) || undefined;
74552
74599
  xlrLayoutObj.options = newOptions;
74553
74600
  xlrLayoutObj.index = getIndexByLayoutId(_this3.inputLayouts, xlrLayoutObj.layoutId).index;
74554
74601
  resolve(Layout(layoutXlfNode, newOptions, self, xlrLayoutObj));