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