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