stormcloud-video-player 0.8.29 → 0.8.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.
Files changed (40) hide show
  1. package/dist/stormcloud-vp.min.js +2 -2
  2. package/lib/index.cjs +78 -1045
  3. package/lib/index.cjs.map +1 -1
  4. package/lib/index.d.cts +0 -3
  5. package/lib/index.d.ts +0 -3
  6. package/lib/index.js +78 -1046
  7. package/lib/index.js.map +1 -1
  8. package/lib/player/AdBreakOrchestrator.cjs +57 -490
  9. package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
  10. package/lib/player/AdBreakOrchestrator.d.cts +8 -7
  11. package/lib/player/AdConfigManager.cjs +12 -53
  12. package/lib/player/AdConfigManager.cjs.map +1 -1
  13. package/lib/player/AdConfigManager.d.cts +4 -5
  14. package/lib/player/AdTimingService.d.cts +1 -1
  15. package/lib/player/HlsEngine.d.cts +1 -1
  16. package/lib/player/PlayerControls.d.cts +1 -1
  17. package/lib/player/Scte35CueManager.d.cts +1 -1
  18. package/lib/player/Scte35Parser.d.cts +1 -1
  19. package/lib/player/StormcloudVideoPlayer.cjs +78 -1045
  20. package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
  21. package/lib/player/StormcloudVideoPlayer.d.cts +1 -3
  22. package/lib/player/playerTypes.d.cts +1 -1
  23. package/lib/players/HlsPlayer.cjs +78 -1045
  24. package/lib/players/HlsPlayer.cjs.map +1 -1
  25. package/lib/players/HlsPlayer.d.cts +1 -1
  26. package/lib/players/index.cjs +78 -1045
  27. package/lib/players/index.cjs.map +1 -1
  28. package/lib/sdk/hlsAdPlayer.d.cts +1 -1
  29. package/lib/{types-Xgz2_W1C.d.cts → types-CSHvCbhZ.d.cts} +0 -1
  30. package/lib/ui/StormcloudVideoPlayer.cjs +78 -1045
  31. package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
  32. package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
  33. package/lib/utils/tracking.d.cts +1 -1
  34. package/lib/utils/vastMacros.cjs +10 -15
  35. package/lib/utils/vastMacros.cjs.map +1 -1
  36. package/lib/utils/vastMacros.d.cts +0 -1
  37. package/package.json +1 -1
  38. package/lib/player/AdPreloadPool.cjs +0 -673
  39. package/lib/player/AdPreloadPool.cjs.map +0 -1
  40. package/lib/player/AdPreloadPool.d.cts +0 -37
@@ -1256,7 +1256,7 @@ function getAdAudioVolume(adPlayer) {
1256
1256
  }
1257
1257
  // src/player/AdBreakOrchestrator.ts
