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
package/lib/index.js
CHANGED
|
@@ -5789,42 +5789,126 @@ function TextOverlay(param) {
|
|
|
5789
5789
|
children: text
|
|
5790
5790
|
});
|
|
5791
5791
|
}
|
|
5792
|
+
function parseRSSXml(xmlText, maxItems) {
|
|
5793
|
+
var parser = new DOMParser();
|
|
5794
|
+
var doc = parser.parseFromString(xmlText, "text/xml");
|
|
5795
|
+
if (doc.querySelector("parsererror")) throw new Error("Invalid RSS XML");
|
|
5796
|
+
return Array.from(doc.querySelectorAll("item")).map(function(item) {
|
|
5797
|
+
var _item_querySelector, _item_querySelector1, _item_querySelector2, _item_querySelector3, _item_querySelector4;
|
|
5798
|
+
return {
|
|
5799
|
+
title: (((_item_querySelector = item.querySelector("title")) === null || _item_querySelector === void 0 ? void 0 : _item_querySelector.textContent) || "").replace(/<[^>]*>/g, "").trim(),
|
|
5800
|
+
description: (((_item_querySelector1 = item.querySelector("description")) === null || _item_querySelector1 === void 0 ? void 0 : _item_querySelector1.textContent) || "").replace(/<[^>]*>/g, "").trim(),
|
|
5801
|
+
pubDate: ((_item_querySelector2 = item.querySelector("pubDate")) === null || _item_querySelector2 === void 0 ? void 0 : _item_querySelector2.textContent) || "",
|
|
5802
|
+
author: ((_item_querySelector3 = item.querySelector("author, dc\\:creator")) === null || _item_querySelector3 === void 0 ? void 0 : _item_querySelector3.textContent) || "",
|
|
5803
|
+
category: ((_item_querySelector4 = item.querySelector("category")) === null || _item_querySelector4 === void 0 ? void 0 : _item_querySelector4.textContent) || ""
|
|
5804
|
+
};
|
|
5805
|
+
}).filter(function(i) {
|
|
5806
|
+
return i.title;
|
|
5807
|
+
}).slice(0, maxItems);
|
|
5808
|
+
}
|
|
5792
5809
|
function fetchRSSItems(rssUrl, maxItems) {
|
|
5793
5810
|
return _async_to_generator(function() {
|
|
5794
|
-
var
|
|
5811
|
+
var encoded, resp2, data, unused, resp21, text2, unused1, resp, text;
|
|
5795
5812
|
return _ts_generator(this, function(_state) {
|
|
5796
5813
|
switch(_state.label){
|
|
5797
5814
|
case 0:
|
|
5815
|
+
encoded = encodeURIComponent(rssUrl);
|
|
5816
|
+
_state.label = 1;
|
|
5817
|
+
case 1:
|
|
5818
|
+
_state.trys.push([
|
|
5819
|
+
1,
|
|
5820
|
+
5,
|
|
5821
|
+
,
|
|
5822
|
+
6
|
|
5823
|
+
]);
|
|
5798
5824
|
return [
|
|
5799
5825
|
4,
|
|
5800
|
-
fetch("https://api.allorigins.win/get?url=".concat(
|
|
5826
|
+
fetch("https://api.allorigins.win/get?url=".concat(encoded))
|
|
5827
|
+
];
|
|
5828
|
+
case 2:
|
|
5829
|
+
resp2 = _state.sent();
|
|
5830
|
+
if (!resp2.ok) return [
|
|
5831
|
+
3,
|
|
5832
|
+
4
|
|
5801
5833
|
];
|
|
5802
|
-
case 1:
|
|
5803
|
-
resp = _state.sent();
|
|
5804
5834
|
return [
|
|
5805
5835
|
4,
|
|
5806
|
-
|
|
5836
|
+
resp2.json()
|
|
5807
5837
|
];
|
|
5808
|
-
case
|
|
5838
|
+
case 3:
|
|
5809
5839
|
data = _state.sent();
|
|
5810
|
-
if (
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5840
|
+
if (data.contents) return [
|
|
5841
|
+
2,
|
|
5842
|
+
parseRSSXml(data.contents, maxItems)
|
|
5843
|
+
];
|
|
5844
|
+
_state.label = 4;
|
|
5845
|
+
case 4:
|
|
5846
|
+
return [
|
|
5847
|
+
3,
|
|
5848
|
+
6
|
|
5849
|
+
];
|
|
5850
|
+
case 5:
|
|
5851
|
+
unused = _state.sent();
|
|
5852
|
+
return [
|
|
5853
|
+
3,
|
|
5854
|
+
6
|
|
5855
|
+
];
|
|
5856
|
+
case 6:
|
|
5857
|
+
_state.trys.push([
|
|
5858
|
+
6,
|
|
5859
|
+
10,
|
|
5860
|
+
,
|
|
5861
|
+
11
|
|
5862
|
+
]);
|
|
5863
|
+
return [
|
|
5864
|
+
4,
|
|
5865
|
+
fetch("https://corsproxy.io/?url=".concat(encoded))
|
|
5866
|
+
];
|
|
5867
|
+
case 7:
|
|
5868
|
+
resp21 = _state.sent();
|
|
5869
|
+
if (!resp21.ok) return [
|
|
5870
|
+
3,
|
|
5871
|
+
9
|
|
5872
|
+
];
|
|
5814
5873
|
return [
|
|
5874
|
+
4,
|
|
5875
|
+
resp21.text()
|
|
5876
|
+
];
|
|
5877
|
+
case 8:
|
|
5878
|
+
text2 = _state.sent();
|
|
5879
|
+
if (text2) return [
|
|
5815
5880
|
2,
|
|
5816
|
-
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5881
|
+
parseRSSXml(text2, maxItems)
|
|
5882
|
+
];
|
|
5883
|
+
_state.label = 9;
|
|
5884
|
+
case 9:
|
|
5885
|
+
return [
|
|
5886
|
+
3,
|
|
5887
|
+
11
|
|
5888
|
+
];
|
|
5889
|
+
case 10:
|
|
5890
|
+
unused1 = _state.sent();
|
|
5891
|
+
return [
|
|
5892
|
+
3,
|
|
5893
|
+
11
|
|
5894
|
+
];
|
|
5895
|
+
case 11:
|
|
5896
|
+
return [
|
|
5897
|
+
4,
|
|
5898
|
+
fetch("https://thingproxy.freeboard.io/fetch/".concat(rssUrl))
|
|
5899
|
+
];
|
|
5900
|
+
case 12:
|
|
5901
|
+
resp = _state.sent();
|
|
5902
|
+
if (!resp.ok) throw new Error("RSS fetch failed: ".concat(resp.status));
|
|
5903
|
+
return [
|
|
5904
|
+
4,
|
|
5905
|
+
resp.text()
|
|
5906
|
+
];
|
|
5907
|
+
case 13:
|
|
5908
|
+
text = _state.sent();
|
|
5909
|
+
return [
|
|
5910
|
+
2,
|
|
5911
|
+
parseRSSXml(text, maxItems)
|
|
5828
5912
|
];
|
|
5829
5913
|
}
|
|
5830
5914
|
});
|
|
@@ -5836,18 +5920,28 @@ function ScrollerOverlay(param) {
|
|
|
5836
5920
|
var cfg = overlay.scroller_config;
|
|
5837
5921
|
var uid = useId().replace(/:/g, "");
|
|
5838
5922
|
var _useState = _sliced_to_array(useState([]), 2), rssItems = _useState[0], setRssItems = _useState[1];
|
|
5839
|
-
var _useState1 = _sliced_to_array(useState(
|
|
5923
|
+
var _useState1 = _sliced_to_array(useState(true), 2), rssLoading = _useState1[0], setRssLoading = _useState1[1];
|
|
5924
|
+
var _useState2 = _sliced_to_array(useState(false), 2), rssError = _useState2[0], setRssError = _useState2[1];
|
|
5840
5925
|
var rssUrl = (cfg === null || cfg === void 0 ? void 0 : cfg.rss_url) || "";
|
|
5841
5926
|
var maxItems = (_ref = cfg === null || cfg === void 0 ? void 0 : cfg.max_items) !== null && _ref !== void 0 ? _ref : 10;
|
|
5842
5927
|
var autoRefresh = (cfg === null || cfg === void 0 ? void 0 : cfg.auto_refresh) !== false;
|
|
5843
5928
|
var updateInterval = (_ref1 = cfg === null || cfg === void 0 ? void 0 : cfg.update_interval) !== null && _ref1 !== void 0 ? _ref1 : 5;
|
|
5844
5929
|
useEffect(function() {
|
|
5845
|
-
if (!rssUrl || (cfg === null || cfg === void 0 ? void 0 : cfg.use_custom_text) && (cfg === null || cfg === void 0 ? void 0 : cfg.custom_text))
|
|
5930
|
+
if (!rssUrl || (cfg === null || cfg === void 0 ? void 0 : cfg.use_custom_text) && (cfg === null || cfg === void 0 ? void 0 : cfg.custom_text)) {
|
|
5931
|
+
setRssLoading(false);
|
|
5932
|
+
return;
|
|
5933
|
+
}
|
|
5846
5934
|
var cancelled = false;
|
|
5847
5935
|
setRssLoading(true);
|
|
5936
|
+
setRssError(false);
|
|
5848
5937
|
fetchRSSItems(rssUrl, maxItems).then(function(items) {
|
|
5849
|
-
if (!cancelled)
|
|
5850
|
-
|
|
5938
|
+
if (!cancelled) {
|
|
5939
|
+
setRssItems(items);
|
|
5940
|
+
setRssError(false);
|
|
5941
|
+
}
|
|
5942
|
+
}).catch(function() {
|
|
5943
|
+
if (!cancelled) setRssError(true);
|
|
5944
|
+
}).finally(function() {
|
|
5851
5945
|
if (!cancelled) setRssLoading(false);
|
|
5852
5946
|
});
|
|
5853
5947
|
return function() {
|
|
@@ -5862,7 +5956,10 @@ function ScrollerOverlay(param) {
|
|
|
5862
5956
|
useEffect(function() {
|
|
5863
5957
|
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;
|
|
5864
5958
|
var interval = setInterval(function() {
|
|
5865
|
-
fetchRSSItems(rssUrl, maxItems).then(
|
|
5959
|
+
fetchRSSItems(rssUrl, maxItems).then(function(items) {
|
|
5960
|
+
setRssItems(items);
|
|
5961
|
+
setRssError(false);
|
|
5962
|
+
}).catch(function() {});
|
|
5866
5963
|
}, updateInterval * 60 * 1e3);
|
|
5867
5964
|
return function() {
|
|
5868
5965
|
return clearInterval(interval);
|
|
@@ -5899,13 +5996,19 @@ function ScrollerOverlay(param) {
|
|
|
5899
5996
|
segments = [
|
|
5900
5997
|
"Loading feed\u2026"
|
|
5901
5998
|
];
|
|
5999
|
+
} else if (rssError) {
|
|
6000
|
+
segments = overlay.content ? [
|
|
6001
|
+
overlay.content
|
|
6002
|
+
] : [
|
|
6003
|
+
"RSS feed unavailable"
|
|
6004
|
+
];
|
|
5902
6005
|
} else if (overlay.content) {
|
|
5903
6006
|
segments = [
|
|
5904
6007
|
overlay.content
|
|
5905
6008
|
];
|
|
5906
6009
|
} else {
|
|
5907
6010
|
segments = rssUrl ? [
|
|
5908
|
-
"
|
|
6011
|
+
"Loading feed\u2026"
|
|
5909
6012
|
] : [
|
|
5910
6013
|
"RSS Ticker"
|
|
5911
6014
|
];
|