stormcloud-video-player 0.7.28 → 0.7.30
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 +72 -27
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +72 -27
- package/lib/index.js.map +1 -1
- package/lib/ui/OverlayRenderer.cjs +72 -27
- package/lib/ui/OverlayRenderer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +72 -27
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -5778,10 +5778,10 @@ function TextOverlay(param) {
|
|
|
5778
5778
|
});
|
|
5779
5779
|
}
|
|
5780
5780
|
function parseRSSXml(xmlText, maxItems) {
|
|
5781
|
+
var stripped = xmlText.replace(/^<\?xml[^?]*\?>\s*/, "");
|
|
5781
5782
|
var parser = new DOMParser();
|
|
5782
|
-
var doc = parser.parseFromString(
|
|
5783
|
-
|
|
5784
|
-
return Array.from(doc.querySelectorAll("item")).map(function(item) {
|
|
5783
|
+
var doc = parser.parseFromString(stripped, "text/xml");
|
|
5784
|
+
var items = Array.from(doc.querySelectorAll("item")).map(function(item) {
|
|
5785
5785
|
var _item_querySelector, _item_querySelector1, _item_querySelector2, _item_querySelector3, _item_querySelector4;
|
|
5786
5786
|
return {
|
|
5787
5787
|
title: (((_item_querySelector = item.querySelector("title")) === null || _item_querySelector === void 0 ? void 0 : _item_querySelector.textContent) || "").replace(/<[^>]*>/g, "").trim(),
|
|
@@ -5793,10 +5793,30 @@ function parseRSSXml(xmlText, maxItems) {
|
|
|
5793
5793
|
}).filter(function(i) {
|
|
5794
5794
|
return i.title;
|
|
5795
5795
|
}).slice(0, maxItems);
|
|
5796
|
+
if (items.length === 0 && doc.querySelector("parsererror")) {
|
|
5797
|
+
throw new Error("Invalid RSS XML");
|
|
5798
|
+
}
|
|
5799
|
+
return items;
|
|
5800
|
+
}
|
|
5801
|
+
var RSS_CACHE_TTL_MS = 6e4;
|
|
5802
|
+
var rssCache = /* @__PURE__ */ new Map();
|
|
5803
|
+
function cachedFetchRSSItems(rssUrl, maxItems) {
|
|
5804
|
+
var now = Date.now();
|
|
5805
|
+
var cached = rssCache.get(rssUrl);
|
|
5806
|
+
if (cached && cached.expiresAt > now) return cached.promise;
|
|
5807
|
+
var promise = fetchRSSItems(rssUrl, maxItems).catch(function(err) {
|
|
5808
|
+
rssCache.delete(rssUrl);
|
|
5809
|
+
throw err;
|
|
5810
|
+
});
|
|
5811
|
+
rssCache.set(rssUrl, {
|
|
5812
|
+
promise: promise,
|
|
5813
|
+
expiresAt: now + RSS_CACHE_TTL_MS
|
|
5814
|
+
});
|
|
5815
|
+
return promise;
|
|
5796
5816
|
}
|
|
5797
5817
|
function fetchRSSItems(rssUrl, maxItems) {
|
|
5798
5818
|
return _async_to_generator(function() {
|
|
5799
|
-
var encoded,
|
|
5819
|
+
var encoded, origin, resp, text, unused, resp1, data, unused1, resp2, text1, unused2;
|
|
5800
5820
|
return _ts_generator(this, function(_state) {
|
|
5801
5821
|
switch(_state.label){
|
|
5802
5822
|
case 0:
|
|
@@ -5809,25 +5829,26 @@ function fetchRSSItems(rssUrl, maxItems) {
|
|
|
5809
5829
|
,
|
|
5810
5830
|
6
|
|
5811
5831
|
]);
|
|
5832
|
+
origin = typeof window !== "undefined" ? window.location.origin : "";
|
|
5812
5833
|
return [
|
|
5813
5834
|
4,
|
|
5814
|
-
fetch("
|
|
5835
|
+
fetch("".concat(origin, "/api/rss-proxy?url=").concat(encoded))
|
|
5815
5836
|
];
|
|
5816
5837
|
case 2:
|
|
5817
|
-
|
|
5818
|
-
if (!
|
|
5838
|
+
resp = _state.sent();
|
|
5839
|
+
if (!resp.ok) return [
|
|
5819
5840
|
3,
|
|
5820
5841
|
4
|
|
5821
5842
|
];
|
|
5822
5843
|
return [
|
|
5823
5844
|
4,
|
|
5824
|
-
|
|
5845
|
+
resp.text()
|
|
5825
5846
|
];
|
|
5826
5847
|
case 3:
|
|
5827
|
-
|
|
5828
|
-
if (
|
|
5848
|
+
text = _state.sent();
|
|
5849
|
+
if (text.includes("<item")) return [
|
|
5829
5850
|
2,
|
|
5830
|
-
parseRSSXml(
|
|
5851
|
+
parseRSSXml(text, maxItems)
|
|
5831
5852
|
];
|
|
5832
5853
|
_state.label = 4;
|
|
5833
5854
|
case 4:
|
|
@@ -5850,23 +5871,23 @@ function fetchRSSItems(rssUrl, maxItems) {
|
|
|
5850
5871
|
]);
|
|
5851
5872
|
return [
|
|
5852
5873
|
4,
|
|
5853
|
-
fetch("https://
|
|
5874
|
+
fetch("https://api.allorigins.win/get?url=".concat(encoded))
|
|
5854
5875
|
];
|
|
5855
5876
|
case 7:
|
|
5856
|
-
|
|
5857
|
-
if (!
|
|
5877
|
+
resp1 = _state.sent();
|
|
5878
|
+
if (!resp1.ok) return [
|
|
5858
5879
|
3,
|
|
5859
5880
|
9
|
|
5860
5881
|
];
|
|
5861
5882
|
return [
|
|
5862
5883
|
4,
|
|
5863
|
-
|
|
5884
|
+
resp1.json()
|
|
5864
5885
|
];
|
|
5865
5886
|
case 8:
|
|
5866
|
-
|
|
5867
|
-
if (
|
|
5887
|
+
data = _state.sent();
|
|
5888
|
+
if (data.contents) return [
|
|
5868
5889
|
2,
|
|
5869
|
-
parseRSSXml(
|
|
5890
|
+
parseRSSXml(data.contents, maxItems)
|
|
5870
5891
|
];
|
|
5871
5892
|
_state.label = 9;
|
|
5872
5893
|
case 9:
|
|
@@ -5881,23 +5902,46 @@ function fetchRSSItems(rssUrl, maxItems) {
|
|
|
5881
5902
|
11
|
|
5882
5903
|
];
|
|
5883
5904
|
case 11:
|
|
5905
|
+
_state.trys.push([
|
|
5906
|
+
11,
|
|
5907
|
+
15,
|
|
5908
|
+
,
|
|
5909
|
+
16
|
|
5910
|
+
]);
|
|
5884
5911
|
return [
|
|
5885
5912
|
4,
|
|
5886
|
-
fetch("https://
|
|
5913
|
+
fetch("https://corsproxy.io/?url=".concat(encoded))
|
|
5887
5914
|
];
|
|
5888
5915
|
case 12:
|
|
5889
|
-
|
|
5890
|
-
if (!
|
|
5916
|
+
resp2 = _state.sent();
|
|
5917
|
+
if (!resp2.ok) return [
|
|
5918
|
+
3,
|
|
5919
|
+
14
|
|
5920
|
+
];
|
|
5891
5921
|
return [
|
|
5892
5922
|
4,
|
|
5893
|
-
|
|
5923
|
+
resp2.text()
|
|
5894
5924
|
];
|
|
5895
5925
|
case 13:
|
|
5896
|
-
|
|
5897
|
-
return [
|
|
5926
|
+
text1 = _state.sent();
|
|
5927
|
+
if (text1) return [
|
|
5898
5928
|
2,
|
|
5899
|
-
parseRSSXml(
|
|
5929
|
+
parseRSSXml(text1, maxItems)
|
|
5930
|
+
];
|
|
5931
|
+
_state.label = 14;
|
|
5932
|
+
case 14:
|
|
5933
|
+
return [
|
|
5934
|
+
3,
|
|
5935
|
+
16
|
|
5936
|
+
];
|
|
5937
|
+
case 15:
|
|
5938
|
+
unused2 = _state.sent();
|
|
5939
|
+
return [
|
|
5940
|
+
3,
|
|
5941
|
+
16
|
|
5900
5942
|
];
|
|
5943
|
+
case 16:
|
|
5944
|
+
throw new Error("All RSS proxies failed");
|
|
5901
5945
|
}
|
|
5902
5946
|
});
|
|
5903
5947
|
})();
|
|
@@ -5922,7 +5966,7 @@ function ScrollerOverlay(param) {
|
|
|
5922
5966
|
var cancelled = false;
|
|
5923
5967
|
setRssLoading(true);
|
|
5924
5968
|
setRssError(false);
|
|
5925
|
-
|
|
5969
|
+
cachedFetchRSSItems(rssUrl, maxItems).then(function(items) {
|
|
5926
5970
|
if (!cancelled) {
|
|
5927
5971
|
setRssItems(items);
|
|
5928
5972
|
setRssError(false);
|
|
@@ -5944,7 +5988,8 @@ function ScrollerOverlay(param) {
|
|
|
5944
5988
|
(0, import_react.useEffect)(function() {
|
|
5945
5989
|
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;
|
|
5946
5990
|
var interval = setInterval(function() {
|
|
5947
|
-
|
|
5991
|
+
rssCache.delete(rssUrl);
|
|
5992
|
+
cachedFetchRSSItems(rssUrl, maxItems).then(function(items) {
|
|
5948
5993
|
setRssItems(items);
|
|
5949
5994
|
setRssError(false);
|
|
5950
5995
|
}).catch(function() {});
|