stormcloud-video-player 0.7.27 → 0.7.29
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 +154 -27
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +154 -27
- package/lib/index.js.map +1 -1
- package/lib/ui/OverlayRenderer.cjs +154 -27
- package/lib/ui/OverlayRenderer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +154 -27
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/package.json +1 -1
|
@@ -441,43 +441,151 @@ function TextOverlay(param) {
|
|
|
441
441
|
children: text
|
|
442
442
|
});
|
|
443
443
|
}
|
|
444
|
+
function parseRSSXml(xmlText, maxItems) {
|
|
445
|
+
var parser = new DOMParser();
|
|
446
|
+
var doc = parser.parseFromString(xmlText, "text/xml");
|
|
447
|
+
if (doc.querySelector("parsererror")) throw new Error("Invalid RSS XML");
|
|
448
|
+
return Array.from(doc.querySelectorAll("item")).map(function(item) {
|
|
449
|
+
var _item_querySelector, _item_querySelector1, _item_querySelector2, _item_querySelector3, _item_querySelector4;
|
|
450
|
+
return {
|
|
451
|
+
title: (((_item_querySelector = item.querySelector("title")) === null || _item_querySelector === void 0 ? void 0 : _item_querySelector.textContent) || "").replace(/<[^>]*>/g, "").trim(),
|
|
452
|
+
description: (((_item_querySelector1 = item.querySelector("description")) === null || _item_querySelector1 === void 0 ? void 0 : _item_querySelector1.textContent) || "").replace(/<[^>]*>/g, "").trim(),
|
|
453
|
+
pubDate: ((_item_querySelector2 = item.querySelector("pubDate")) === null || _item_querySelector2 === void 0 ? void 0 : _item_querySelector2.textContent) || "",
|
|
454
|
+
author: ((_item_querySelector3 = item.querySelector("author, dc\\:creator")) === null || _item_querySelector3 === void 0 ? void 0 : _item_querySelector3.textContent) || "",
|
|
455
|
+
category: ((_item_querySelector4 = item.querySelector("category")) === null || _item_querySelector4 === void 0 ? void 0 : _item_querySelector4.textContent) || ""
|
|
456
|
+
};
|
|
457
|
+
}).filter(function(i) {
|
|
458
|
+
return i.title;
|
|
459
|
+
}).slice(0, maxItems);
|
|
460
|
+
}
|
|
444
461
|
function fetchRSSItems(rssUrl, maxItems) {
|
|
445
462
|
return _async_to_generator(function() {
|
|
446
|
-
var resp, data,
|
|
463
|
+
var encoded, origin, resp, text, unused, resp1, data, unused1, resp2, text1, unused2;
|
|
447
464
|
return _ts_generator(this, function(_state) {
|
|
448
465
|
switch(_state.label){
|
|
449
466
|
case 0:
|
|
467
|
+
encoded = encodeURIComponent(rssUrl);
|
|
468
|
+
_state.label = 1;
|
|
469
|
+
case 1:
|
|
470
|
+
_state.trys.push([
|
|
471
|
+
1,
|
|
472
|
+
5,
|
|
473
|
+
,
|
|
474
|
+
6
|
|
475
|
+
]);
|
|
476
|
+
origin = typeof window !== "undefined" ? window.location.origin : "";
|
|
450
477
|
return [
|
|
451
478
|
4,
|
|
452
|
-
fetch("
|
|
479
|
+
fetch("".concat(origin, "/api/rss-proxy?url=").concat(encoded))
|
|
453
480
|
];
|
|
454
|
-
case
|
|
481
|
+
case 2:
|
|
455
482
|
resp = _state.sent();
|
|
483
|
+
if (!resp.ok) return [
|
|
484
|
+
3,
|
|
485
|
+
4
|
|
486
|
+
];
|
|
456
487
|
return [
|
|
457
488
|
4,
|
|
458
|
-
resp.
|
|
489
|
+
resp.text()
|
|
459
490
|
];
|
|
460
|
-
case
|
|
491
|
+
case 3:
|
|
492
|
+
text = _state.sent();
|
|
493
|
+
if (text.includes("<item")) return [
|
|
494
|
+
2,
|
|
495
|
+
parseRSSXml(text, maxItems)
|
|
496
|
+
];
|
|
497
|
+
_state.label = 4;
|
|
498
|
+
case 4:
|
|
499
|
+
return [
|
|
500
|
+
3,
|
|
501
|
+
6
|
|
502
|
+
];
|
|
503
|
+
case 5:
|
|
504
|
+
unused = _state.sent();
|
|
505
|
+
return [
|
|
506
|
+
3,
|
|
507
|
+
6
|
|
508
|
+
];
|
|
509
|
+
case 6:
|
|
510
|
+
_state.trys.push([
|
|
511
|
+
6,
|
|
512
|
+
10,
|
|
513
|
+
,
|
|
514
|
+
11
|
|
515
|
+
]);
|
|
516
|
+
return [
|
|
517
|
+
4,
|
|
518
|
+
fetch("https://api.allorigins.win/get?url=".concat(encoded))
|
|
519
|
+
];
|
|
520
|
+
case 7:
|
|
521
|
+
resp1 = _state.sent();
|
|
522
|
+
if (!resp1.ok) return [
|
|
523
|
+
3,
|
|
524
|
+
9
|
|
525
|
+
];
|
|
526
|
+
return [
|
|
527
|
+
4,
|
|
528
|
+
resp1.json()
|
|
529
|
+
];
|
|
530
|
+
case 8:
|
|
461
531
|
data = _state.sent();
|
|
462
|
-
if (
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
532
|
+
if (data.contents) return [
|
|
533
|
+
2,
|
|
534
|
+
parseRSSXml(data.contents, maxItems)
|
|
535
|
+
];
|
|
536
|
+
_state.label = 9;
|
|
537
|
+
case 9:
|
|
538
|
+
return [
|
|
539
|
+
3,
|
|
540
|
+
11
|
|
541
|
+
];
|
|
542
|
+
case 10:
|
|
543
|
+
unused1 = _state.sent();
|
|
544
|
+
return [
|
|
545
|
+
3,
|
|
546
|
+
11
|
|
547
|
+
];
|
|
548
|
+
case 11:
|
|
549
|
+
_state.trys.push([
|
|
550
|
+
11,
|
|
551
|
+
15,
|
|
552
|
+
,
|
|
553
|
+
16
|
|
554
|
+
]);
|
|
555
|
+
return [
|
|
556
|
+
4,
|
|
557
|
+
fetch("https://corsproxy.io/?url=".concat(encoded))
|
|
558
|
+
];
|
|
559
|
+
case 12:
|
|
560
|
+
resp2 = _state.sent();
|
|
561
|
+
if (!resp2.ok) return [
|
|
562
|
+
3,
|
|
563
|
+
14
|
|
564
|
+
];
|
|
466
565
|
return [
|
|
566
|
+
4,
|
|
567
|
+
resp2.text()
|
|
568
|
+
];
|
|
569
|
+
case 13:
|
|
570
|
+
text1 = _state.sent();
|
|
571
|
+
if (text1) return [
|
|
467
572
|
2,
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
category: ((_item_querySelector4 = item.querySelector("category")) === null || _item_querySelector4 === void 0 ? void 0 : _item_querySelector4.textContent) || ""
|
|
476
|
-
};
|
|
477
|
-
}).filter(function(i) {
|
|
478
|
-
return i.title;
|
|
479
|
-
}).slice(0, maxItems)
|
|
573
|
+
parseRSSXml(text1, maxItems)
|
|
574
|
+
];
|
|
575
|
+
_state.label = 14;
|
|
576
|
+
case 14:
|
|
577
|
+
return [
|
|
578
|
+
3,
|
|
579
|
+
16
|
|
480
580
|
];
|
|
581
|
+
case 15:
|
|
582
|
+
unused2 = _state.sent();
|
|
583
|
+
return [
|
|
584
|
+
3,
|
|
585
|
+
16
|
|
586
|
+
];
|
|
587
|
+
case 16:
|
|
588
|
+
throw new Error("All RSS proxies failed");
|
|
481
589
|
}
|
|
482
590
|
});
|
|
483
591
|
})();
|
|
@@ -488,18 +596,28 @@ function ScrollerOverlay(param) {
|
|
|
488
596
|
var cfg = overlay.scroller_config;
|
|
489
597
|
var uid = (0, import_react.useId)().replace(/:/g, "");
|
|
490
598
|
var _ref13 = _sliced_to_array((0, import_react.useState)([]), 2), rssItems = _ref13[0], setRssItems = _ref13[1];
|
|
491
|
-
var _ref14 = _sliced_to_array((0, import_react.useState)(
|
|
599
|
+
var _ref14 = _sliced_to_array((0, import_react.useState)(true), 2), rssLoading = _ref14[0], setRssLoading = _ref14[1];
|
|
600
|
+
var _ref15 = _sliced_to_array((0, import_react.useState)(false), 2), rssError = _ref15[0], setRssError = _ref15[1];
|
|
492
601
|
var rssUrl = (cfg === null || cfg === void 0 ? void 0 : cfg.rss_url) || "";
|
|
493
602
|
var maxItems = (_ref = cfg === null || cfg === void 0 ? void 0 : cfg.max_items) !== null && _ref !== void 0 ? _ref : 10;
|
|
494
603
|
var autoRefresh = (cfg === null || cfg === void 0 ? void 0 : cfg.auto_refresh) !== false;
|
|
495
604
|
var updateInterval = (_ref1 = cfg === null || cfg === void 0 ? void 0 : cfg.update_interval) !== null && _ref1 !== void 0 ? _ref1 : 5;
|
|
496
605
|
(0, import_react.useEffect)(function() {
|
|
497
|
-
if (!rssUrl || (cfg === null || cfg === void 0 ? void 0 : cfg.use_custom_text) && (cfg === null || cfg === void 0 ? void 0 : cfg.custom_text))
|
|
606
|
+
if (!rssUrl || (cfg === null || cfg === void 0 ? void 0 : cfg.use_custom_text) && (cfg === null || cfg === void 0 ? void 0 : cfg.custom_text)) {
|
|
607
|
+
setRssLoading(false);
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
498
610
|
var cancelled = false;
|
|
499
611
|
setRssLoading(true);
|
|
612
|
+
setRssError(false);
|
|
500
613
|
fetchRSSItems(rssUrl, maxItems).then(function(items) {
|
|
501
|
-
if (!cancelled)
|
|
502
|
-
|
|
614
|
+
if (!cancelled) {
|
|
615
|
+
setRssItems(items);
|
|
616
|
+
setRssError(false);
|
|
617
|
+
}
|
|
618
|
+
}).catch(function() {
|
|
619
|
+
if (!cancelled) setRssError(true);
|
|
620
|
+
}).finally(function() {
|
|
503
621
|
if (!cancelled) setRssLoading(false);
|
|
504
622
|
});
|
|
505
623
|
return function() {
|
|
@@ -514,7 +632,10 @@ function ScrollerOverlay(param) {
|
|
|
514
632
|
(0, import_react.useEffect)(function() {
|
|
515
633
|
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;
|
|
516
634
|
var interval = setInterval(function() {
|
|
517
|
-
fetchRSSItems(rssUrl, maxItems).then(
|
|
635
|
+
fetchRSSItems(rssUrl, maxItems).then(function(items) {
|
|
636
|
+
setRssItems(items);
|
|
637
|
+
setRssError(false);
|
|
638
|
+
}).catch(function() {});
|
|
518
639
|
}, updateInterval * 60 * 1e3);
|
|
519
640
|
return function() {
|
|
520
641
|
return clearInterval(interval);
|
|
@@ -551,13 +672,19 @@ function ScrollerOverlay(param) {
|
|
|
551
672
|
segments = [
|
|
552
673
|
"Loading feed\u2026"
|
|
553
674
|
];
|
|
675
|
+
} else if (rssError) {
|
|
676
|
+
segments = overlay.content ? [
|
|
677
|
+
overlay.content
|
|
678
|
+
] : [
|
|
679
|
+
"RSS feed unavailable"
|
|
680
|
+
];
|
|
554
681
|
} else if (overlay.content) {
|
|
555
682
|
segments = [
|
|
556
683
|
overlay.content
|
|
557
684
|
];
|
|
558
685
|
} else {
|
|
559
686
|
segments = rssUrl ? [
|
|
560
|
-
"
|
|
687
|
+
"Loading feed\u2026"
|
|
561
688
|
] : [
|
|
562
689
|
"RSS Ticker"
|
|
563
690
|
];
|