stormcloud-video-player 0.7.27 → 0.7.28
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/stormcloud-vp.min.js +1 -1
- package/lib/index.cjs +131 -28
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +131 -28
- package/lib/index.js.map +1 -1
- package/lib/ui/OverlayRenderer.cjs +131 -28
- package/lib/ui/OverlayRenderer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +131 -28
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -5777,42 +5777,126 @@ function TextOverlay(param) {
|
|
|
5777
5777
|
children: text
|
|
5778
5778
|
});
|
|
5779
5779
|
}
|
|
5780
|
+
function parseRSSXml(xmlText, maxItems) {
|
|
5781
|
+
var parser = new DOMParser();
|
|
5782
|
+
var doc = parser.parseFromString(xmlText, "text/xml");
|
|
5783
|
+
if (doc.querySelector("parsererror")) throw new Error("Invalid RSS XML");
|
|
5784
|
+
return Array.from(doc.querySelectorAll("item")).map(function(item) {
|
|
5785
|
+
var _item_querySelector, _item_querySelector1, _item_querySelector2, _item_querySelector3, _item_querySelector4;
|
|
5786
|
+
return {
|
|
5787
|
+
title: (((_item_querySelector = item.querySelector("title")) === null || _item_querySelector === void 0 ? void 0 : _item_querySelector.textContent) || "").replace(/<[^>]*>/g, "").trim(),
|
|
5788
|
+
description: (((_item_querySelector1 = item.querySelector("description")) === null || _item_querySelector1 === void 0 ? void 0 : _item_querySelector1.textContent) || "").replace(/<[^>]*>/g, "").trim(),
|
|
5789
|
+
pubDate: ((_item_querySelector2 = item.querySelector("pubDate")) === null || _item_querySelector2 === void 0 ? void 0 : _item_querySelector2.textContent) || "",
|
|
5790
|
+
author: ((_item_querySelector3 = item.querySelector("author, dc\\:creator")) === null || _item_querySelector3 === void 0 ? void 0 : _item_querySelector3.textContent) || "",
|
|
5791
|
+
category: ((_item_querySelector4 = item.querySelector("category")) === null || _item_querySelector4 === void 0 ? void 0 : _item_querySelector4.textContent) || ""
|
|
5792
|
+
};
|
|
5793
|
+
}).filter(function(i) {
|
|
5794
|
+
return i.title;
|
|
5795
|
+
}).slice(0, maxItems);
|
|
5796
|
+
}
|
|
5780
5797
|
function fetchRSSItems(rssUrl, maxItems) {
|
|
5781
5798
|
return _async_to_generator(function() {
|
|
5782
|
-
var
|
|
5799
|
+
var encoded, resp2, data, unused, resp21, text2, unused1, resp, text;
|
|
5783
5800
|
return _ts_generator(this, function(_state) {
|
|
5784
5801
|
switch(_state.label){
|
|
5785
5802
|
case 0:
|
|
5803
|
+
encoded = encodeURIComponent(rssUrl);
|
|
5804
|
+
_state.label = 1;
|
|
5805
|
+
case 1:
|
|
5806
|
+
_state.trys.push([
|
|
5807
|
+
1,
|
|
5808
|
+
5,
|
|
5809
|
+
,
|
|
5810
|
+
6
|
|
5811
|
+
]);
|
|
5786
5812
|
return [
|
|
5787
5813
|
4,
|
|
5788
|
-
fetch("https://api.allorigins.win/get?url=".concat(
|
|
5814
|
+
fetch("https://api.allorigins.win/get?url=".concat(encoded))
|
|
5815
|
+
];
|
|
5816
|
+
case 2:
|
|
5817
|
+
resp2 = _state.sent();
|
|
5818
|
+
if (!resp2.ok) return [
|
|
5819
|
+
3,
|
|
5820
|
+
4
|
|
5789
5821
|
];
|
|
5790
|
-
case 1:
|
|
5791
|
-
resp = _state.sent();
|
|
5792
5822
|
return [
|
|
5793
5823
|
4,
|
|
5794
|
-
|
|
5824
|
+
resp2.json()
|
|
5795
5825
|
];
|
|
5796
|
-
case
|
|
5826
|
+
case 3:
|
|
5797
5827
|
data = _state.sent();
|
|
5798
|
-
if (
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5828
|
+
if (data.contents) return [
|
|
5829
|
+
2,
|
|
5830
|
+
parseRSSXml(data.contents, maxItems)
|
|
5831
|
+
];
|
|
5832
|
+
_state.label = 4;
|
|
5833
|
+
case 4:
|
|
5834
|
+
return [
|
|
5835
|
+
3,
|
|
5836
|
+
6
|
|
5837
|
+
];
|
|
5838
|
+
case 5:
|
|
5839
|
+
unused = _state.sent();
|
|
5840
|
+
return [
|
|
5841
|
+
3,
|
|
5842
|
+
6
|
|
5843
|
+
];
|
|
5844
|
+
case 6:
|
|
5845
|
+
_state.trys.push([
|
|
5846
|
+
6,
|
|
5847
|
+
10,
|
|
5848
|
+
,
|
|
5849
|
+
11
|
|
5850
|
+
]);
|
|
5851
|
+
return [
|
|
5852
|
+
4,
|
|
5853
|
+
fetch("https://corsproxy.io/?url=".concat(encoded))
|
|
5854
|
+
];
|
|
5855
|
+
case 7:
|
|
5856
|
+
resp21 = _state.sent();
|
|
5857
|
+
if (!resp21.ok) return [
|
|
5858
|
+
3,
|
|
5859
|
+
9
|
|
5860
|
+
];
|
|
5802
5861
|
return [
|
|
5862
|
+
4,
|
|
5863
|
+
resp21.text()
|
|
5864
|
+
];
|
|
5865
|
+
case 8:
|
|
5866
|
+
text2 = _state.sent();
|
|
5867
|
+
if (text2) return [
|
|
5803
5868
|
2,
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5869
|
+
parseRSSXml(text2, maxItems)
|
|
5870
|
+
];
|
|
5871
|
+
_state.label = 9;
|
|
5872
|
+
case 9:
|
|
5873
|
+
return [
|
|
5874
|
+
3,
|
|
5875
|
+
11
|
|
5876
|
+
];
|
|
5877
|
+
case 10:
|
|
5878
|
+
unused1 = _state.sent();
|
|
5879
|
+
return [
|
|
5880
|
+
3,
|
|
5881
|
+
11
|
|
5882
|
+
];
|
|
5883
|
+
case 11:
|
|
5884
|
+
return [
|
|
5885
|
+
4,
|
|
5886
|
+
fetch("https://thingproxy.freeboard.io/fetch/".concat(rssUrl))
|
|
5887
|
+
];
|
|
5888
|
+
case 12:
|
|
5889
|
+
resp = _state.sent();
|
|
5890
|
+
if (!resp.ok) throw new Error("RSS fetch failed: ".concat(resp.status));
|
|
5891
|
+
return [
|
|
5892
|
+
4,
|
|
5893
|
+
resp.text()
|
|
5894
|
+
];
|
|
5895
|
+
case 13:
|
|
5896
|
+
text = _state.sent();
|
|
5897
|
+
return [
|
|
5898
|
+
2,
|
|
5899
|
+
parseRSSXml(text, maxItems)
|
|
5816
5900
|
];
|
|
5817
5901
|
}
|
|
5818
5902
|
});
|
|
@@ -5824,18 +5908,28 @@ function ScrollerOverlay(param) {
|
|
|
5824
5908
|
var cfg = overlay.scroller_config;
|
|
5825
5909
|
var uid = (0, import_react.useId)().replace(/:/g, "");
|
|
5826
5910
|
var _ref13 = _sliced_to_array((0, import_react.useState)([]), 2), rssItems = _ref13[0], setRssItems = _ref13[1];
|
|
5827
|
-
var _ref14 = _sliced_to_array((0, import_react.useState)(
|
|
5911
|
+
var _ref14 = _sliced_to_array((0, import_react.useState)(true), 2), rssLoading = _ref14[0], setRssLoading = _ref14[1];
|
|
5912
|
+
var _ref15 = _sliced_to_array((0, import_react.useState)(false), 2), rssError = _ref15[0], setRssError = _ref15[1];
|
|
5828
5913
|
var rssUrl = (cfg === null || cfg === void 0 ? void 0 : cfg.rss_url) || "";
|
|
5829
5914
|
var maxItems = (_ref = cfg === null || cfg === void 0 ? void 0 : cfg.max_items) !== null && _ref !== void 0 ? _ref : 10;
|
|
5830
5915
|
var autoRefresh = (cfg === null || cfg === void 0 ? void 0 : cfg.auto_refresh) !== false;
|
|
5831
5916
|
var updateInterval = (_ref1 = cfg === null || cfg === void 0 ? void 0 : cfg.update_interval) !== null && _ref1 !== void 0 ? _ref1 : 5;
|
|
5832
5917
|
(0, import_react.useEffect)(function() {
|
|
5833
|
-
if (!rssUrl || (cfg === null || cfg === void 0 ? void 0 : cfg.use_custom_text) && (cfg === null || cfg === void 0 ? void 0 : cfg.custom_text))
|
|
5918
|
+
if (!rssUrl || (cfg === null || cfg === void 0 ? void 0 : cfg.use_custom_text) && (cfg === null || cfg === void 0 ? void 0 : cfg.custom_text)) {
|
|
5919
|
+
setRssLoading(false);
|
|
5920
|
+
return;
|
|
5921
|
+
}
|
|
5834
5922
|
var cancelled = false;
|
|
5835
5923
|
setRssLoading(true);
|
|
5924
|
+
setRssError(false);
|
|
5836
5925
|
fetchRSSItems(rssUrl, maxItems).then(function(items) {
|
|
5837
|
-
if (!cancelled)
|
|
5838
|
-
|
|
5926
|
+
if (!cancelled) {
|
|
5927
|
+
setRssItems(items);
|
|
5928
|
+
setRssError(false);
|
|
5929
|
+
}
|
|
5930
|
+
}).catch(function() {
|
|
5931
|
+
if (!cancelled) setRssError(true);
|
|
5932
|
+
}).finally(function() {
|
|
5839
5933
|
if (!cancelled) setRssLoading(false);
|
|
5840
5934
|
});
|
|
5841
5935
|
return function() {
|
|
@@ -5850,7 +5944,10 @@ function ScrollerOverlay(param) {
|
|
|
5850
5944
|
(0, import_react.useEffect)(function() {
|
|
5851
5945
|
if (!rssUrl || !autoRefresh || (cfg === null || cfg === void 0 ? void 0 : cfg.use_custom_text) && (cfg === null || cfg === void 0 ? void 0 : cfg.custom_text)) return;
|
|
5852
5946
|
var interval = setInterval(function() {
|
|
5853
|
-
fetchRSSItems(rssUrl, maxItems).then(
|
|
5947
|
+
fetchRSSItems(rssUrl, maxItems).then(function(items) {
|
|
5948
|
+
setRssItems(items);
|
|
5949
|
+
setRssError(false);
|
|
5950
|
+
}).catch(function() {});
|
|
5854
5951
|
}, updateInterval * 60 * 1e3);
|
|
5855
5952
|
return function() {
|
|
5856
5953
|
return clearInterval(interval);
|
|
@@ -5887,13 +5984,19 @@ function ScrollerOverlay(param) {
|
|
|
5887
5984
|
segments = [
|
|
5888
5985
|
"Loading feed\u2026"
|
|
5889
5986
|
];
|
|
5987
|
+
} else if (rssError) {
|
|
5988
|
+
segments = overlay.content ? [
|
|
5989
|
+
overlay.content
|
|
5990
|
+
] : [
|
|
5991
|
+
"RSS feed unavailable"
|
|
5992
|
+
];
|
|
5890
5993
|
} else if (overlay.content) {
|
|
5891
5994
|
segments = [
|
|
5892
5995
|
overlay.content
|
|
5893
5996
|
];
|
|
5894
5997
|
} else {
|
|
5895
5998
|
segments = rssUrl ? [
|
|
5896
|
-
"
|
|
5999
|
+
"Loading feed\u2026"
|
|
5897
6000
|
] : [
|
|
5898
6001
|
"RSS Ticker"
|
|
5899
6002
|
];
|