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.cjs
CHANGED
|
@@ -5956,10 +5956,10 @@ function TextOverlay(param) {
|
|
|
5956
5956
|
});
|
|
5957
5957
|
}
|
|
5958
5958
|
function parseRSSXml(xmlText, maxItems) {
|
|
5959
|
+
var stripped = xmlText.replace(/^<\?xml[^?]*\?>\s*/, "");
|
|
5959
5960
|
var parser = new DOMParser();
|
|
5960
|
-
var doc = parser.parseFromString(
|
|
5961
|
-
|
|
5962
|
-
return Array.from(doc.querySelectorAll("item")).map(function(item) {
|
|
5961
|
+
var doc = parser.parseFromString(stripped, "text/xml");
|
|
5962
|
+
var items = Array.from(doc.querySelectorAll("item")).map(function(item) {
|
|
5963
5963
|
var _item_querySelector, _item_querySelector1, _item_querySelector2, _item_querySelector3, _item_querySelector4;
|
|
5964
5964
|
return {
|
|
5965
5965
|
title: (((_item_querySelector = item.querySelector("title")) === null || _item_querySelector === void 0 ? void 0 : _item_querySelector.textContent) || "").replace(/<[^>]*>/g, "").trim(),
|
|
@@ -5971,10 +5971,30 @@ function parseRSSXml(xmlText, maxItems) {
|
|
|
5971
5971
|
}).filter(function(i) {
|
|
5972
5972
|
return i.title;
|
|
5973
5973
|
}).slice(0, maxItems);
|
|
5974
|
+
if (items.length === 0 && doc.querySelector("parsererror")) {
|
|
5975
|
+
throw new Error("Invalid RSS XML");
|
|
5976
|
+
}
|
|
5977
|
+
return items;
|
|
5978
|
+
}
|
|
5979
|
+
var RSS_CACHE_TTL_MS = 6e4;
|
|
5980
|
+
var rssCache = /* @__PURE__ */ new Map();
|
|
5981
|
+
function cachedFetchRSSItems(rssUrl, maxItems) {
|
|
5982
|
+
var now = Date.now();
|
|
5983
|
+
var cached = rssCache.get(rssUrl);
|
|
5984
|
+
if (cached && cached.expiresAt > now) return cached.promise;
|
|
5985
|
+
var promise = fetchRSSItems(rssUrl, maxItems).catch(function(err) {
|
|
5986
|
+
rssCache.delete(rssUrl);
|
|
5987
|
+
throw err;
|
|
5988
|
+
});
|
|
5989
|
+
rssCache.set(rssUrl, {
|
|
5990
|
+
promise: promise,
|
|
5991
|
+
expiresAt: now + RSS_CACHE_TTL_MS
|
|
5992
|
+
});
|
|
5993
|
+
return promise;
|
|
5974
5994
|
}
|
|
5975
5995
|
function fetchRSSItems(rssUrl, maxItems) {
|
|
5976
5996
|
return _async_to_generator(function() {
|
|
5977
|
-
var encoded,
|
|
5997
|
+
var encoded, origin, resp, text, unused, resp1, data, unused1, resp2, text1, unused2;
|
|
5978
5998
|
return _ts_generator(this, function(_state) {
|
|
5979
5999
|
switch(_state.label){
|
|
5980
6000
|
case 0:
|
|
@@ -5987,25 +6007,26 @@ function fetchRSSItems(rssUrl, maxItems) {
|
|
|
5987
6007
|
,
|
|
5988
6008
|
6
|
|
5989
6009
|
]);
|
|
6010
|
+
origin = typeof window !== "undefined" ? window.location.origin : "";
|
|
5990
6011
|
return [
|
|
5991
6012
|
4,
|
|
5992
|
-
fetch("
|
|
6013
|
+
fetch("".concat(origin, "/api/rss-proxy?url=").concat(encoded))
|
|
5993
6014
|
];
|
|
5994
6015
|
case 2:
|
|
5995
|
-
|
|
5996
|
-
if (!
|
|
6016
|
+
resp = _state.sent();
|
|
6017
|
+
if (!resp.ok) return [
|
|
5997
6018
|
3,
|
|
5998
6019
|
4
|
|
5999
6020
|
];
|
|
6000
6021
|
return [
|
|
6001
6022
|
4,
|
|
6002
|
-
|
|
6023
|
+
resp.text()
|
|
6003
6024
|
];
|
|
6004
6025
|
case 3:
|
|
6005
|
-
|
|
6006
|
-
if (
|
|
6026
|
+
text = _state.sent();
|
|
6027
|
+
if (text.includes("<item")) return [
|
|
6007
6028
|
2,
|
|
6008
|
-
parseRSSXml(
|
|
6029
|
+
parseRSSXml(text, maxItems)
|
|
6009
6030
|
];
|
|
6010
6031
|
_state.label = 4;
|
|
6011
6032
|
case 4:
|
|
@@ -6028,23 +6049,23 @@ function fetchRSSItems(rssUrl, maxItems) {
|
|
|
6028
6049
|
]);
|
|
6029
6050
|
return [
|
|
6030
6051
|
4,
|
|
6031
|
-
fetch("https://
|
|
6052
|
+
fetch("https://api.allorigins.win/get?url=".concat(encoded))
|
|
6032
6053
|
];
|
|
6033
6054
|
case 7:
|
|
6034
|
-
|
|
6035
|
-
if (!
|
|
6055
|
+
resp1 = _state.sent();
|
|
6056
|
+
if (!resp1.ok) return [
|
|
6036
6057
|
3,
|
|
6037
6058
|
9
|
|
6038
6059
|
];
|
|
6039
6060
|
return [
|
|
6040
6061
|
4,
|
|
6041
|
-
|
|
6062
|
+
resp1.json()
|
|
6042
6063
|
];
|
|
6043
6064
|
case 8:
|
|
6044
|
-
|
|
6045
|
-
if (
|
|
6065
|
+
data = _state.sent();
|
|
6066
|
+
if (data.contents) return [
|
|
6046
6067
|
2,
|
|
6047
|
-
parseRSSXml(
|
|
6068
|
+
parseRSSXml(data.contents, maxItems)
|
|
6048
6069
|
];
|
|
6049
6070
|
_state.label = 9;
|
|
6050
6071
|
case 9:
|
|
@@ -6059,23 +6080,46 @@ function fetchRSSItems(rssUrl, maxItems) {
|
|
|
6059
6080
|
11
|
|
6060
6081
|
];
|
|
6061
6082
|
case 11:
|
|
6083
|
+
_state.trys.push([
|
|
6084
|
+
11,
|
|
6085
|
+
15,
|
|
6086
|
+
,
|
|
6087
|
+
16
|
|
6088
|
+
]);
|
|
6062
6089
|
return [
|
|
6063
6090
|
4,
|
|
6064
|
-
fetch("https://
|
|
6091
|
+
fetch("https://corsproxy.io/?url=".concat(encoded))
|
|
6065
6092
|
];
|
|
6066
6093
|
case 12:
|
|
6067
|
-
|
|
6068
|
-
if (!
|
|
6094
|
+
resp2 = _state.sent();
|
|
6095
|
+
if (!resp2.ok) return [
|
|
6096
|
+
3,
|
|
6097
|
+
14
|
|
6098
|
+
];
|
|
6069
6099
|
return [
|
|
6070
6100
|
4,
|
|
6071
|
-
|
|
6101
|
+
resp2.text()
|
|
6072
6102
|
];
|
|
6073
6103
|
case 13:
|
|
6074
|
-
|
|
6075
|
-
return [
|
|
6104
|
+
text1 = _state.sent();
|
|
6105
|
+
if (text1) return [
|
|
6076
6106
|
2,
|
|
6077
|
-
parseRSSXml(
|
|
6107
|
+
parseRSSXml(text1, maxItems)
|
|
6108
|
+
];
|
|
6109
|
+
_state.label = 14;
|
|
6110
|
+
case 14:
|
|
6111
|
+
return [
|
|
6112
|
+
3,
|
|
6113
|
+
16
|
|
6114
|
+
];
|
|
6115
|
+
case 15:
|
|
6116
|
+
unused2 = _state.sent();
|
|
6117
|
+
return [
|
|
6118
|
+
3,
|
|
6119
|
+
16
|
|
6078
6120
|
];
|
|
6121
|
+
case 16:
|
|
6122
|
+
throw new Error("All RSS proxies failed");
|
|
6079
6123
|
}
|
|
6080
6124
|
});
|
|
6081
6125
|
})();
|
|
@@ -6100,7 +6144,7 @@ function ScrollerOverlay(param) {
|
|
|
6100
6144
|
var cancelled = false;
|
|
6101
6145
|
setRssLoading(true);
|
|
6102
6146
|
setRssError(false);
|
|
6103
|
-
|
|
6147
|
+
cachedFetchRSSItems(rssUrl, maxItems).then(function(items) {
|
|
6104
6148
|
if (!cancelled) {
|
|
6105
6149
|
setRssItems(items);
|
|
6106
6150
|
setRssError(false);
|
|
@@ -6122,7 +6166,8 @@ function ScrollerOverlay(param) {
|
|
|
6122
6166
|
(0, import_react.useEffect)(function() {
|
|
6123
6167
|
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;
|
|
6124
6168
|
var interval = setInterval(function() {
|
|
6125
|
-
|
|
6169
|
+
rssCache.delete(rssUrl);
|
|
6170
|
+
cachedFetchRSSItems(rssUrl, maxItems).then(function(items) {
|
|
6126
6171
|
setRssItems(items);
|
|
6127
6172
|
setRssError(false);
|
|
6128
6173
|
}).catch(function() {});
|