stormcloud-video-player 0.8.28 → 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 +80 -1038
  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 +80 -1039
  7. package/lib/index.js.map +1 -1
  8. package/lib/player/AdBreakOrchestrator.cjs +59 -483
  9. package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
  10. package/lib/player/AdBreakOrchestrator.d.cts +9 -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 +80 -1038
  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 +80 -1038
  24. package/lib/players/HlsPlayer.cjs.map +1 -1
  25. package/lib/players/HlsPlayer.d.cts +1 -1
  26. package/lib/players/index.cjs +80 -1038
  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 +80 -1038
  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
package/lib/index.cjs CHANGED
@@ -3678,21 +3678,16 @@ function applyVastMacros(baseUrl, ctx) {
3678
3678
  if (ctx.pod != null) {
3679
3679
  params.set("pod", String(ctx.pod));
3680
3680
  }
3681
- var optimizedPodMode = ctx.podMaxAds != null || ctx.podMinDurationMs != null || ctx.podMaxDurationMs != null;
3682
- if (optimizedPodMode) {
3683
- params.delete("ppos");
3684
- params.delete("lip");
3685
- if (ctx.podMinDurationMs != null) {
3686
- params.set("pmnd", String(Math.max(0, Math.round(ctx.podMinDurationMs))));
3687
- }
3688
- if (ctx.podMaxDurationMs != null) {
3689
- params.set("pmxd", String(Math.max(0, Math.round(ctx.podMaxDurationMs))));
3690
- }
3691
- if (ctx.podMaxAds != null) {
3692
- params.set("pmad", String(Math.max(1, Math.round(ctx.podMaxAds))));
3693
- }
3694
- } else if (ctx.adPosition != null) {
3695
- params.set("ppos", String(ctx.adPosition));
3681
+ params.delete("ppos");
3682
+ params.delete("lip");
3683
+ if (ctx.podMinDurationMs != null) {
3684
+ params.set("pmnd", String(Math.max(0, Math.round(ctx.podMinDurationMs))));
3685
+ }
3686
+ if (ctx.podMaxDurationMs != null) {
3687
+ params.set("pmxd", String(Math.max(0, Math.round(ctx.podMaxDurationMs))));
3688
+ }
3689
+ if (ctx.podMaxAds != null) {
3690
+ params.set("pmad", String(Math.max(1, Math.round(ctx.podMaxAds))));
3696
3691
  }
3697
3692
  var requestUrl = ctx.contentUrl || ctx.pageUrl;
3698
3693
  if (requestUrl) {
@@ -5055,9 +5050,9 @@ var AdConfigManager = /*#__PURE__*/ function() {
5055
5050
  this.consentSignals = {};
5056
5051
  this.podCounter = 0;
5057
5052
  this.podAssignedByPrefetch = false;
5058
- this.adRequestPositionInBreak = 0;
5059
5053
  this.lastHeartbeatTime = 0;
5060
5054
  this.defaultPodMaxAds = 6;
5055
+ this.defaultPodMaxDurationMs = 12e4;
5061
5056
  this.config = config;
5062
5057
  this.video = video;
5063
5058
  }
@@ -5475,48 +5470,12 @@ var AdConfigManager = /*#__PURE__*/ function() {
5475
5470
  key: "beginNewAdPod",
5476
5471
  value: function beginNewAdPod() {
5477
5472
  this.podCounter++;
5478
- this.adRequestPositionInBreak = 0;
5479
- }
5480
- },
5481
- {
5482
- key: "generateVastUrlsWithCorrelators",
5483
- value: function generateVastUrlsWithCorrelators(baseUrl, count, adPlayer, palNonce, inAdBreak) {
5484
- var urls = [];
5485
- for(var i = 0; i < count; i++){
5486
- this.adRequestPositionInBreak++;
5487
- var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
5488
- var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest);
5489
- var urlWithMacros = applyVastMacros(baseUrl, {
5490
- correlator: this.viewCorrelator,
5491
- streamCorrelator: this.streamCorrelator,
5492
- pod: this.podCounter > 0 ? this.podCounter : void 0,
5493
- adPosition: this.adRequestPositionInBreak,
5494
- isCtv: envSignals.isCtv,
5495
- contentUrl: envSignals.contentUrl,
5496
- pageUrl: !envSignals.isCtv && typeof window !== "undefined" ? window.location.href : void 0,
5497
- adWillPlayMuted: adWillPlayMuted,
5498
- adWillAutoPlay: !!this.config.autoplay,
5499
- appId: envSignals.appId,
5500
- appName: envSignals.appName,
5501
- sessionId: envSignals.sessionId,
5502
- deviceId: envSignals.deviceId,
5503
- deviceIdType: envSignals.deviceIdType,
5504
- limitAdTracking: envSignals.limitAdTracking,
5505
- deviceTypeHint: envSignals.deviceTypeHint,
5506
- adTest: this.config.adTest,
5507
- consent: this.consentSignals
5508
- });
5509
- var finalUrl = palNonce.injectNonce(urlWithMacros);
5510
- console.log("[StormcloudVideoPlayer] Resolved ad request URL (pod=".concat(this.podCounter, ", pos=").concat(this.adRequestPositionInBreak, "):"), finalUrl);
5511
- urls.push(finalUrl);
5512
- }
5513
- return urls;
5514
5473
  }
5515
5474
  },
5516
5475
  {
5517
5476
  key: "resolvePodParams",
5518
5477
  value: function resolvePodParams(breakDurationMs) {
5519
- var maxDurationMs = breakDurationMs != null && breakDurationMs > 0 ? breakDurationMs : this.config.podMaxDurationMs;
5478
+ var maxDurationMs = breakDurationMs != null && breakDurationMs > 0 ? breakDurationMs : this.config.podMaxDurationMs != null && this.config.podMaxDurationMs > 0 ? this.config.podMaxDurationMs : this.defaultPodMaxDurationMs;
5520
5479
  var maxAds = this.config.podMaxAds && this.config.podMaxAds > 0 ? this.config.podMaxAds : this.apiNumberAds && this.apiNumberAds > 0 ? this.apiNumberAds : this.defaultPodMaxAds;
5521
5480
  var minDurationMs = this.config.podExactDuration && maxDurationMs != null ? maxDurationMs : 0;
5522
5481
  return {
@@ -6169,462 +6128,6 @@ var AdTimingService = /*#__PURE__*/ function() {
6169
6128
  ]);
6170
6129
  return AdTimingService;
6171
6130
  }();
6172
- // src/player/AdPreloadPool.ts
6173
- var AdPreloadPool = /*#__PURE__*/ function() {
6174
- function AdPreloadPool(deps) {
6175
- _class_call_check(this, AdPreloadPool);
6176
- this.pool = [];
6177
- this.maxPoolSize = 2;
6178
- this.poolActive = false;
6179
- this.loopRunning = false;
6180
- this.deps = deps;
6181
- }
6182
- _create_class(AdPreloadPool, [
6183
- {
6184
- key: "active",
6185
- get: function get() {
6186
- return this.poolActive;
6187
- },
6188
- set: function set(value) {
6189
- this.poolActive = value;
6190
- }
6191
- },
6192
- {
6193
- key: "isLoopRunning",
6194
- get: function get() {
6195
- return this.loopRunning;
6196
- }
6197
- },
6198
- {
6199
- key: "startPreloadPool",
6200
- value: function startPreloadPool(baseVastUrl, initialUrls) {
6201
- var startLoopImmediately = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
6202
- if (this.poolActive) {
6203
- if (this.deps.debug) {
6204
- console.log("[PRELOAD-POOL] Already active, skipping duplicate start");
6205
- }
6206
- return;
6207
- }
6208
- this.poolActive = true;
6209
- if (this.deps.debug) {
6210
- console.log("[PRELOAD-POOL] Starting preload pool EARLY (target size: ".concat(this.maxPoolSize, ")"));
6211
- console.log("[PRELOAD-POOL] Ad break hasn't started yet, but preloading ads in advance");
6212
- }
6213
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6214
- try {
6215
- for(var _iterator = initialUrls[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6216
- var url = _step.value;
6217
- if (this.pool.length < this.maxPoolSize) {
6218
- this.preloadAdIntoPool(url);
6219
- }
6220
- }
6221
- } catch (err) {
6222
- _didIteratorError = true;
6223
- _iteratorError = err;
6224
- } finally{
6225
- try {
6226
- if (!_iteratorNormalCompletion && _iterator.return != null) {
6227
- _iterator.return();
6228
- }
6229
- } finally{
6230
- if (_didIteratorError) {
6231
- throw _iteratorError;
6232
- }
6233
- }
6234
- }
6235
- if (startLoopImmediately) {
6236
- this.preloadPoolLoop(baseVastUrl);
6237
- } else if (this.deps.debug) {
6238
- console.log("[PRELOAD-POOL] Pre-break mode: preloaded once, waiting for SCTE start to continue fetching");
6239
- }
6240
- }
6241
- },
6242
- {
6243
- key: "preloadAdIntoPool",
6244
- value: function preloadAdIntoPool(vastUrl) {
6245
- return _async_to_generator(function() {
6246
- var _this, timing, epoch, loadPromise;
6247
- return _ts_generator(this, function(_state) {
6248
- _this = this;
6249
- timing = this.deps.timing;
6250
- if (timing.isGamInCooldown()) {
6251
- if (this.deps.debug) {
6252
- console.log("[CIRCUIT-BREAKER] GAM in cooldown, skipping preload");
6253
- }
6254
- return [
6255
- 2
6256
- ];
6257
- }
6258
- if (this.pool.some(function(entry) {
6259
- return entry.vastUrl === vastUrl;
6260
- }) || timing.failedVastUrls.has(vastUrl) || timing.isUrlInCooldown(vastUrl)) {
6261
- return [
6262
- 2
6263
- ];
6264
- }
6265
- if (this.pool.length >= this.maxPoolSize) {
6266
- return [
6267
- 2
6268
- ];
6269
- }
6270
- if (this.deps.debug) {
6271
- console.log("[PRELOAD-POOL] Preloading ad into pool: ".concat(vastUrl));
6272
- }
6273
- epoch = timing.adBreakEpoch;
6274
- loadPromise = function() {
6275
- return _async_to_generator(function() {
6276
- var _this, hasAdError, adErrorPayload, errorListenerCleanup, _preloadAd_getLoadedAdDuration, continueLiveStreamDuringAds, preloadAd, errorListener, isNoFill, poolEntry, loadedDuration, lateErrorListener, _poolEntry_durationSeconds, error;
6277
- return _ts_generator(this, function(_state) {
6278
- switch(_state.label){
6279
- case 0:
6280
- _this = this;
6281
- hasAdError = false;
6282
- adErrorPayload = null;
6283
- errorListenerCleanup = null;
6284
- _state.label = 1;
6285
- case 1:
6286
- _state.trys.push([
6287
- 1,
6288
- 5,
6289
- ,
6290
- 6
6291
- ]);
6292
- continueLiveStreamDuringAds = this.deps.shouldContinueLiveStreamDuringAds();
6293
- preloadAd = this.deps.createAdPlayer(continueLiveStreamDuringAds);
6294
- preloadAd.initialize();
6295
- errorListener = function errorListener(payload) {
6296
- hasAdError = true;
6297
- adErrorPayload = payload;
6298
- };
6299
- preloadAd.on("ad_error", errorListener);
6300
- errorListenerCleanup = function errorListenerCleanup() {
6301
- return preloadAd.off("ad_error", errorListener);
6302
- };
6303
- return [
6304
- 4,
6305
- timing.enforceGlobalRateLimit()
6306
- ];
6307
- case 2:
6308
- _state.sent();
6309
- return [
6310
- 4,
6311
- preloadAd.requestAds(vastUrl)
6312
- ];
6313
- case 3:
6314
- _state.sent();
6315
- preloadAd.pause();
6316
- return [
6317
- 4,
6318
- new Promise(function(resolve) {
6319
- return setTimeout(resolve, 1500);
6320
- })
6321
- ];
6322
- case 4:
6323
- _state.sent();
6324
- preloadAd.pause();
6325
- if (hasAdError) {
6326
- isNoFill = (adErrorPayload === null || adErrorPayload === void 0 ? void 0 : adErrorPayload.isNoFill) || (adErrorPayload === null || adErrorPayload === void 0 ? void 0 : adErrorPayload.code) === 303 || (adErrorPayload === null || adErrorPayload === void 0 ? void 0 : adErrorPayload.vastErrorCode) === 303;
6327
- if (errorListenerCleanup) {
6328
- errorListenerCleanup();
6329
- }
6330
- preloadAd.destroy();
6331
- timing.recordGamNoFill();
6332
- if (isNoFill) {
6333
- if (this.deps.debug) {
6334
- console.log("[PRELOAD-POOL] Ad preload returned no-fill: ".concat(vastUrl));
6335
- }
6336
- timing.temporaryFailureUrls.set(vastUrl, Date.now());
6337
- } else {
6338
- if (this.deps.debug) {
6339
- console.log("[PRELOAD-POOL] Ad preload failed with error: ".concat(vastUrl), adErrorPayload);
6340
- }
6341
- if (adErrorPayload && !timing.isTemporaryAdError(adErrorPayload)) {
6342
- timing.failedVastUrls.add(vastUrl);
6343
- } else {
6344
- timing.temporaryFailureUrls.set(vastUrl, Date.now());
6345
- }
6346
- }
6347
- return [
6348
- 2
6349
- ];
6350
- }
6351
- if (!this.poolActive || epoch !== timing.adBreakEpoch) {
6352
- if (this.deps.debug) {
6353
- console.log("[PRELOAD-POOL] Discarding preloaded ad - break ended during fetch");
6354
- }
6355
- if (errorListenerCleanup) {
6356
- errorListenerCleanup();
6357
- }
6358
- try {
6359
- preloadAd.destroy();
6360
- } catch (unused) {}
6361
- return [
6362
- 2
6363
- ];
6364
- }
6365
- poolEntry = {
6366
- vastUrl: vastUrl,
6367
- adController: preloadAd,
6368
- loadedAt: Date.now(),
6369
- isReady: true,
6370
- loadPromise: Promise.resolve()
6371
- };
6372
- loadedDuration = (_preloadAd_getLoadedAdDuration = preloadAd.getLoadedAdDuration) === null || _preloadAd_getLoadedAdDuration === void 0 ? void 0 : _preloadAd_getLoadedAdDuration.call(preloadAd);
6373
- if (loadedDuration != null && loadedDuration > 0) {
6374
- poolEntry.durationSeconds = loadedDuration;
6375
- }
6376
- lateErrorListener = function lateErrorListener(payload) {
6377
- var index = _this.pool.findIndex(function(entry) {
6378
- return entry.vastUrl === vastUrl;
6379
- });
6380
- if (index >= 0) {
6381
- _this.pool.splice(index, 1);
6382
- if (_this.deps.debug) {
6383
- console.log("[PRELOAD-POOL] Late error detected, removed from pool: ".concat(vastUrl), payload);
6384
- }
6385
- try {
6386
- preloadAd.destroy();
6387
- } catch (unused) {}
6388
- }
6389
- };
6390
- preloadAd.on("ad_error", lateErrorListener);
6391
- this.pool.push(poolEntry);
6392
- if (this.deps.debug) {
6393
- ;
6394
- console.log("[PRELOAD-POOL] Ad preloaded (no errors detected within timeout) (pool size: ".concat(this.pool.length, "/").concat(this.maxPoolSize, ", duration=").concat((_poolEntry_durationSeconds = poolEntry.durationSeconds) !== null && _poolEntry_durationSeconds !== void 0 ? _poolEntry_durationSeconds : "?", "s)"));
6395
- }
6396
- if (errorListenerCleanup) {
6397
- errorListenerCleanup();
6398
- }
6399
- return [
6400
- 3,
6401
- 6
6402
- ];
6403
- case 5:
6404
- error = _state.sent();
6405
- if (errorListenerCleanup) {
6406
- errorListenerCleanup();
6407
- }
6408
- timing.recordGamNoFill();
6409
- if (this.deps.debug) {
6410
- console.warn("[PRELOAD-POOL] Failed to preload ad: ".concat(vastUrl), error);
6411
- }
6412
- if (_instanceof(error, Error) && !timing.isTemporaryAdError(error)) {
6413
- timing.failedVastUrls.add(vastUrl);
6414
- } else if (_instanceof(error, Error) && timing.isTemporaryAdError(error)) {
6415
- timing.temporaryFailureUrls.set(vastUrl, Date.now());
6416
- }
6417
- return [
6418
- 3,
6419
- 6
6420
- ];
6421
- case 6:
6422
- return [
6423
- 2
6424
- ];
6425
- }
6426
- });
6427
- }).call(_this);
6428
- }();
6429
- loadPromise.catch(function() {});
6430
- return [
6431
- 2
6432
- ];
6433
- });
6434
- }).call(this);
6435
- }
6436
- },
6437
- {
6438
- key: "preloadPoolLoop",
6439
- value: function preloadPoolLoop(baseVastUrl) {
6440
- return _async_to_generator(function() {
6441
- var epoch, newUrls, newUrl;
6442
- return _ts_generator(this, function(_state) {
6443
- switch(_state.label){
6444
- case 0:
6445
- if (this.loopRunning) {
6446
- return [
6447
- 2
6448
- ];
6449
- }
6450
- this.loopRunning = true;
6451
- epoch = this.deps.timing.adBreakEpoch;
6452
- if (this.deps.debug) {
6453
- console.log("[PRELOAD-POOL] Starting continuous preload loop");
6454
- }
6455
- _state.label = 1;
6456
- case 1:
6457
- if (!(this.poolActive && epoch === this.deps.timing.adBreakEpoch)) return [
6458
- 3,
6459
- 10
6460
- ];
6461
- if (this.deps.timing.isGamInCooldown()) {
6462
- if (this.deps.debug) {
6463
- console.log("[CIRCUIT-BREAKER] GAM in cooldown, stopping preload pool loop");
6464
- }
6465
- return [
6466
- 3,
6467
- 10
6468
- ];
6469
- }
6470
- if (!(!this.deps.isInAdBreak() && this.pool.length >= this.maxPoolSize)) return [
6471
- 3,
6472
- 3
6473
- ];
6474
- return [
6475
- 4,
6476
- new Promise(function(resolve) {
6477
- return setTimeout(resolve, 2e3);
6478
- })
6479
- ];
6480
- case 2:
6481
- _state.sent();
6482
- return [
6483
- 3,
6484
- 1
6485
- ];
6486
- case 3:
6487
- if (!this.deps.isInAdBreak() && this.deps.getPendingAdBreak() === null) {
6488
- if (this.deps.debug) {
6489
- console.log("[PRELOAD-POOL] Ad break cancelled, stopping preload pool");
6490
- }
6491
- return [
6492
- 3,
6493
- 10
6494
- ];
6495
- }
6496
- _state.label = 4;
6497
- case 4:
6498
- if (!(this.pool.length < this.maxPoolSize)) return [
6499
- 3,
6500
- 8
6501
- ];
6502
- if (!this.poolActive || epoch !== this.deps.timing.adBreakEpoch || this.deps.timing.isGamInCooldown()) {
6503
- return [
6504
- 3,
6505
- 8
6506
- ];
6507
- }
6508
- if (this.deps.isInAdBreak() && !this.deps.timing.hasTimeToStartAnotherAd()) {
6509
- if (this.deps.debug) {
6510
- console.log("[PRELOAD-POOL] Not enough ad break time left, stopping preload");
6511
- }
6512
- return [
6513
- 3,
6514
- 8
6515
- ];
6516
- }
6517
- newUrls = this.deps.generateVastUrlsWithCorrelators(baseVastUrl, 1);
6518
- newUrl = newUrls[0];
6519
- if (!(newUrl && !this.deps.timing.failedVastUrls.has(newUrl) && !this.deps.timing.isUrlInCooldown(newUrl))) return [
6520
- 3,
6521
- 6
6522
- ];
6523
- return [
6524
- 4,
6525
- this.preloadAdIntoPool(newUrl)
6526
- ];
6527
- case 5:
6528
- _state.sent();
6529
- _state.label = 6;
6530
- case 6:
6531
- return [
6532
- 4,
6533
- new Promise(function(resolve) {
6534
- return setTimeout(resolve, 1e3);
6535
- })
6536
- ];
6537
- case 7:
6538
- _state.sent();
6539
- return [
6540
- 3,
6541
- 4
6542
- ];
6543
- case 8:
6544
- return [
6545
- 4,
6546
- new Promise(function(resolve) {
6547
- return setTimeout(resolve, 2e3);
6548
- })
6549
- ];
6550
- case 9:
6551
- _state.sent();
6552
- return [
6553
- 3,
6554
- 1
6555
- ];
6556
- case 10:
6557
- this.loopRunning = false;
6558
- if (this.deps.debug) {
6559
- console.log("[PRELOAD-POOL] Preload loop ended");
6560
- }
6561
- return [
6562
- 2
6563
- ];
6564
- }
6565
- });
6566
- }).call(this);
6567
- }
6568
- },
6569
- {
6570
- key: "getPreloadedAd",
6571
- value: function getPreloadedAd() {
6572
- if (this.pool.length === 0) {
6573
- return null;
6574
- }
6575
- var entry = this.pool.shift();
6576
- if (!entry || !entry.isReady) {
6577
- return null;
6578
- }
6579
- if (this.deps.debug) {
6580
- console.log("[PRELOAD-POOL] Using preloaded ad from pool (".concat(this.pool.length, " remaining)"));
6581
- }
6582
- return {
6583
- vastUrl: entry.vastUrl,
6584
- adController: entry.adController
6585
- };
6586
- }
6587
- },
6588
- {
6589
- key: "stop",
6590
- value: function stop() {
6591
- this.poolActive = false;
6592
- this.loopRunning = false;
6593
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6594
- try {
6595
- for(var _iterator = this.pool[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6596
- var entry = _step.value;
6597
- try {
6598
- entry.adController.destroy();
6599
- } catch (error) {
6600
- if (this.deps.debug) {
6601
- console.warn("[PRELOAD-POOL] Error destroying preloaded controller:", error);
6602
- }
6603
- }
6604
- }
6605
- } catch (err) {
6606
- _didIteratorError = true;
6607
- _iteratorError = err;
6608
- } finally{
6609
- try {
6610
- if (!_iteratorNormalCompletion && _iterator.return != null) {
6611
- _iterator.return();
6612
- }
6613
- } finally{
6614
- if (_didIteratorError) {
6615
- throw _iteratorError;
6616
- }
6617
- }
6618
- }
6619
- this.pool = [];
6620
- if (this.deps.debug) {
6621
- console.log("[PRELOAD-POOL] Preload pool stopped and cleaned up");
6622
- }
6623
- }
6624
- }
6625
- ]);
6626
- return AdPreloadPool;
6627
- }();
6628
6131
  // src/player/PlaceholderLayer.ts
6629
6132
  var PlaceholderLayer = /*#__PURE__*/ function() {
6630
6133
  function PlaceholderLayer(video, debug) {
@@ -7346,7 +6849,7 @@ function resizePlayer(video, adPlayer, debug) {
7346
6849
  }
7347
6850
  // src/player/AdBreakOrchestrator.ts
7348
6851
  var AdBreakOrchestrator = /*#__PURE__*/ function() {
7349
- function AdBreakOrchestrator(host, timing, preloadPool, adConfig, cueManager, placeholder) {
6852
+ function AdBreakOrchestrator(host, timing, adConfig, cueManager, placeholder) {
7350
6853
  _class_call_check(this, AdBreakOrchestrator);
7351
6854
  this.inAdBreak = false;
7352
6855
  this.showAds = false;
@@ -7360,7 +6863,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7360
6863
  this.pendingAdBreak = null;
7361
6864
  this.host = host;
7362
6865
  this.timing = timing;
7363
- this.preloadPool = preloadPool;
7364
6866
  this.adConfig = adConfig;
7365
6867
  this.cueManager = cueManager;
7366
6868
  this.placeholder = placeholder;
@@ -7379,12 +6881,19 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7379
6881
  }
7380
6882
  },
7381
6883
  {
7382
- key: "optimizedPodsEnabled",
7383
- get: // ───────────────────────────────────────────────────────────────
6884
+ // ───────────────────────────────────────────────────────────────
7384
6885
  // IMA event listeners
7385
6886
  // ───────────────────────────────────────────────────────────────
7386
- function get() {
7387
- return this.host.config.optimizedPods !== false;
6887
+ /**
6888
+ * Produces the next pod ad-request URL for the current break. Every request
6889
+ * (initial and continuous-fetch top-up) carries pod macros (pmad/pmnd/pmxd,
6890
+ * no ppos); pmxd tracks the remaining break time so top-up pods only ask for
6891
+ * what still fits.
6892
+ */ key: "nextAdRequestUrl",
6893
+ value: function nextAdRequestUrl(baseVastUrl) {
6894
+ var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
6895
+ var breakDurationMs = remaining > 0 ? remaining : void 0;
6896
+ return this.host.generatePodVastUrl(baseVastUrl, breakDurationMs);
7388
6897
  }
7389
6898
  },
7390
6899
  {
@@ -7556,7 +7065,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7556
7065
  // ───────────────────────────────────────────────────────────────
7557
7066
  function handleAdStart(_marker) {
7558
7067
  return _async_to_generator(function() {
7559
- var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, podPlayed, firstAdUrl, usePreloadedAd, preloadedController, preloaded, firstAdUrlArray, adPlayer, preservedMuted, preservedVolume, adVolume, adPlayer1, adVolume1, error, fallbackPreloaded, ap, adVolume2, fallbackError;
7068
+ var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, podPlayed;
7560
7069
  return _ts_generator(this, function(_state) {
7561
7070
  switch(_state.label){
7562
7071
  case 0:
@@ -7603,292 +7112,29 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7603
7112
  if (this.timing.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
7604
7113
  this.timing.expectedAdBreakDurationMs = adBreakDurationMs;
7605
7114
  }
7606
- if (!this.optimizedPodsEnabled) return [
7607
- 3,
7608
- 2
7609
- ];
7610
7115
  return [
7611
7116
  4,
7612
7117
  this.startOptimizedPod(baseVastUrl, adBreakDurationMs, currentMuted, currentVolume)
7613
7118
  ];
7614
7119
  case 1:
7615
7120
  podPlayed = _state.sent();
7616
- if (podPlayed) {
7617
- return [
7618
- 2
7619
- ];
7620
- }
7121
+ if (!!podPlayed) return [
7122
+ 3,
7123
+ 3
7124
+ ];
7621
7125
  if (this.debug) {
7622
- console.log("[POD] Optimized pod unavailable, falling back to sequential single-ad path");
7126
+ console.log("[POD] Initial pod request did not fill; attempting top-up pod request");
7623
7127
  }
7624
- _state.label = 2;
7128
+ this.continuousFetchingActive = true;
7129
+ this.startContinuousFetching(baseVastUrl);
7130
+ return [
7131
+ 4,
7132
+ this.tryNextAvailableAdWithRateLimit()
7133
+ ];
7625
7134
  case 2:
7626
- usePreloadedAd = false;
7627
- preloaded = this.preloadPool.getPreloadedAd();
7628
- if (preloaded) {
7629
- firstAdUrl = preloaded.vastUrl;
7630
- preloadedController = preloaded.adController;
7631
- usePreloadedAd = true;
7632
- sendAdLoadedTracking(this.host.config.licenseKey, {
7633
- source: "hls",
7634
- vastUrl: firstAdUrl,
7635
- timestamp: /* @__PURE__ */ new Date().toISOString()
7636
- }, this.analyticsContext).catch(function() {});
7637
- if (this.debug) {
7638
- console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool (preloaded in advance, ready immediately!)");
7639
- }
7640
- } else if (this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0) {
7641
- this.adRequestQueue = _to_consumable_array(this.pendingAdBreak.vastUrls);
7642
- firstAdUrl = this.adRequestQueue.shift();
7643
- if (this.debug) {
7644
- console.log("[CONTINUOUS-FETCH] Pool empty, using prefetched URLs (".concat(this.adRequestQueue.length + 1, " available)"));
7645
- }
7646
- this.clearPendingAdBreak();
7647
- } else {
7648
- if (this.debug) {
7649
- console.log("[CONTINUOUS-FETCH] Generating new ad URLs...");
7650
- }
7651
- firstAdUrlArray = this.host.generateVastUrls(baseVastUrl, 1);
7652
- firstAdUrl = firstAdUrlArray[0];
7653
- this.adRequestQueue = [];
7654
- }
7655
- if (!firstAdUrl) {
7656
- if (this.debug) {
7657
- console.warn("[CONTINUOUS-FETCH] Failed to get first ad URL");
7658
- }
7659
- this.handleAdPodComplete();
7660
- return [
7661
- 2
7662
- ];
7663
- }
7664
- if (this.debug) {
7665
- console.log("[CONTINUOUS-FETCH] First VAST URL:", firstAdUrl);
7666
- }
7135
+ _state.sent();
7667
7136
  _state.label = 3;
7668
7137
  case 3:
7669
- _state.trys.push([
7670
- 3,
7671
- 14,
7672
- ,
7673
- 22
7674
- ]);
7675
- if (!(usePreloadedAd && preloadedController)) return [
7676
- 3,
7677
- 7
7678
- ];
7679
- if (!!this.timing.ensureLoadedAdFitsBudget(preloadedController)) return [
7680
- 3,
7681
- 5
7682
- ];
7683
- this.timing.rejectLoadedAdForDuration(preloadedController);
7684
- this.startContinuousFetching(baseVastUrl);
7685
- return [
7686
- 4,
7687
- this.tryNextAvailableAdWithRateLimit()
7688
- ];
7689
- case 4:
7690
- _state.sent();
7691
- return [
7692
- 2
7693
- ];
7694
- case 5:
7695
- adPlayer = this.host.getAdPlayer();
7696
- preservedMuted = adPlayer.getOriginalMutedState();
7697
- preservedVolume = adPlayer.getOriginalVolume();
7698
- adPlayer.destroy();
7699
- this.host.video.muted = true;
7700
- this.host.setAdPlayer(preloadedController);
7701
- preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
7702
- this.attachImaEventListeners();
7703
- if (this.debug) {
7704
- console.log("[CONTINUOUS-FETCH] Using preloaded ad, resuming and starting playback immediately (no request delay!)");
7705
- }
7706
- preloadedController.resume();
7707
- this.timing.consecutiveFailures = 0;
7708
- this.startContinuousFetching(baseVastUrl);
7709
- if (!this.preloadPool.active) {
7710
- this.preloadPool.active = true;
7711
- }
7712
- if (!this.preloadPool.isLoopRunning) {
7713
- this.preloadPool.preloadPoolLoop(baseVastUrl);
7714
- }
7715
- return [
7716
- 4,
7717
- preloadedController.play()
7718
- ];
7719
- case 6:
7720
- _state.sent();
7721
- this.timing.markAdStarted();
7722
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7723
- this.timing.scheduleAdStopAtBreakBoundary();
7724
- }
7725
- adVolume = currentMuted ? 0 : currentVolume;
7726
- preloadedController.setAdVolume(adVolume);
7727
- return [
7728
- 3,
7729
- 13
7730
- ];
7731
- case 7:
7732
- adPlayer1 = this.host.getAdPlayer();
7733
- return [
7734
- 4,
7735
- this.timing.enforceGlobalRateLimit()
7736
- ];
7737
- case 8:
7738
- _state.sent();
7739
- this.timing.lastAdRequestTime = Date.now();
7740
- return [
7741
- 4,
7742
- adPlayer1.requestAds(firstAdUrl)
7743
- ];
7744
- case 9:
7745
- _state.sent();
7746
- sendAdLoadedTracking(this.host.config.licenseKey, {
7747
- source: "hls",
7748
- vastUrl: firstAdUrl,
7749
- timestamp: /* @__PURE__ */ new Date().toISOString()
7750
- }, this.analyticsContext).catch(function() {});
7751
- if (this.debug) {
7752
- console.log("[CONTINUOUS-FETCH] First ad request successful, starting playback");
7753
- }
7754
- if (!!this.timing.ensureLoadedAdFitsBudget(adPlayer1)) return [
7755
- 3,
7756
- 11
7757
- ];
7758
- this.timing.rejectLoadedAdForDuration(adPlayer1);
7759
- this.recreateAdController();
7760
- this.startContinuousFetching(baseVastUrl);
7761
- return [
7762
- 4,
7763
- this.tryNextAvailableAdWithRateLimit()
7764
- ];
7765
- case 10:
7766
- _state.sent();
7767
- return [
7768
- 2
7769
- ];
7770
- case 11:
7771
- this.timing.consecutiveFailures = 0;
7772
- this.startContinuousFetching(baseVastUrl);
7773
- if (!this.preloadPool.active) {
7774
- this.preloadPool.startPreloadPool(baseVastUrl, []);
7775
- }
7776
- return [
7777
- 4,
7778
- adPlayer1.play()
7779
- ];
7780
- case 12:
7781
- _state.sent();
7782
- this.timing.markAdStarted();
7783
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7784
- this.timing.scheduleAdStopAtBreakBoundary();
7785
- }
7786
- adVolume1 = currentMuted ? 0 : currentVolume;
7787
- adPlayer1.setAdVolume(adVolume1);
7788
- _state.label = 13;
7789
- case 13:
7790
- return [
7791
- 3,
7792
- 22
7793
- ];
7794
- case 14:
7795
- error = _state.sent();
7796
- if (this.debug) {
7797
- console.warn("[CONTINUOUS-FETCH] First ad request failed:", error);
7798
- }
7799
- if (!!usePreloadedAd) return [
7800
- 3,
7801
- 20
7802
- ];
7803
- fallbackPreloaded = this.preloadPool.getPreloadedAd();
7804
- if (!fallbackPreloaded) return [
7805
- 3,
7806
- 20
7807
- ];
7808
- if (this.debug) {
7809
- console.log("[CONTINUOUS-FETCH] First ad failed, using preloaded fallback");
7810
- }
7811
- _state.label = 15;
7812
- case 15:
7813
- _state.trys.push([
7814
- 15,
7815
- 19,
7816
- ,
7817
- 20
7818
- ]);
7819
- if (!!this.timing.ensureLoadedAdFitsBudget(fallbackPreloaded.adController)) return [
7820
- 3,
7821
- 17
7822
- ];
7823
- this.timing.rejectLoadedAdForDuration(fallbackPreloaded.adController);
7824
- this.startContinuousFetching(baseVastUrl);
7825
- return [
7826
- 4,
7827
- this.tryNextAvailableAdWithRateLimit()
7828
- ];
7829
- case 16:
7830
- _state.sent();
7831
- return [
7832
- 2
7833
- ];
7834
- case 17:
7835
- this.swapToPreloadedAdPlayer(fallbackPreloaded.adController);
7836
- this.timing.consecutiveFailures = 0;
7837
- this.startContinuousFetching(baseVastUrl);
7838
- if (!this.preloadPool.active) {
7839
- this.preloadPool.active = true;
7840
- this.preloadPool.preloadPoolLoop(baseVastUrl);
7841
- }
7842
- ap = this.host.getAdPlayer();
7843
- return [
7844
- 4,
7845
- ap.play()
7846
- ];
7847
- case 18:
7848
- _state.sent();
7849
- this.timing.markAdStarted();
7850
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7851
- this.timing.scheduleAdStopAtBreakBoundary();
7852
- }
7853
- adVolume2 = currentMuted ? 0 : currentVolume;
7854
- ap.setAdVolume(adVolume2);
7855
- return [
7856
- 2
7857
- ];
7858
- case 19:
7859
- fallbackError = _state.sent();
7860
- if (this.debug) {
7861
- console.warn("[CONTINUOUS-FETCH] Preloaded fallback also failed:", fallbackError);
7862
- }
7863
- return [
7864
- 3,
7865
- 20
7866
- ];
7867
- case 20:
7868
- if (this.timing.isTemporaryAdError(error)) {
7869
- this.timing.temporaryFailureUrls.set(firstAdUrl, Date.now());
7870
- if (this.debug) {
7871
- console.log("[CONTINUOUS-FETCH] First ad had temporary error (no-fill) - will try alternatives");
7872
- }
7873
- } else {
7874
- this.timing.failedVastUrls.add(firstAdUrl);
7875
- if (this.debug) {
7876
- console.log("[CONTINUOUS-FETCH] First ad had permanent error - URL blacklisted");
7877
- }
7878
- }
7879
- this.timing.consecutiveFailures++;
7880
- this.startContinuousFetching(baseVastUrl);
7881
- return [
7882
- 4,
7883
- this.tryNextAvailableAdWithRateLimit()
7884
- ];
7885
- case 21:
7886
- _state.sent();
7887
- return [
7888
- 3,
7889
- 22
7890
- ];
7891
- case 22:
7892
7138
  return [
7893
7139
  2
7894
7140
  ];
@@ -7962,7 +7208,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7962
7208
  ];
7963
7209
  }
7964
7210
  if (this.debug) {
7965
- 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"));
7211
+ 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"));
7966
7212
  }
7967
7213
  sendAdLoadedTracking(this.host.config.licenseKey, {
7968
7214
  source: "hls",
@@ -7982,13 +7228,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7982
7228
  }
7983
7229
  adPlayer.setAdVolume(currentMuted ? 0 : currentVolume);
7984
7230
  this.timing.consecutiveFailures = 0;
7985
- if (podCount === 1) {
7986
- this.continuousFetchingActive = true;
7987
- this.startContinuousFetching(baseVastUrl);
7988
- if (!this.preloadPool.active) {
7989
- this.preloadPool.startPreloadPool(baseVastUrl, []);
7990
- }
7991
- }
7231
+ this.continuousFetchingActive = true;
7232
+ this.startContinuousFetching(baseVastUrl);
7992
7233
  return [
7993
7234
  2,
7994
7235
  true
@@ -8021,20 +7262,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8021
7262
  }).call(this);
8022
7263
  }
8023
7264
  },
8024
- {
8025
- key: "swapToPreloadedAdPlayer",
8026
- value: function swapToPreloadedAdPlayer(preloadedController) {
8027
- var adPlayer = this.host.getAdPlayer();
8028
- var preservedMuted = adPlayer.getOriginalMutedState();
8029
- var preservedVolume = adPlayer.getOriginalVolume();
8030
- adPlayer.destroy();
8031
- this.host.video.muted = true;
8032
- this.host.setAdPlayer(preloadedController);
8033
- this.attachImaEventListeners();
8034
- preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
8035
- preloadedController.resume();
8036
- }
8037
- },
8038
7265
  {
8039
7266
  // ───────────────────────────────────────────────────────────────
8040
7267
  // Continuous fetching
@@ -8128,7 +7355,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8128
7355
  "continue"
8129
7356
  ];
8130
7357
  case 2:
8131
- newAdUrl = _this.host.generateVastUrls(baseVastUrl, 1)[0];
7358
+ newAdUrl = _this.nextAdRequestUrl(baseVastUrl);
8132
7359
  if (!(!newAdUrl || _this.timing.failedVastUrls.has(newAdUrl) || _this.timing.isUrlInCooldown(newAdUrl))) return [
8133
7360
  3,
8134
7361
  4
@@ -8285,7 +7512,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8285
7512
  value: function tryNextAvailableAd() {
8286
7513
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
8287
7514
  return _async_to_generator(function() {
8288
- var remaining, preloaded, ap, error, nextAdUrl, error1, errorMessage, maxRetries;
7515
+ var remaining, nextAdUrl, error, errorMessage, maxRetries;
8289
7516
  return _ts_generator(this, function(_state) {
8290
7517
  switch(_state.label){
8291
7518
  case 0:
@@ -8323,132 +7550,71 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8323
7550
  ];
8324
7551
  }
8325
7552
  this.timing.cleanupTemporaryFailures();
8326
- preloaded = this.preloadPool.getPreloadedAd();
8327
- if (!preloaded) return [
8328
- 3,
8329
- 6
8330
- ];
8331
- if (this.debug) {
8332
- console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool");
8333
- }
8334
- sendAdLoadedTracking(this.host.config.licenseKey, {
8335
- source: "hls",
8336
- vastUrl: preloaded.vastUrl,
8337
- timestamp: /* @__PURE__ */ new Date().toISOString()
8338
- }, this.analyticsContext).catch(function() {});
8339
7553
  _state.label = 1;
8340
7554
  case 1:
8341
- _state.trys.push([
8342
- 1,
8343
- 5,
8344
- ,
8345
- 6
8346
- ]);
8347
- if (!!this.timing.ensureLoadedAdFitsBudget(preloaded.adController)) return [
8348
- 3,
8349
- 3
8350
- ];
8351
- this.timing.rejectLoadedAdForDuration(preloaded.adController);
8352
- return [
8353
- 4,
8354
- this.tryNextAvailableAdWithRateLimit()
8355
- ];
8356
- case 2:
8357
- _state.sent();
8358
- return [
8359
- 2
8360
- ];
8361
- case 3:
8362
- this.swapToPreloadedAdPlayer(preloaded.adController);
8363
- ap = this.host.getAdPlayer();
8364
- return [
8365
- 4,
8366
- ap.play()
8367
- ];
8368
- case 4:
8369
- _state.sent();
8370
- this.timing.markAdStarted();
8371
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
8372
- this.timing.scheduleAdStopAtBreakBoundary();
8373
- }
8374
- ap.setAdVolume(getAdAudioVolume(ap));
8375
- this.timing.consecutiveFailures = 0;
8376
- return [
8377
- 2
8378
- ];
8379
- case 5:
8380
- error = _state.sent();
8381
- if (this.debug) {
8382
- console.warn("[CONTINUOUS-FETCH] Preloaded ad failed to play:", error);
8383
- }
8384
- return [
8385
- 3,
8386
- 6
8387
- ];
8388
- case 6:
8389
7555
  if (!(this.adRequestQueue.length > 0)) return [
8390
7556
  3,
8391
- 14
7557
+ 9
8392
7558
  ];
8393
7559
  nextAdUrl = this.adRequestQueue.shift();
8394
7560
  if (!nextAdUrl) return [
8395
7561
  3,
8396
- 6
7562
+ 1
8397
7563
  ];
8398
7564
  if (this.timing.failedVastUrls.has(nextAdUrl)) {
8399
7565
  if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping permanently-failed URL, trying next...");
8400
7566
  return [
8401
7567
  3,
8402
- 6
7568
+ 1
8403
7569
  ];
8404
7570
  }
8405
7571
  if (this.timing.isUrlInCooldown(nextAdUrl)) {
8406
7572
  if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping URL in cooldown (recent no-fill), trying next...");
8407
7573
  return [
8408
7574
  3,
8409
- 6
7575
+ 1
8410
7576
  ];
8411
7577
  }
8412
7578
  if (this.debug) {
8413
7579
  console.log("[CONTINUOUS-FETCH] Requesting next ad via HLS ad player (".concat(this.timing.currentAdIndex + 1, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
8414
7580
  }
8415
- _state.label = 7;
8416
- case 7:
7581
+ _state.label = 2;
7582
+ case 2:
8417
7583
  _state.trys.push([
8418
- 7,
8419
- 9,
7584
+ 2,
7585
+ 4,
8420
7586
  ,
8421
- 13
7587
+ 8
8422
7588
  ]);
8423
7589
  return [
8424
7590
  4,
8425
7591
  this.playSingleAd(nextAdUrl)
8426
7592
  ];
8427
- case 8:
7593
+ case 3:
8428
7594
  _state.sent();
8429
7595
  this.timing.consecutiveFailures = 0;
8430
7596
  return [
8431
7597
  3,
8432
- 13
7598
+ 8
8433
7599
  ];
8434
- case 9:
8435
- error1 = _state.sent();
8436
- errorMessage = error1.message;
7600
+ case 4:
7601
+ error = _state.sent();
7602
+ errorMessage = error.message;
8437
7603
  if (this.debug) console.log("[CONTINUOUS-FETCH] Ad request failed:", errorMessage);
8438
7604
  if (!errorMessage.includes("ad_duration_exceeds_budget")) return [
8439
7605
  3,
8440
- 11
7606
+ 6
8441
7607
  ];
8442
7608
  return [
8443
7609
  4,
8444
7610
  this.tryNextAvailableAdWithRateLimit()
8445
7611
  ];
8446
- case 10:
7612
+ case 5:
8447
7613
  _state.sent();
8448
7614
  return [
8449
7615
  2
8450
7616
  ];
8451
- case 11:
7617
+ case 6:
8452
7618
  if (!errorMessage.includes("permanently failed") && !errorMessage.includes("in cooldown")) {
8453
7619
  this.timing.consecutiveFailures++;
8454
7620
  }
@@ -8456,21 +7622,21 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8456
7622
  4,
8457
7623
  this.tryNextAvailableAdWithRateLimit()
8458
7624
  ];
8459
- case 12:
7625
+ case 7:
8460
7626
  _state.sent();
8461
7627
  return [
8462
7628
  3,
8463
- 13
7629
+ 8
8464
7630
  ];
8465
- case 13:
7631
+ case 8:
8466
7632
  return [
8467
7633
  2
8468
7634
  ];
8469
- case 14:
7635
+ case 9:
8470
7636
  maxRetries = 3;
8471
7637
  if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
8472
7638
  3,
8473
- 17
7639
+ 12
8474
7640
  ];
8475
7641
  if (this.debug) {
8476
7642
  console.log("[CONTINUOUS-FETCH] Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
@@ -8481,18 +7647,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8481
7647
  return setTimeout(resolve, 500);
8482
7648
  })
8483
7649
  ];
8484
- case 15:
7650
+ case 10:
8485
7651
  _state.sent();
8486
7652
  return [
8487
7653
  4,
8488
7654
  this.tryNextAvailableAd(retryCount + 1)
8489
7655
  ];
8490
- case 16:
7656
+ case 11:
8491
7657
  _state.sent();
8492
7658
  return [
8493
7659
  2
8494
7660
  ];
8495
- case 17:
7661
+ case 12:
8496
7662
  if (!this.isShowingPlaceholder && remaining > 1e3) {
8497
7663
  this.showPlaceholderAndWaitForAds();
8498
7664
  } else {
@@ -8514,7 +7680,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8514
7680
  // ───────────────────────────────────────────────────────────────
8515
7681
  function playSingleAd(vastTagUrl) {
8516
7682
  return _async_to_generator(function() {
8517
- var adPlayer, requestToken, ap, playError, preloadedFallback, fbAp, fallbackError, error, errorMessage, preloadedFallback1, fbAp1, fallbackError1;
7683
+ var adPlayer, requestToken, ap, playError, error, errorMessage;
8518
7684
  return _ts_generator(this, function(_state) {
8519
7685
  switch(_state.label){
8520
7686
  case 0:
@@ -8546,9 +7712,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8546
7712
  case 1:
8547
7713
  _state.trys.push([
8548
7714
  1,
8549
- 12,
7715
+ 8,
8550
7716
  ,
8551
- 17
7717
+ 9
8552
7718
  ]);
8553
7719
  return [
8554
7720
  4,
@@ -8584,7 +7750,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8584
7750
  4,
8585
7751
  6,
8586
7752
  ,
8587
- 11
7753
+ 7
8588
7754
  ]);
8589
7755
  this.timing.startAdFailsafeTimer(requestToken);
8590
7756
  return [
@@ -8602,55 +7768,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8602
7768
  this.timing.temporaryFailureUrls.delete(vastTagUrl);
8603
7769
  return [
8604
7770
  3,
8605
- 11
7771
+ 7
8606
7772
  ];
8607
7773
  case 6:
8608
7774
  playError = _state.sent();
8609
7775
  if (this.debug) console.error("[AD-ERROR] Failed to play ad:", playError);
8610
- preloadedFallback = this.preloadPool.getPreloadedAd();
8611
- if (!preloadedFallback) return [
8612
- 3,
8613
- 10
8614
- ];
8615
- if (this.debug) console.log("[AD-ERROR] Play failed, trying preloaded fallback ad");
8616
- _state.label = 7;
8617
- case 7:
8618
- _state.trys.push([
8619
- 7,
8620
- 9,
8621
- ,
8622
- 10
8623
- ]);
8624
- if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback.adController)) {
8625
- this.timing.rejectLoadedAdForDuration(preloadedFallback.adController);
8626
- throw playError;
8627
- }
8628
- this.timing.clearAdFailsafeTimer();
8629
- this.swapToPreloadedAdPlayer(preloadedFallback.adController);
8630
- this.timing.consecutiveFailures = 0;
8631
- fbAp = this.host.getAdPlayer();
8632
- return [
8633
- 4,
8634
- fbAp.play()
8635
- ];
8636
- case 8:
8637
- _state.sent();
8638
- this.timing.markAdStarted();
8639
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
8640
- this.timing.scheduleAdStopAtBreakBoundary();
8641
- }
8642
- fbAp.setAdVolume(getAdAudioVolume(fbAp));
8643
- return [
8644
- 2
8645
- ];
8646
- case 9:
8647
- fallbackError = _state.sent();
8648
- if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError);
8649
- return [
8650
- 3,
8651
- 10
8652
- ];
8653
- case 10:
8654
7776
  if (this.timing.isTemporaryAdError(playError)) {
8655
7777
  this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
8656
7778
  if (this.debug) console.log("[AD-ERROR] Temporary play error - URL can be retried after cooldown");
@@ -8663,57 +7785,15 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8663
7785
  this.timing.activeAdRequestToken = null;
8664
7786
  }
8665
7787
  throw playError;
8666
- case 11:
7788
+ case 7:
8667
7789
  return [
8668
7790
  3,
8669
- 17
7791
+ 9
8670
7792
  ];
8671
- case 12:
7793
+ case 8:
8672
7794
  error = _state.sent();
8673
7795
  errorMessage = (error === null || error === void 0 ? void 0 : error.message) || "";
8674
7796
  if (this.debug) console.error("[AD-ERROR] Ad request failed:", errorMessage);
8675
- preloadedFallback1 = this.preloadPool.getPreloadedAd();
8676
- if (!preloadedFallback1) return [
8677
- 3,
8678
- 16
8679
- ];
8680
- if (this.debug) console.log("[AD-ERROR] Request failed, trying preloaded fallback ad");
8681
- _state.label = 13;
8682
- case 13:
8683
- _state.trys.push([
8684
- 13,
8685
- 15,
8686
- ,
8687
- 16
8688
- ]);
8689
- if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback1.adController)) {
8690
- this.timing.rejectLoadedAdForDuration(preloadedFallback1.adController);
8691
- throw error;
8692
- }
8693
- this.timing.clearAdRequestWatchdog();
8694
- this.timing.clearAdFailsafeTimer();
8695
- this.swapToPreloadedAdPlayer(preloadedFallback1.adController);
8696
- this.timing.consecutiveFailures = 0;
8697
- fbAp1 = this.host.getAdPlayer();
8698
- return [
8699
- 4,
8700
- fbAp1.play()
8701
- ];
8702
- case 14:
8703
- _state.sent();
8704
- this.timing.markAdStarted();
8705
- fbAp1.setAdVolume(getAdAudioVolume(fbAp1));
8706
- return [
8707
- 2
8708
- ];
8709
- case 15:
8710
- fallbackError1 = _state.sent();
8711
- if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError1);
8712
- return [
8713
- 3,
8714
- 16
8715
- ];
8716
- case 16:
8717
7797
  if (this.timing.isTemporaryAdError(error)) {
8718
7798
  this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
8719
7799
  if (this.debug) console.log("[AD-ERROR] Temporary error (no-fill/timeout) - URL can be retried after cooldown");
@@ -8727,7 +7807,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8727
7807
  this.timing.activeAdRequestToken = null;
8728
7808
  }
8729
7809
  throw error;
8730
- case 17:
7810
+ case 9:
8731
7811
  return [
8732
7812
  2
8733
7813
  ];
@@ -8917,7 +7997,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8917
7997
  }
8918
7998
  this.timing.resetForBreakEnd();
8919
7999
  this.stopContinuousFetching();
8920
- this.preloadPool.stop();
8921
8000
  this.clearPendingAdBreak();
8922
8001
  if (this.isShowingPlaceholder) {
8923
8002
  this.host.getAdPlayer().hidePlaceholder();
@@ -9027,25 +8106,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9027
8106
  return _this.adBreak.handleAdFailure();
9028
8107
  }
9029
8108
  });
9030
- this.preloadPool = new AdPreloadPool({
9031
- debug: !!this.config.debugAdTiming,
9032
- createAdPlayer: function createAdPlayer(c) {
9033
- return _this.createAdPlayer(c);
9034
- },
9035
- shouldContinueLiveStreamDuringAds: function shouldContinueLiveStreamDuringAds() {
9036
- return _this.shouldContinueLiveStreamDuringAds();
9037
- },
9038
- timing: this.timing,
9039
- generateVastUrlsWithCorrelators: function generateVastUrlsWithCorrelators(base, count) {
9040
- return _this.generateVastUrls(base, count);
9041
- },
9042
- isInAdBreak: function isInAdBreak() {
9043
- return _this.adBreak.inAdBreak;
9044
- },
9045
- getPendingAdBreak: function getPendingAdBreak() {
9046
- return _this.adBreak.pendingAdBreak;
9047
- }
9048
- });
9049
8109
  this.placeholder = new PlaceholderLayer(this.video, !!this.config.debugAdTiming);
9050
8110
  this.hlsEngine = new HlsEngine(this.config, this.video, this.cueManager, this.timing, {
9051
8111
  onManifestParsed: function onManifestParsed(isLive) {
@@ -9092,13 +8152,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9092
8152
  getLiveSyncPosition: function getLiveSyncPosition() {
9093
8153
  return _this.hlsEngine.getLiveSyncPosition();
9094
8154
  },
9095
- generateVastUrls: function generateVastUrls(base, count) {
9096
- return _this.generateVastUrls(base, count);
9097
- },
9098
8155
  generatePodVastUrl: function generatePodVastUrl(base, breakDurationMs) {
9099
8156
  return _this.generatePodVastUrl(base, breakDurationMs);
9100
8157
  }
9101
- }, this.timing, this.preloadPool, this.adConfig, this.cueManager, this.placeholder);
8158
+ }, this.timing, this.adConfig, this.cueManager, this.placeholder);
9102
8159
  }
9103
8160
  _create_class(StormcloudVideoPlayer, [
9104
8161
  {
@@ -9123,12 +8180,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9123
8180
  } : {}));
9124
8181
  }
9125
8182
  },
9126
- {
9127
- key: "generateVastUrls",
9128
- value: function generateVastUrls(baseUrl, count) {
9129
- return this.adConfig.generateVastUrlsWithCorrelators(baseUrl, count, this.adPlayer, this.palNonce, this.adBreak.inAdBreak);
9130
- }
9131
- },
9132
8183
  {
9133
8184
  key: "generatePodVastUrl",
9134
8185
  value: function generatePodVastUrl(baseUrl, breakDurationMs) {
@@ -9524,11 +8575,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9524
8575
  }
9525
8576
  this.adConfig.beginNewAdPod();
9526
8577
  this.adConfig.podAssignedByPrefetch = true;
9527
- var optimizedPods = this.config.optimizedPods !== false;
9528
8578
  var breakDurationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : void 0;
9529
- var generatedUrls = optimizedPods ? [
8579
+ var generatedUrls = [
9530
8580
  this.generatePodVastUrl(baseVastUrl, breakDurationMs)
9531
- ] : this.generateVastUrls(baseVastUrl, 1);
8581
+ ];
9532
8582
  this.adBreak.pendingAdBreak = _object_spread_props(_object_spread({
9533
8583
  marker: marker
9534
8584
  }, fragmentSn !== void 0 ? {
@@ -9550,15 +8600,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9550
8600
  }, detectPayload), buildAnalyticsContext(this.config)).catch(function() {});
9551
8601
  if (this.debug) {
9552
8602
  console.log("[PREFETCH] Starting ad prefetch for upcoming ad break");
9553
- console.log("[PREFETCH] Pre-generated ".concat(generatedUrls.length, " ").concat(optimizedPods ? "pod" : "VAST", " URL(s)"));
9554
- }
9555
- if (optimizedPods) {
9556
- if (this.debug) {
9557
- console.log("[PREFETCH] Optimized pods enabled - skipping single-ad preload pool");
9558
- }
9559
- return;
8603
+ console.log("[PREFETCH] Pre-generated pod request URL");
9560
8604
  }
9561
- this.preloadPool.startPreloadPool(baseVastUrl, generatedUrls.slice(0, 1), false);
9562
8605
  }
9563
8606
  },
9564
8607
  {
@@ -9797,7 +8840,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9797
8840
  value: function destroy() {
9798
8841
  var _this_adPlayer;
9799
8842
  this.adBreak.stopContinuousFetching();
9800
- this.preloadPool.stop();
9801
8843
  this.timing.destroy();
9802
8844
  this.adBreak.clearPendingAdBreak();
9803
8845
  this.placeholder.destroy();