1258
1258
  var AdBreakOrchestrator = /*#__PURE__*/ function() {
1259
- function AdBreakOrchestrator(host, timing, preloadPool, adConfig, cueManager, placeholder) {
1259
+ function AdBreakOrchestrator(host, timing, adConfig, cueManager, placeholder) {
1260
1260
  _class_call_check(this, AdBreakOrchestrator);
1261
1261
  this.inAdBreak = false;
1262
1262
  this.showAds = false;
@@ -1270,7 +1270,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
1270
1270
  this.pendingAdBreak = null;
1271
1271
  this.host = host;
1272
1272
  this.timing = timing;
1273
- this.preloadPool = preloadPool;
1274
1273
  this.adConfig = adConfig;
1275
1274
  this.cueManager = cueManager;
1276
1275
  this.placeholder = placeholder;
@@ -1289,23 +1288,19 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
1289
1288
  }
1290
1289
  },
1291
1290
  {
1292
- key: "optimizedPodsEnabled",
1293
- get: // ───────────────────────────────────────────────────────────────
1291
+ // ───────────────────────────────────────────────────────────────
1294
1292
  // IMA event listeners
1295
1293
  // ───────────────────────────────────────────────────────────────
1296
- function get() {
1297
- return this.host.config.optimizedPods !== false;
1298
- }
1299
- },
1300
- {
1301
- key: "nextAdRequestUrl",
1294
+ /**
1295
+ * Produces the next pod ad-request URL for the current break. Every request
1296
+ * (initial and continuous-fetch top-up) carries pod macros (pmad/pmnd/pmxd,
1297
+ * no ppos); pmxd tracks the remaining break time so top-up pods only ask for
1298
+ * what still fits.
1299
+ */ key: "nextAdRequestUrl",
1302
1300
  value: function nextAdRequestUrl(baseVastUrl) {
1303
- if (this.optimizedPodsEnabled) {
1304
- var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
1305
- var breakDurationMs = remaining > 0 ? remaining : void 0;
1306
- return this.host.generatePodVastUrl(baseVastUrl, breakDurationMs);
1307
- }
1308
- return this.host.generateVastUrls(baseVastUrl, 1)[0];
1301
+ var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
1302
+ var breakDurationMs = remaining > 0 ? remaining : void 0;
1303
+ return this.host.generatePodVastUrl(baseVastUrl, breakDurationMs);
1309
1304
  }
1310
1305
  },
1311
1306
  {
@@ -1477,7 +1472,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
1477
1472
  // ───────────────────────────────────────────────────────────────
1478
1473
  function handleAdStart(_marker) {
1479
1474
  return _async_to_generator(function() {
1480
- var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, podPlayed, firstAdUrl, usePreloadedAd, preloadedController, preloaded, adPlayer, preservedMuted, preservedVolume, adVolume, adPlayer1, adVolume1, error, fallbackPreloaded, ap, adVolume2, fallbackError;
1475
+ var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, podPlayed;
1481
1476
  return _ts_generator(this, function(_state) {
1482
1477
  switch(_state.label){
1483
1478
  case 0:
@@ -1524,293 +1519,29 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
1524
1519
  if (this.timing.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
1525
1520
  this.timing.expectedAdBreakDurationMs = adBreakDurationMs;
1526
1521
  }
1527
- if (!this.optimizedPodsEnabled) return [
1528
- 3,
1529
- 2
1530
- ];
1531
1522
  return [
1532
1523
  4,
1533
1524
  this.startOptimizedPod(baseVastUrl, adBreakDurationMs, currentMuted, currentVolume)
1534
1525
  ];
1535
1526
  case 1:
1536
1527
  podPlayed = _state.sent();
1537
- if (podPlayed) {
1538
- return [
1539
- 2
1540
- ];
1541
- }
1542
- if (this.debug) {
1543
- console.log("[POD] Optimized pod unavailable, falling back to sequential single-ad path");
1544
- }
1545
- _state.label = 2;
1546
- case 2:
1547
- usePreloadedAd = false;
1548
- preloaded = this.preloadPool.getPreloadedAd();
1549
- if (preloaded) {
1550
- firstAdUrl = preloaded.vastUrl;
1551
- preloadedController = preloaded.adController;
1552
- usePreloadedAd = true;
1553
- sendAdLoadedTracking(this.host.config.licenseKey, {
1554
- source: "hls",
1555
- vastUrl: firstAdUrl,
1556
- timestamp: /* @__PURE__ */ new Date().toISOString()
1557
- }, this.analyticsContext).catch(function() {});
1558
- if (this.debug) {
1559
- console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool (preloaded in advance, ready immediately!)");
1560
- }
1561
- } else if (this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0) {
1562
- this.adRequestQueue = _to_consumable_array(this.pendingAdBreak.vastUrls);
1563
- firstAdUrl = this.adRequestQueue.shift();
1564
- if (this.debug) {
1565
- console.log("[CONTINUOUS-FETCH] Pool empty, using prefetched URLs (".concat(this.adRequestQueue.length + 1, " available)"));
1566
- }
1567
- this.clearPendingAdBreak();
1568
- } else {
1569
- if (this.debug) {
1570
- console.log("[CONTINUOUS-FETCH] Generating new ad URLs...");
1571
- }
1572
- firstAdUrl = this.nextAdRequestUrl(baseVastUrl);
1573
- this.adRequestQueue = [];
1574
- }
1575
- if (!firstAdUrl) {
1576
- if (this.debug) {
1577
- console.warn("[CONTINUOUS-FETCH] Failed to get first ad URL");
1578
- }
1579
- this.handleAdPodComplete();
1580
- return [
1581
- 2
1582
- ];
1583
- }
1584
- if (this.debug) {
1585
- console.log("[CONTINUOUS-FETCH] First VAST URL:", firstAdUrl);
1586
- }
1587
- _state.label = 3;
1588
- case 3:
1589
- _state.trys.push([
1528
+ if (!!podPlayed) return [
1590
1529
  3,
1591
- 14,
1592
- ,
1593
- 22
1594
- ]);
1595
- if (!(usePreloadedAd && preloadedController)) return [
1596
- 3,
1597
- 7
1598
- ];
1599
- if (!!this.timing.ensureLoadedAdFitsBudget(preloadedController)) return [
1600
- 3,
1601
- 5
1602
- ];
1603
- this.timing.rejectLoadedAdForDuration(preloadedController);
1604
- this.startContinuousFetching(baseVastUrl);
1605
- return [
1606
- 4,
1607
- this.tryNextAvailableAdWithRateLimit()
1608
- ];
1609
- case 4:
1610
- _state.sent();
1611
- return [
1612
- 2
1613
- ];
1614
- case 5:
1615
- adPlayer = this.host.getAdPlayer();
1616
- preservedMuted = adPlayer.getOriginalMutedState();
1617
- preservedVolume = adPlayer.getOriginalVolume();
1618
- adPlayer.destroy();
1619
- this.host.video.muted = true;
1620
- this.host.setAdPlayer(preloadedController);
1621
- preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
1622
- this.attachImaEventListeners();
1623
- if (this.debug) {
1624
- console.log("[CONTINUOUS-FETCH] Using preloaded ad, resuming and starting playback immediately (no request delay!)");
1625
- }
1626
- preloadedController.resume();
1627
- this.timing.consecutiveFailures = 0;
1628
- this.startContinuousFetching(baseVastUrl);
1629
- if (!this.optimizedPodsEnabled) {
1630
- if (!this.preloadPool.active) {
1631
- this.preloadPool.active = true;
1632
- }
1633
- if (!this.preloadPool.isLoopRunning) {
1634
- this.preloadPool.preloadPoolLoop(baseVastUrl);
1635
- }
1636
- }
1637
- return [
1638
- 4,
1639
- preloadedController.play()
1640
- ];
1641
- case 6:
1642
- _state.sent();
1643
- this.timing.markAdStarted();
1644
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
1645
- this.timing.scheduleAdStopAtBreakBoundary();
1646
- }
1647
- adVolume = currentMuted ? 0 : currentVolume;
1648
- preloadedController.setAdVolume(adVolume);
1649
- return [
1650
- 3,
1651
- 13
1652
- ];
1653
- case 7:
1654
- adPlayer1 = this.host.getAdPlayer();
1655
- return [
1656
- 4,
1657
- this.timing.enforceGlobalRateLimit()
1658
- ];
1659
- case 8:
1660
- _state.sent();
1661
- this.timing.lastAdRequestTime = Date.now();
1662
- return [
1663
- 4,
1664
- adPlayer1.requestAds(firstAdUrl)
1665
- ];
1666
- case 9:
1667
- _state.sent();
1668
- sendAdLoadedTracking(this.host.config.licenseKey, {
1669
- source: "hls",
1670
- vastUrl: firstAdUrl,
1671
- timestamp: /* @__PURE__ */ new Date().toISOString()
1672
- }, this.analyticsContext).catch(function() {});
1673
- if (this.debug) {
1674
- console.log("[CONTINUOUS-FETCH] First ad request successful, starting playback");
1675
- }
1676
- if (!!this.timing.ensureLoadedAdFitsBudget(adPlayer1)) return [
1677
- 3,
1678
- 11
1679
- ];
1680
- this.timing.rejectLoadedAdForDuration(adPlayer1);
1681
- this.recreateAdController();
1682
- this.startContinuousFetching(baseVastUrl);
1683
- return [
1684
- 4,
1685
- this.tryNextAvailableAdWithRateLimit()
1686
- ];
1687
- case 10:
1688
- _state.sent();
1689
- return [
1690
- 2
1691
- ];
1692
- case 11:
1693
- this.timing.consecutiveFailures = 0;
1694
- this.startContinuousFetching(baseVastUrl);
1695
- if (!this.optimizedPodsEnabled && !this.preloadPool.active) {
1696
- this.preloadPool.startPreloadPool(baseVastUrl, []);
1697
- }
1698
- return [
1699
- 4,
1700
- adPlayer1.play()
1701
- ];
1702
- case 12:
1703
- _state.sent();
1704
- this.timing.markAdStarted();
1705
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
1706
- this.timing.scheduleAdStopAtBreakBoundary();
1707
- }
1708
- adVolume1 = currentMuted ? 0 : currentVolume;
1709
- adPlayer1.setAdVolume(adVolume1);
1710
- _state.label = 13;
1711
- case 13:
1712
- return [
1713
- 3,
1714
- 22
1715
- ];
1716
- case 14:
1717
- error = _state.sent();
1718
- if (this.debug) {
1719
- console.warn("[CONTINUOUS-FETCH] First ad request failed:", error);
1720
- }
1721
- if (!!usePreloadedAd) return [
1722
- 3,
1723
- 20
1724
- ];
1725
- fallbackPreloaded = this.preloadPool.getPreloadedAd();
1726
- if (!fallbackPreloaded) return [
1727
- 3,
1728
- 20
1729
- ];
1730
- if (this.debug) {
1731
- console.log("[CONTINUOUS-FETCH] First ad failed, using preloaded fallback");
1732
- }
1733
- _state.label = 15;
1734
- case 15:
1735
- _state.trys.push([
1736
- 15,
1737
- 19,
1738
- ,
1739
- 20
1740
- ]);
1741
- if (!!this.timing.ensureLoadedAdFitsBudget(fallbackPreloaded.adController)) return [
1742
- 3,
1743
- 17
1744
- ];
1745
- this.timing.rejectLoadedAdForDuration(fallbackPreloaded.adController);
1746
- this.startContinuousFetching(baseVastUrl);
1747
- return [
1748
- 4,
1749
- this.tryNextAvailableAdWithRateLimit()
1750
- ];
1751
- case 16:
1752
- _state.sent();
1753
- return [
1754
- 2
1755
- ];
1756
- case 17:
1757
- this.swapToPreloadedAdPlayer(fallbackPreloaded.adController);
1758
- this.timing.consecutiveFailures = 0;
1759
- this.startContinuousFetching(baseVastUrl);
1760
- if (!this.optimizedPodsEnabled && !this.preloadPool.active) {
1761
- this.preloadPool.active = true;
1762
- this.preloadPool.preloadPoolLoop(baseVastUrl);
1763
- }
1764
- ap = this.host.getAdPlayer();
1765
- return [
1766
- 4,
1767
- ap.play()
1768
- ];
1769
- case 18:
1770
- _state.sent();
1771
- this.timing.markAdStarted();
1772
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
1773
- this.timing.scheduleAdStopAtBreakBoundary();
1774
- }
1775
- adVolume2 = currentMuted ? 0 : currentVolume;
1776
- ap.setAdVolume(adVolume2);
1777
- return [
1778
- 2
1530
+ 3
1779
1531
  ];
1780
- case 19:
1781
- fallbackError = _state.sent();
1782
1532
  if (this.debug) {
1783
- console.warn("[CONTINUOUS-FETCH] Preloaded fallback also failed:", fallbackError);
1533
+ console.log("[POD] Initial pod request did not fill; attempting top-up pod request");
1784
1534
  }
1785
- return [
1786
- 3,
1787
- 20
1788
- ];
1789
- case 20:
1790
- if (this.timing.isTemporaryAdError(error)) {
1791
- this.timing.temporaryFailureUrls.set(firstAdUrl, Date.now());
1792
- if (this.debug) {
1793
- console.log("[CONTINUOUS-FETCH] First ad had temporary error (no-fill) - will try alternatives");
1794
- }
1795
- } else {
1796
- this.timing.failedVastUrls.add(firstAdUrl);
1797
- if (this.debug) {
1798
- console.log("[CONTINUOUS-FETCH] First ad had permanent error - URL blacklisted");
1799
- }
1800
- }
1801
- this.timing.consecutiveFailures++;
1535
+ this.continuousFetchingActive = true;
1802
1536
  this.startContinuousFetching(baseVastUrl);
1803
1537
  return [
1804
1538
  4,
1805
1539
  this.tryNextAvailableAdWithRateLimit()
1806
1540
  ];
1807
- case 21:
1541
+ case 2:
1808
1542
  _state.sent();
1809
- return [
1810
- 3,
1811
- 22
1812
- ];
1813
- case 22:
1543
+ _state.label = 3;
1544
+ case 3:
1814
1545
  return [
1815
1546
  2
1816
1547
  ];
@@ -1884,7 +1615,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
1884
1615
  ];
1885
1616
  }
1886
1617
  if (this.debug) {
1887
- console.log(podCount === 1 ? "[POD] Response contained a single ad; playing it and enabling sequential top-up" : "[POD] Optimized pod returned ".concat(podCount, " ads; playing pod in one controller"));
1618
+ console.log(podCount === 1 ? "[POD] Response contained a single ad; playing it and enabling pod top-up" : "[POD] Optimized pod returned ".concat(podCount, " ads; playing pod in one controller"));
1888
1619
  }
1889
1620
  sendAdLoadedTracking(this.host.config.licenseKey, {
1890
1621
  source: "hls",
@@ -1904,10 +1635,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
1904
1635
  }
1905
1636
  adPlayer.setAdVolume(currentMuted ? 0 : currentVolume);
1906
1637
  this.timing.consecutiveFailures = 0;
1907
- if (podCount === 1) {
1908
- this.continuousFetchingActive = true;
1909
- this.startContinuousFetching(baseVastUrl);
1910
- }
1638
+ this.continuousFetchingActive = true;
1639
+ this.startContinuousFetching(baseVastUrl);
1911
1640
  return [
1912
1641
  2,
1913
1642
  true
@@ -1940,20 +1669,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
1940
1669
  }).call(this);
1941
1670
  }
1942
1671
  },
1943
- {
1944
- key: "swapToPreloadedAdPlayer",
1945
- value: function swapToPreloadedAdPlayer(preloadedController) {
1946
- var adPlayer = this.host.getAdPlayer();
1947
- var preservedMuted = adPlayer.getOriginalMutedState();
1948
- var preservedVolume = adPlayer.getOriginalVolume();
1949
- adPlayer.destroy();
1950
- this.host.video.muted = true;
1951
- this.host.setAdPlayer(preloadedController);
1952
- this.attachImaEventListeners();
1953
- preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
1954
- preloadedController.resume();
1955
- }
1956
- },
1957
1672
  {
1958
1673
  // ───────────────────────────────────────────────────────────────
1959
1674
  // Continuous fetching
@@ -2204,7 +1919,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2204
1919
  value: function tryNextAvailableAd() {
2205
1920
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
2206
1921
  return _async_to_generator(function() {
2207
- var remaining, preloaded, ap, error, nextAdUrl, error1, errorMessage, maxRetries;
1922
+ var remaining, nextAdUrl, error, errorMessage, maxRetries;
2208
1923
  return _ts_generator(this, function(_state) {
2209
1924
  switch(_state.label){
2210
1925
  case 0:
@@ -2242,132 +1957,71 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2242
1957
  ];
2243
1958
  }
2244
1959
  this.timing.cleanupTemporaryFailures();
2245
- preloaded = this.preloadPool.getPreloadedAd();
2246
- if (!preloaded) return [
2247
- 3,
2248
- 6
2249
- ];
2250
- if (this.debug) {
2251
- console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool");
2252
- }
2253
- sendAdLoadedTracking(this.host.config.licenseKey, {
2254
- source: "hls",
2255
- vastUrl: preloaded.vastUrl,
2256
- timestamp: /* @__PURE__ */ new Date().toISOString()
2257
- }, this.analyticsContext).catch(function() {});
2258
1960
  _state.label = 1;
2259
1961
  case 1:
2260
- _state.trys.push([
2261
- 1,
2262
- 5,
2263
- ,
2264
- 6
2265
- ]);
2266
- if (!!this.timing.ensureLoadedAdFitsBudget(preloaded.adController)) return [
2267
- 3,
2268
- 3
2269
- ];
2270
- this.timing.rejectLoadedAdForDuration(preloaded.adController);
2271
- return [
2272
- 4,
2273
- this.tryNextAvailableAdWithRateLimit()
2274
- ];
2275
- case 2:
2276
- _state.sent();
2277
- return [
2278
- 2
2279
- ];
2280
- case 3:
2281
- this.swapToPreloadedAdPlayer(preloaded.adController);
2282
- ap = this.host.getAdPlayer();
2283
- return [
2284
- 4,
2285
- ap.play()
2286
- ];
2287
- case 4:
2288
- _state.sent();
2289
- this.timing.markAdStarted();
2290
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
2291
- this.timing.scheduleAdStopAtBreakBoundary();
2292
- }
2293
- ap.setAdVolume(getAdAudioVolume(ap));
2294
- this.timing.consecutiveFailures = 0;
2295
- return [
2296
- 2
2297
- ];
2298
- case 5:
2299
- error = _state.sent();
2300
- if (this.debug) {
2301
- console.warn("[CONTINUOUS-FETCH] Preloaded ad failed to play:", error);
2302
- }
2303
- return [
2304
- 3,
2305
- 6
2306
- ];
2307
- case 6:
2308
1962
  if (!(this.adRequestQueue.length > 0)) return [
2309
1963
  3,
2310
- 14
1964
+ 9
2311
1965
  ];
2312
1966
  nextAdUrl = this.adRequestQueue.shift();
2313
1967
  if (!nextAdUrl) return [
2314
1968
  3,
2315
- 6
1969
+ 1
2316
1970
  ];
2317
1971
  if (this.timing.failedVastUrls.has(nextAdUrl)) {
2318
1972
  if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping permanently-failed URL, trying next...");
2319
1973
  return [
2320
1974
  3,
2321
- 6
1975
+ 1
2322
1976
  ];
2323
1977
  }
2324
1978
  if (this.timing.isUrlInCooldown(nextAdUrl)) {
2325
1979
  if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping URL in cooldown (recent no-fill), trying next...");
2326
1980
  return [
2327
1981
  3,
2328
- 6
1982
+ 1
2329
1983
  ];
2330
1984
  }
2331
1985
  if (this.debug) {
2332
1986
  console.log("[CONTINUOUS-FETCH] Requesting next ad via HLS ad player (".concat(this.timing.currentAdIndex + 1, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
2333
1987
  }
2334
- _state.label = 7;
2335
- case 7:
1988
+ _state.label = 2;
1989
+ case 2:
2336
1990
  _state.trys.push([
2337
- 7,
2338
- 9,
1991
+ 2,
1992
+ 4,
2339
1993
  ,
2340
- 13
1994
+ 8
2341
1995
  ]);
2342
1996
  return [
2343
1997
  4,
2344
1998
  this.playSingleAd(nextAdUrl)
2345
1999
  ];
2346
- case 8:
2000
+ case 3:
2347
2001
  _state.sent();
2348
2002
  this.timing.consecutiveFailures = 0;
2349
2003
  return [
2350
2004
  3,
2351
- 13
2005
+ 8
2352
2006
  ];
2353
- case 9:
2354
- error1 = _state.sent();
2355
- errorMessage = error1.message;
2007
+ case 4:
2008
+ error = _state.sent();
2009
+ errorMessage = error.message;
2356
2010
  if (this.debug) console.log("[CONTINUOUS-FETCH] Ad request failed:", errorMessage);
2357
2011
  if (!errorMessage.includes("ad_duration_exceeds_budget")) return [
2358
2012
  3,
2359
- 11
2013
+ 6
2360
2014
  ];
2361
2015
  return [
2362
2016
  4,
2363
2017
  this.tryNextAvailableAdWithRateLimit()
2364
2018
  ];
2365
- case 10:
2019
+ case 5:
2366
2020
  _state.sent();
2367
2021
  return [
2368
2022
  2
2369
2023
  ];
2370
- case 11:
2024
+ case 6:
2371
2025
  if (!errorMessage.includes("permanently failed") && !errorMessage.includes("in cooldown")) {
2372
2026
  this.timing.consecutiveFailures++;
2373
2027
  }
@@ -2375,21 +2029,21 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2375
2029
  4,
2376
2030
  this.tryNextAvailableAdWithRateLimit()
2377
2031
  ];
2378
- case 12:
2032
+ case 7:
2379
2033
  _state.sent();
2380
2034
  return [
2381
2035
  3,
2382
- 13
2036
+ 8
2383
2037
  ];
2384
- case 13:
2038
+ case 8:
2385
2039
  return [
2386
2040
  2
2387
2041
  ];
2388
- case 14:
2042
+ case 9:
2389
2043
  maxRetries = 3;
2390
2044
  if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
2391
2045
  3,
2392
- 17
2046
+ 12
2393
2047
  ];
2394
2048
  if (this.debug) {
2395
2049
  console.log("[CONTINUOUS-FETCH] Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
@@ -2400,18 +2054,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2400
2054
  return setTimeout(resolve, 500);
2401
2055
  })
2402
2056
  ];
2403
- case 15:
2057
+ case 10:
2404
2058
  _state.sent();
2405
2059
  return [
2406
2060
  4,
2407
2061
  this.tryNextAvailableAd(retryCount + 1)
2408
2062
  ];
2409
- case 16:
2063
+ case 11:
2410
2064
  _state.sent();
2411
2065
  return [
2412
2066
  2
2413
2067
  ];
2414
- case 17:
2068
+ case 12:
2415
2069
  if (!this.isShowingPlaceholder && remaining > 1e3) {
2416
2070
  this.showPlaceholderAndWaitForAds();
2417
2071
  } else {
@@ -2433,7 +2087,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2433
2087
  // ───────────────────────────────────────────────────────────────
2434
2088
  function playSingleAd(vastTagUrl) {
2435
2089
  return _async_to_generator(function() {
2436
- var adPlayer, requestToken, ap, playError, preloadedFallback, fbAp, fallbackError, error, errorMessage, preloadedFallback1, fbAp1, fallbackError1;
2090
+ var adPlayer, requestToken, ap, playError, error, errorMessage;
2437
2091
  return _ts_generator(this, function(_state) {
2438
2092
  switch(_state.label){
2439
2093
  case 0:
@@ -2465,9 +2119,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2465
2119
  case 1:
2466
2120
  _state.trys.push([
2467
2121
  1,
2468
- 12,
2122
+ 8,
2469
2123
  ,
2470
- 17
2124
+ 9
2471
2125
  ]);
2472
2126
  return [
2473
2127
  4,
@@ -2503,7 +2157,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2503
2157
  4,
2504
2158
  6,
2505
2159
  ,
2506
- 11
2160
+ 7
2507
2161
  ]);
2508
2162
  this.timing.startAdFailsafeTimer(requestToken);
2509
2163
  return [
@@ -2521,55 +2175,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2521
2175
  this.timing.temporaryFailureUrls.delete(vastTagUrl);
2522
2176
  return [
2523
2177
  3,
2524
- 11
2178
+ 7
2525
2179
  ];
2526
2180
  case 6:
2527
2181
  playError = _state.sent();
2528
2182
  if (this.debug) console.error("[AD-ERROR] Failed to play ad:", playError);
2529
- preloadedFallback = this.preloadPool.getPreloadedAd();
2530
- if (!preloadedFallback) return [
2531
- 3,
2532
- 10
2533
- ];
2534
- if (this.debug) console.log("[AD-ERROR] Play failed, trying preloaded fallback ad");
2535
- _state.label = 7;
2536
- case 7:
2537
- _state.trys.push([
2538
- 7,
2539
- 9,
2540
- ,
2541
- 10
2542
- ]);
2543
- if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback.adController)) {
2544
- this.timing.rejectLoadedAdForDuration(preloadedFallback.adController);
2545
- throw playError;
2546
- }
2547
- this.timing.clearAdFailsafeTimer();
2548
- this.swapToPreloadedAdPlayer(preloadedFallback.adController);
2549
- this.timing.consecutiveFailures = 0;
2550
- fbAp = this.host.getAdPlayer();
2551
- return [
2552
- 4,
2553
- fbAp.play()
2554
- ];
2555
- case 8:
2556
- _state.sent();
2557
- this.timing.markAdStarted();
2558
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
2559
- this.timing.scheduleAdStopAtBreakBoundary();
2560
- }
2561
- fbAp.setAdVolume(getAdAudioVolume(fbAp));
2562
- return [
2563
- 2
2564
- ];
2565
- case 9:
2566
- fallbackError = _state.sent();
2567
- if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError);
2568
- return [
2569
- 3,
2570
- 10
2571
- ];
2572
- case 10:
2573
2183
  if (this.timing.isTemporaryAdError(playError)) {
2574
2184
  this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
2575
2185
  if (this.debug) console.log("[AD-ERROR] Temporary play error - URL can be retried after cooldown");
@@ -2582,57 +2192,15 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2582
2192
  this.timing.activeAdRequestToken = null;
2583
2193
  }
2584
2194
  throw playError;
2585
- case 11:
2195
+ case 7:
2586
2196
  return [
2587
2197
  3,
2588
- 17
2198
+ 9
2589
2199
  ];
2590
- case 12:
2200
+ case 8:
2591
2201
  error = _state.sent();
2592
2202
  errorMessage = (error === null || error === void 0 ? void 0 : error.message) || "";
2593
2203
  if (this.debug) console.error("[AD-ERROR] Ad request failed:", errorMessage);
2594
- preloadedFallback1 = this.preloadPool.getPreloadedAd();
2595
- if (!preloadedFallback1) return [
2596
- 3,
2597
- 16
2598
- ];
2599
- if (this.debug) console.log("[AD-ERROR] Request failed, trying preloaded fallback ad");
2600
- _state.label = 13;
2601
- case 13:
2602
- _state.trys.push([
2603
- 13,
2604
- 15,
2605
- ,
2606
- 16
2607
- ]);
2608
- if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback1.adController)) {
2609
- this.timing.rejectLoadedAdForDuration(preloadedFallback1.adController);
2610
- throw error;
2611
- }
2612
- this.timing.clearAdRequestWatchdog();
2613
- this.timing.clearAdFailsafeTimer();
2614
- this.swapToPreloadedAdPlayer(preloadedFallback1.adController);
2615
- this.timing.consecutiveFailures = 0;
2616
- fbAp1 = this.host.getAdPlayer();
2617
- return [
2618
- 4,
2619
- fbAp1.play()
2620
- ];
2621
- case 14:
2622
- _state.sent();
2623
- this.timing.markAdStarted();
2624
- fbAp1.setAdVolume(getAdAudioVolume(fbAp1));
2625
- return [
2626
- 2
2627
- ];
2628
- case 15:
2629
- fallbackError1 = _state.sent();
2630
- if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError1);
2631
- return [
2632
- 3,
2633
- 16
2634
- ];
2635
- case 16:
2636
2204
  if (this.timing.isTemporaryAdError(error)) {
2637
2205
  this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
2638
2206
  if (this.debug) console.log("[AD-ERROR] Temporary error (no-fill/timeout) - URL can be retried after cooldown");
@@ -2646,7 +2214,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2646
2214
  this.timing.activeAdRequestToken = null;
2647
2215
  }
2648
2216
  throw error;
2649
- case 17:
2217
+ case 9:
2650
2218
  return [
2651
2219
  2
2652
2220
  ];
@@ -2836,7 +2404,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2836
2404
  }
2837
2405
  this.timing.resetForBreakEnd();
2838
2406
  this.stopContinuousFetching();
2839
- this.preloadPool.stop();
2840
2407
  this.clearPendingAdBreak();
2841
2408
  if (this.isShowingPlaceholder) {
2842
2409
  this.host.getAdPlayer().hidePlaceholder();