stormcloud-video-player 0.7.29 → 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.
@@ -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(xmlText, "text/xml");
5783
- if (doc.querySelector("parsererror")) throw new Error("Invalid RSS XML");
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,6 +5793,26 @@ 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() {
@@ -5946,7 +5966,7 @@ function ScrollerOverlay(param) {
5946
5966
  var cancelled = false;
5947
5967
  setRssLoading(true);
5948
5968
  setRssError(false);
5949
- fetchRSSItems(rssUrl, maxItems).then(function(items) {
5969
+ cachedFetchRSSItems(rssUrl, maxItems).then(function(items) {
5950
5970
  if (!cancelled) {
5951
5971
  setRssItems(items);
5952
5972
  setRssError(false);
@@ -5968,7 +5988,8 @@ function ScrollerOverlay(param) {
5968
5988
  (0, import_react.useEffect)(function() {
5969
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;
5970
5990
  var interval = setInterval(function() {
5971
- fetchRSSItems(rssUrl, maxItems).then(function(items) {
5991
+ rssCache.delete(rssUrl);
5992
+ cachedFetchRSSItems(rssUrl, maxItems).then(function(items) {
5972
5993
  setRssItems(items);
5973
5994
  setRssError(false);
5974
5995
  }).catch(function() {});