stormcloud-video-player 0.7.27 → 0.7.29
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 +154 -27
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +154 -27
- package/lib/index.js.map +1 -1
- package/lib/ui/OverlayRenderer.cjs +154 -27
- package/lib/ui/OverlayRenderer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +154 -27
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -5789,43 +5789,151 @@ 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 resp, data,
|
|
5811
|
+
var encoded, origin, resp, text, unused, resp1, data, unused1, resp2, text1, unused2;
|
|
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
|
+
]);
|
|
5824
|
+
origin = typeof window !== "undefined" ? window.location.origin : "";
|
|
5798
5825
|
return [
|
|
5799
5826
|
4,
|
|
5800
|
-
fetch("
|
|
5827
|
+
fetch("".concat(origin, "/api/rss-proxy?url=").concat(encoded))
|
|
5801
5828
|
];
|
|
5802
|
-
case
|
|
5829
|
+
case 2:
|
|
5803
5830
|
resp = _state.sent();
|
|
5831
|
+
if (!resp.ok) return [
|
|
5832
|
+
3,
|
|
5833
|
+
4
|
|
5834
|
+
];
|
|
5804
5835
|
return [
|
|
5805
5836
|
4,
|
|
5806
|
-
resp.
|
|
5837
|
+
resp.text()
|
|
5807
5838
|
];
|
|
5808
|
-
case
|
|
5839
|
+
case 3:
|
|
5840
|
+
text = _state.sent();
|
|
5841
|
+
if (text.includes("<item")) return [
|
|
5842
|
+
2,
|
|
5843
|
+
parseRSSXml(text, maxItems)
|
|
5844
|
+
];
|
|
5845
|
+
_state.label = 4;
|
|
5846
|
+
case 4:
|
|
5847
|
+
return [
|
|
5848
|
+
3,
|
|
5849
|
+
6
|
|
5850
|
+
];
|
|
5851
|
+
case 5:
|
|
5852
|
+
unused = _state.sent();
|
|
5853
|
+
return [
|
|
5854
|
+
3,
|
|
5855
|
+
6
|
|
5856
|
+
];
|
|
5857
|
+
case 6:
|
|
5858
|
+
_state.trys.push([
|
|
5859
|
+
6,
|
|
5860
|
+
10,
|
|
5861
|
+
,
|
|
5862
|
+
11
|
|
5863
|
+
]);
|
|
5864
|
+
return [
|
|
5865
|
+
4,
|
|
5866
|
+
fetch("https://api.allorigins.win/get?url=".concat(encoded))
|
|
5867
|
+
];
|
|
5868
|
+
case 7:
|
|
5869
|
+
resp1 = _state.sent();
|
|
5870
|
+
if (!resp1.ok) return [
|
|
5871
|
+
3,
|
|
5872
|
+
9
|
|
5873
|
+
];
|
|
5874
|
+
return [
|
|
5875
|
+
4,
|
|
5876
|
+
resp1.json()
|
|
5877
|
+
];
|
|
5878
|
+
case 8:
|
|
5809
5879
|
data = _state.sent();
|
|
5810
|
-
if (
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5880
|
+
if (data.contents) return [
|
|
5881
|
+
2,
|
|
5882
|
+
parseRSSXml(data.contents, maxItems)
|
|
5883
|
+
];
|
|
5884
|
+
_state.label = 9;
|
|
5885
|
+
case 9:
|
|
5886
|
+
return [
|
|
5887
|
+
3,
|
|
5888
|
+
11
|
|
5889
|
+
];
|
|
5890
|
+
case 10:
|
|
5891
|
+
unused1 = _state.sent();
|
|
5892
|
+
return [
|
|
5893
|
+
3,
|
|
5894
|
+
11
|
|
5895
|
+
];
|
|
5896
|
+
case 11:
|
|
5897
|
+
_state.trys.push([
|
|
5898
|
+
11,
|
|
5899
|
+
15,
|
|
5900
|
+
,
|
|
5901
|
+
16
|
|
5902
|
+
]);
|
|
5903
|
+
return [
|
|
5904
|
+
4,
|
|
5905
|
+
fetch("https://corsproxy.io/?url=".concat(encoded))
|
|
5906
|
+
];
|
|
5907
|
+
case 12:
|
|
5908
|
+
resp2 = _state.sent();
|
|
5909
|
+
if (!resp2.ok) return [
|
|
5910
|
+
3,
|
|
5911
|
+
14
|
|
5912
|
+
];
|
|
5814
5913
|
return [
|
|
5914
|
+
4,
|
|
5915
|
+
resp2.text()
|
|
5916
|
+
];
|
|
5917
|
+
case 13:
|
|
5918
|
+
text1 = _state.sent();
|
|
5919
|
+
if (text1) return [
|
|
5815
5920
|
2,
|
|
5816
|
-
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5921
|
+
parseRSSXml(text1, maxItems)
|
|
5922
|
+
];
|
|
5923
|
+
_state.label = 14;
|
|
5924
|
+
case 14:
|
|
5925
|
+
return [
|
|
5926
|
+
3,
|
|
5927
|
+
16
|
|
5928
|
+
];
|
|
5929
|
+
case 15:
|
|
5930
|
+
unused2 = _state.sent();
|
|
5931
|
+
return [
|
|
5932
|
+
3,
|
|
5933
|
+
16
|
|
5828
5934
|
];
|
|
5935
|
+
case 16:
|
|
5936
|
+
throw new Error("All RSS proxies failed");
|
|
5829
5937
|
}
|
|
5830
5938
|
});
|
|
5831
5939
|
})();
|
|
@@ -5836,18 +5944,28 @@ function ScrollerOverlay(param) {
|
|
|
5836
5944
|
var cfg = overlay.scroller_config;
|
|
5837
5945
|
var uid = useId().replace(/:/g, "");
|
|
5838
5946
|
var _useState = _sliced_to_array(useState([]), 2), rssItems = _useState[0], setRssItems = _useState[1];
|
|
5839
|
-
var _useState1 = _sliced_to_array(useState(
|
|
5947
|
+
var _useState1 = _sliced_to_array(useState(true), 2), rssLoading = _useState1[0], setRssLoading = _useState1[1];
|
|
5948
|
+
var _useState2 = _sliced_to_array(useState(false), 2), rssError = _useState2[0], setRssError = _useState2[1];
|
|
5840
5949
|
var rssUrl = (cfg === null || cfg === void 0 ? void 0 : cfg.rss_url) || "";
|
|
5841
5950
|
var maxItems = (_ref = cfg === null || cfg === void 0 ? void 0 : cfg.max_items) !== null && _ref !== void 0 ? _ref : 10;
|
|
5842
5951
|
var autoRefresh = (cfg === null || cfg === void 0 ? void 0 : cfg.auto_refresh) !== false;
|
|
5843
5952
|
var updateInterval = (_ref1 = cfg === null || cfg === void 0 ? void 0 : cfg.update_interval) !== null && _ref1 !== void 0 ? _ref1 : 5;
|
|
5844
5953
|
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))
|
|
5954
|
+
if (!rssUrl || (cfg === null || cfg === void 0 ? void 0 : cfg.use_custom_text) && (cfg === null || cfg === void 0 ? void 0 : cfg.custom_text)) {
|
|
5955
|
+
setRssLoading(false);
|
|
5956
|
+
return;
|
|
5957
|
+
}
|
|
5846
5958
|
var cancelled = false;
|
|
5847
5959
|
setRssLoading(true);
|
|
5960
|
+
setRssError(false);
|
|
5848
5961
|
fetchRSSItems(rssUrl, maxItems).then(function(items) {
|
|
5849
|
-
if (!cancelled)
|
|
5850
|
-
|
|
5962
|
+
if (!cancelled) {
|
|
5963
|
+
setRssItems(items);
|
|
5964
|
+
setRssError(false);
|
|
5965
|
+
}
|
|
5966
|
+
}).catch(function() {
|
|
5967
|
+
if (!cancelled) setRssError(true);
|
|
5968
|
+
}).finally(function() {
|
|
5851
5969
|
if (!cancelled) setRssLoading(false);
|
|
5852
5970
|
});
|
|
5853
5971
|
return function() {
|
|
@@ -5862,7 +5980,10 @@ function ScrollerOverlay(param) {
|
|
|
5862
5980
|
useEffect(function() {
|
|
5863
5981
|
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
5982
|
var interval = setInterval(function() {
|
|
5865
|
-
fetchRSSItems(rssUrl, maxItems).then(
|
|
5983
|
+
fetchRSSItems(rssUrl, maxItems).then(function(items) {
|
|
5984
|
+
setRssItems(items);
|
|
5985
|
+
setRssError(false);
|
|
5986
|
+
}).catch(function() {});
|
|
5866
5987
|
}, updateInterval * 60 * 1e3);
|
|
5867
5988
|
return function() {
|
|
5868
5989
|
return clearInterval(interval);
|
|
@@ -5899,13 +6020,19 @@ function ScrollerOverlay(param) {
|
|
|
5899
6020
|
segments = [
|
|
5900
6021
|
"Loading feed\u2026"
|
|
5901
6022
|
];
|
|
6023
|
+
} else if (rssError) {
|
|
6024
|
+
segments = overlay.content ? [
|
|
6025
|
+
overlay.content
|
|
6026
|
+
] : [
|
|
6027
|
+
"RSS feed unavailable"
|
|
6028
|
+
];
|
|
5902
6029
|
} else if (overlay.content) {
|
|
5903
6030
|
segments = [
|
|
5904
6031
|
overlay.content
|
|
5905
6032
|
];
|
|
5906
6033
|
} else {
|
|
5907
6034
|
segments = rssUrl ? [
|
|
5908
|
-
"
|
|
6035
|
+
"Loading feed\u2026"
|
|
5909
6036
|
] : [
|
|
5910
6037
|
"RSS Ticker"
|
|
5911
6038
|
];
|