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
|
@@ -442,10 +442,10 @@ function TextOverlay(param) {
|
|
|
442
442
|
});
|
|
443
443
|
}
|
|
444
444
|
function parseRSSXml(xmlText, maxItems) {
|
|
445
|
+
var stripped = xmlText.replace(/^<\?xml[^?]*\?>\s*/, "");
|
|
445
446
|
var parser = new DOMParser();
|
|
446
|
-
var doc = parser.parseFromString(
|
|
447
|
-
|
|
448
|
-
return Array.from(doc.querySelectorAll("item")).map(function(item) {
|
|
447
|
+
var doc = parser.parseFromString(stripped, "text/xml");
|
|
448
|
+
var items = Array.from(doc.querySelectorAll("item")).map(function(item) {
|
|
449
449
|
var _item_querySelector, _item_querySelector1, _item_querySelector2, _item_querySelector3, _item_querySelector4;
|
|
450
450
|
return {
|
|
451
451
|
title: (((_item_querySelector = item.querySelector("title")) === null || _item_querySelector === void 0 ? void 0 : _item_querySelector.textContent) || "").replace(/<[^>]*>/g, "").trim(),
|
|
@@ -457,10 +457,30 @@ function parseRSSXml(xmlText, maxItems) {
|
|
|
457
457
|
}).filter(function(i) {
|
|
458
458
|
return i.title;
|
|
459
459
|
}).slice(0, maxItems);
|
|
460
|
+
if (items.length === 0 && doc.querySelector("parsererror")) {
|
|
461
|
+
throw new Error("Invalid RSS XML");
|
|
462
|
+
}
|
|
463
|
+
return items;
|
|
464
|
+
}
|
|
465
|
+
var RSS_CACHE_TTL_MS = 6e4;
|
|
466
|
+
var rssCache = /* @__PURE__ */ new Map();
|
|
467
|
+
function cachedFetchRSSItems(rssUrl, maxItems) {
|
|
468
|
+
var now = Date.now();
|
|
469
|
+
var cached = rssCache.get(rssUrl);
|
|
470
|
+
if (cached && cached.expiresAt > now) return cached.promise;
|
|
471
|
+
var promise = fetchRSSItems(rssUrl, maxItems).catch(function(err) {
|
|
472
|
+
rssCache.delete(rssUrl);
|
|
473
|
+
throw err;
|
|
474
|
+
});
|
|
475
|
+
rssCache.set(rssUrl, {
|
|
476
|
+
promise: promise,
|
|
477
|
+
expiresAt: now + RSS_CACHE_TTL_MS
|
|
478
|
+
});
|
|
479
|
+
return promise;
|
|
460
480
|
}
|
|
461
481
|
function fetchRSSItems(rssUrl, maxItems) {
|
|
462
482
|
return _async_to_generator(function() {
|
|
463
|
-
var encoded,
|
|
483
|
+
var encoded, origin, resp, text, unused, resp1, data, unused1, resp2, text1, unused2;
|
|
464
484
|
return _ts_generator(this, function(_state) {
|
|
465
485
|
switch(_state.label){
|
|
466
486
|
case 0:
|
|
@@ -473,25 +493,26 @@ function fetchRSSItems(rssUrl, maxItems) {
|
|
|
473
493
|
,
|
|
474
494
|
6
|
|
475
495
|
]);
|
|
496
|
+
origin = typeof window !== "undefined" ? window.location.origin : "";
|
|
476
497
|
return [
|
|
477
498
|
4,
|
|
478
|
-
fetch("
|
|
499
|
+
fetch("".concat(origin, "/api/rss-proxy?url=").concat(encoded))
|
|
479
500
|
];
|
|
480
501
|
case 2:
|
|
481
|
-
|
|
482
|
-
if (!
|
|
502
|
+
resp = _state.sent();
|
|
503
|
+
if (!resp.ok) return [
|
|
483
504
|
3,
|
|
484
505
|
4
|
|
485
506
|
];
|
|
486
507
|
return [
|
|
487
508
|
4,
|
|
488
|
-
|
|
509
|
+
resp.text()
|
|
489
510
|
];
|
|
490
511
|
case 3:
|
|
491
|
-
|
|
492
|
-
if (
|
|
512
|
+
text = _state.sent();
|
|
513
|
+
if (text.includes("<item")) return [
|
|
493
514
|
2,
|
|
494
|
-
parseRSSXml(
|
|
515
|
+
parseRSSXml(text, maxItems)
|
|
495
516
|
];
|
|
496
517
|
_state.label = 4;
|
|
497
518
|
case 4:
|
|
@@ -514,23 +535,23 @@ function fetchRSSItems(rssUrl, maxItems) {
|
|
|
514
535
|
]);
|
|
515
536
|
return [
|
|
516
537
|
4,
|
|
517
|
-
fetch("https://
|
|
538
|
+
fetch("https://api.allorigins.win/get?url=".concat(encoded))
|
|
518
539
|
];
|
|
519
540
|
case 7:
|
|
520
|
-
|
|
521
|
-
if (!
|
|
541
|
+
resp1 = _state.sent();
|
|
542
|
+
if (!resp1.ok) return [
|
|
522
543
|
3,
|
|
523
544
|
9
|
|
524
545
|
];
|
|
525
546
|
return [
|
|
526
547
|
4,
|
|
527
|
-
|
|
548
|
+
resp1.json()
|
|
528
549
|
];
|
|
529
550
|
case 8:
|
|
530
|
-
|
|
531
|
-
if (
|
|
551
|
+
data = _state.sent();
|
|
552
|
+
if (data.contents) return [
|
|
532
553
|
2,
|
|
533
|
-
parseRSSXml(
|
|
554
|
+
parseRSSXml(data.contents, maxItems)
|
|
534
555
|
];
|
|
535
556
|
_state.label = 9;
|
|
536
557
|
case 9:
|
|
@@ -545,23 +566,46 @@ function fetchRSSItems(rssUrl, maxItems) {
|
|
|
545
566
|
11
|
|
546
567
|
];
|
|
547
568
|
case 11:
|
|
569
|
+
_state.trys.push([
|
|
570
|
+
11,
|
|
571
|
+
15,
|
|
572
|
+
,
|
|
573
|
+
16
|
|
574
|
+
]);
|
|
548
575
|
return [
|
|
549
576
|
4,
|
|
550
|
-
fetch("https://
|
|
577
|
+
fetch("https://corsproxy.io/?url=".concat(encoded))
|
|
551
578
|
];
|
|
552
579
|
case 12:
|
|
553
|
-
|
|
554
|
-
if (!
|
|
580
|
+
resp2 = _state.sent();
|
|
581
|
+
if (!resp2.ok) return [
|
|
582
|
+
3,
|
|
583
|
+
14
|
|
584
|
+
];
|
|
555
585
|
return [
|
|
556
586
|
4,
|
|
557
|
-
|
|
587
|
+
resp2.text()
|
|
558
588
|
];
|
|
559
589
|
case 13:
|
|
560
|
-
|
|
561
|
-
return [
|
|
590
|
+
text1 = _state.sent();
|
|
591
|
+
if (text1) return [
|
|
562
592
|
2,
|
|
563
|
-
parseRSSXml(
|
|
593
|
+
parseRSSXml(text1, maxItems)
|
|
594
|
+
];
|
|
595
|
+
_state.label = 14;
|
|
596
|
+
case 14:
|
|
597
|
+
return [
|
|
598
|
+
3,
|
|
599
|
+
16
|
|
600
|
+
];
|
|
601
|
+
case 15:
|
|
602
|
+
unused2 = _state.sent();
|
|
603
|
+
return [
|
|
604
|
+
3,
|
|
605
|
+
16
|
|
564
606
|
];
|
|
607
|
+
case 16:
|
|
608
|
+
throw new Error("All RSS proxies failed");
|
|
565
609
|
}
|
|
566
610
|
});
|
|
567
611
|
})();
|
|
@@ -586,7 +630,7 @@ function ScrollerOverlay(param) {
|
|
|
586
630
|
var cancelled = false;
|
|
587
631
|
setRssLoading(true);
|
|
588
632
|
setRssError(false);
|
|
589
|
-
|
|
633
|
+
cachedFetchRSSItems(rssUrl, maxItems).then(function(items) {
|
|
590
634
|
if (!cancelled) {
|
|
591
635
|
setRssItems(items);
|
|
592
636
|
setRssError(false);
|
|
@@ -608,7 +652,8 @@ function ScrollerOverlay(param) {
|
|
|
608
652
|
(0, import_react.useEffect)(function() {
|
|
609
653
|
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;
|
|
610
654
|
var interval = setInterval(function() {
|
|
611
|
-
|
|
655
|
+
rssCache.delete(rssUrl);
|
|
656
|
+
cachedFetchRSSItems(rssUrl, maxItems).then(function(items) {
|
|
612
657
|
setRssItems(items);
|
|
613
658
|
setRssError(false);
|
|
614
659
|
}).catch(function() {});
|