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
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,23 +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;
7388
- }
7389
- },
7390
- {
7391
- key: "nextAdRequestUrl",
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",
7392
6893
  value: function nextAdRequestUrl(baseVastUrl) {
7393
- if (this.optimizedPodsEnabled) {
7394
- var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
7395
- var breakDurationMs = remaining > 0 ? remaining : void 0;
7396
- return this.host.generatePodVastUrl(baseVastUrl, breakDurationMs);
7397
- }
7398
- return this.host.generateVastUrls(baseVastUrl, 1)[0];
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);
7399
6897
  }
7400
6898
  },
7401
6899
  {
@@ -7567,7 +7065,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7567
7065
  // ───────────────────────────────────────────────────────────────
7568
7066
  function handleAdStart(_marker) {
7569
7067
  return _async_to_generator(function() {
7570
- var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, podPlayed, firstAdUrl, usePreloadedAd, preloadedController, preloaded, adPlayer, preservedMuted, preservedVolume, adVolume, adPlayer1, adVolume1, error, fallbackPreloaded, ap, adVolume2, fallbackError;
7068
+ var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, podPlayed;
7571
7069
  return _ts_generator(this, function(_state) {
7572
7070
  switch(_state.label){
7573
7071
  case 0:
@@ -7614,293 +7112,29 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7614
7112
  if (this.timing.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
7615
7113
  this.timing.expectedAdBreakDurationMs = adBreakDurationMs;
7616
7114
  }
7617
- if (!this.optimizedPodsEnabled) return [
7618
- 3,
7619
- 2
7620
- ];
7621
7115
  return [
7622
7116
  4,
7623
7117
  this.startOptimizedPod(baseVastUrl, adBreakDurationMs, currentMuted, currentVolume)
7624
7118
  ];
7625
7119
  case 1:
7626
7120
  podPlayed = _state.sent();
7627
- if (podPlayed) {
7628
- return [
7629
- 2
7630
- ];
7631
- }
7121
+ if (!!podPlayed) return [
7122
+ 3,
7123
+ 3
7124
+ ];
7632
7125
  if (this.debug) {
7633
- 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");
7634
7127
  }
7635
- _state.label = 2;
7128
+ this.continuousFetchingActive = true;
7129
+ this.startContinuousFetching(baseVastUrl);
7130
+ return [
7131
+ 4,
7132
+ this.tryNextAvailableAdWithRateLimit()
7133
+ ];
7636
7134
  case 2:
7637
- usePreloadedAd = false;
7638
- preloaded = this.preloadPool.getPreloadedAd();
7639
- if (preloaded) {
7640
- firstAdUrl = preloaded.vastUrl;
7641
- preloadedController = preloaded.adController;
7642
- usePreloadedAd = true;
7643
- sendAdLoadedTracking(this.host.config.licenseKey, {
7644
- source: "hls",
7645
- vastUrl: firstAdUrl,
7646
- timestamp: /* @__PURE__ */ new Date().toISOString()
7647
- }, this.analyticsContext).catch(function() {});
7648
- if (this.debug) {
7649
- console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool (preloaded in advance, ready immediately!)");
7650
- }
7651
- } else if (this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0) {
7652
- this.adRequestQueue = _to_consumable_array(this.pendingAdBreak.vastUrls);
7653
- firstAdUrl = this.adRequestQueue.shift();
7654
- if (this.debug) {
7655
- console.log("[CONTINUOUS-FETCH] Pool empty, using prefetched URLs (".concat(this.adRequestQueue.length + 1, " available)"));
7656
- }
7657
- this.clearPendingAdBreak();
7658
- } else {
7659
- if (this.debug) {
7660
- console.log("[CONTINUOUS-FETCH] Generating new ad URLs...");
7661
- }
7662
- firstAdUrl = this.nextAdRequestUrl(baseVastUrl);
7663
- this.adRequestQueue = [];
7664
- }
7665
- if (!firstAdUrl) {
7666
- if (this.debug) {
7667
- console.warn("[CONTINUOUS-FETCH] Failed to get first ad URL");
7668
- }
7669
- this.handleAdPodComplete();
7670
- return [
7671
- 2
7672
- ];
7673
- }
7674
- if (this.debug) {
7675
- console.log("[CONTINUOUS-FETCH] First VAST URL:", firstAdUrl);
7676
- }
7135
+ _state.sent();
7677
7136
  _state.label = 3;
7678
7137
  case 3:
7679
- _state.trys.push([
7680
- 3,
7681
- 14,
7682
- ,
7683
- 22
7684
- ]);
7685
- if (!(usePreloadedAd && preloadedController)) return [
7686
- 3,
7687
- 7
7688
- ];
7689
- if (!!this.timing.ensureLoadedAdFitsBudget(preloadedController)) return [
7690
- 3,
7691
- 5
7692
- ];
7693
- this.timing.rejectLoadedAdForDuration(preloadedController);
7694
- this.startContinuousFetching(baseVastUrl);
7695
- return [
7696
- 4,
7697
- this.tryNextAvailableAdWithRateLimit()
7698
- ];
7699
- case 4:
7700
- _state.sent();
7701
- return [
7702
- 2
7703
- ];
7704
- case 5:
7705
- adPlayer = this.host.getAdPlayer();
7706
- preservedMuted = adPlayer.getOriginalMutedState();
7707
- preservedVolume = adPlayer.getOriginalVolume();
7708
- adPlayer.destroy();
7709
- this.host.video.muted = true;
7710
- this.host.setAdPlayer(preloadedController);
7711
- preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
7712
- this.attachImaEventListeners();
7713
- if (this.debug) {
7714
- console.log("[CONTINUOUS-FETCH] Using preloaded ad, resuming and starting playback immediately (no request delay!)");
7715
- }
7716
- preloadedController.resume();
7717
- this.timing.consecutiveFailures = 0;
7718
- this.startContinuousFetching(baseVastUrl);
7719
- if (!this.optimizedPodsEnabled) {
7720
- if (!this.preloadPool.active) {
7721
- this.preloadPool.active = true;
7722
- }
7723
- if (!this.preloadPool.isLoopRunning) {
7724
- this.preloadPool.preloadPoolLoop(baseVastUrl);
7725
- }
7726
- }
7727
- return [
7728
- 4,
7729
- preloadedController.play()
7730
- ];
7731
- case 6:
7732
- _state.sent();
7733
- this.timing.markAdStarted();
7734
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7735
- this.timing.scheduleAdStopAtBreakBoundary();
7736
- }
7737
- adVolume = currentMuted ? 0 : currentVolume;
7738
- preloadedController.setAdVolume(adVolume);
7739
- return [
7740
- 3,
7741
- 13
7742
- ];
7743
- case 7:
7744
- adPlayer1 = this.host.getAdPlayer();
7745
- return [
7746
- 4,
7747
- this.timing.enforceGlobalRateLimit()
7748
- ];
7749
- case 8:
7750
- _state.sent();
7751
- this.timing.lastAdRequestTime = Date.now();
7752
- return [
7753
- 4,
7754
- adPlayer1.requestAds(firstAdUrl)
7755
- ];
7756
- case 9:
7757
- _state.sent();
7758
- sendAdLoadedTracking(this.host.config.licenseKey, {
7759
- source: "hls",
7760
- vastUrl: firstAdUrl,
7761
- timestamp: /* @__PURE__ */ new Date().toISOString()
7762
- }, this.analyticsContext).catch(function() {});
7763
- if (this.debug) {
7764
- console.log("[CONTINUOUS-FETCH] First ad request successful, starting playback");
7765
- }
7766
- if (!!this.timing.ensureLoadedAdFitsBudget(adPlayer1)) return [
7767
- 3,
7768
- 11
7769
- ];
7770
- this.timing.rejectLoadedAdForDuration(adPlayer1);
7771
- this.recreateAdController();
7772
- this.startContinuousFetching(baseVastUrl);
7773
- return [
7774
- 4,
7775
- this.tryNextAvailableAdWithRateLimit()
7776
- ];
7777
- case 10:
7778
- _state.sent();
7779
- return [
7780
- 2
7781
- ];
7782
- case 11:
7783
- this.timing.consecutiveFailures = 0;
7784
- this.startContinuousFetching(baseVastUrl);
7785
- if (!this.optimizedPodsEnabled && !this.preloadPool.active) {
7786
- this.preloadPool.startPreloadPool(baseVastUrl, []);
7787
- }
7788
- return [
7789
- 4,
7790
- adPlayer1.play()
7791
- ];
7792
- case 12:
7793
- _state.sent();
7794
- this.timing.markAdStarted();
7795
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7796
- this.timing.scheduleAdStopAtBreakBoundary();
7797
- }
7798
- adVolume1 = currentMuted ? 0 : currentVolume;
7799
- adPlayer1.setAdVolume(adVolume1);
7800
- _state.label = 13;
7801
- case 13:
7802
- return [
7803
- 3,
7804
- 22
7805
- ];
7806
- case 14:
7807
- error = _state.sent();
7808
- if (this.debug) {
7809
- console.warn("[CONTINUOUS-FETCH] First ad request failed:", error);
7810
- }
7811
- if (!!usePreloadedAd) return [
7812
- 3,
7813
- 20
7814
- ];
7815
- fallbackPreloaded = this.preloadPool.getPreloadedAd();
7816
- if (!fallbackPreloaded) return [
7817
- 3,
7818
- 20
7819
- ];
7820
- if (this.debug) {
7821
- console.log("[CONTINUOUS-FETCH] First ad failed, using preloaded fallback");
7822
- }
7823
- _state.label = 15;
7824
- case 15:
7825
- _state.trys.push([
7826
- 15,
7827
- 19,
7828
- ,
7829
- 20
7830
- ]);
7831
- if (!!this.timing.ensureLoadedAdFitsBudget(fallbackPreloaded.adController)) return [
7832
- 3,
7833
- 17
7834
- ];
7835
- this.timing.rejectLoadedAdForDuration(fallbackPreloaded.adController);
7836
- this.startContinuousFetching(baseVastUrl);
7837
- return [
7838
- 4,
7839
- this.tryNextAvailableAdWithRateLimit()
7840
- ];
7841
- case 16:
7842
- _state.sent();
7843
- return [
7844
- 2
7845
- ];
7846
- case 17:
7847
- this.swapToPreloadedAdPlayer(fallbackPreloaded.adController);
7848
- this.timing.consecutiveFailures = 0;
7849
- this.startContinuousFetching(baseVastUrl);
7850
- if (!this.optimizedPodsEnabled && !this.preloadPool.active) {
7851
- this.preloadPool.active = true;
7852
- this.preloadPool.preloadPoolLoop(baseVastUrl);
7853
- }
7854
- ap = this.host.getAdPlayer();
7855
- return [
7856
- 4,
7857
- ap.play()
7858
- ];
7859
- case 18:
7860
- _state.sent();
7861
- this.timing.markAdStarted();
7862
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7863
- this.timing.scheduleAdStopAtBreakBoundary();
7864
- }
7865
- adVolume2 = currentMuted ? 0 : currentVolume;
7866
- ap.setAdVolume(adVolume2);
7867
- return [
7868
- 2
7869
- ];
7870
- case 19:
7871
- fallbackError = _state.sent();
7872
- if (this.debug) {
7873
- console.warn("[CONTINUOUS-FETCH] Preloaded fallback also failed:", fallbackError);
7874
- }
7875
- return [
7876
- 3,
7877
- 20
7878
- ];
7879
- case 20:
7880
- if (this.timing.isTemporaryAdError(error)) {
7881
- this.timing.temporaryFailureUrls.set(firstAdUrl, Date.now());
7882
- if (this.debug) {
7883
- console.log("[CONTINUOUS-FETCH] First ad had temporary error (no-fill) - will try alternatives");
7884
- }
7885
- } else {
7886
- this.timing.failedVastUrls.add(firstAdUrl);
7887
- if (this.debug) {
7888
- console.log("[CONTINUOUS-FETCH] First ad had permanent error - URL blacklisted");
7889
- }
7890
- }
7891
- this.timing.consecutiveFailures++;
7892
- this.startContinuousFetching(baseVastUrl);
7893
- return [
7894
- 4,
7895
- this.tryNextAvailableAdWithRateLimit()
7896
- ];
7897
- case 21:
7898
- _state.sent();
7899
- return [
7900
- 3,
7901
- 22
7902
- ];
7903
- case 22:
7904
7138
  return [
7905
7139
  2
7906
7140
  ];
@@ -7974,7 +7208,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7974
7208
  ];
7975
7209
  }
7976
7210
  if (this.debug) {
7977
- 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"));
7978
7212
  }
7979
7213
  sendAdLoadedTracking(this.host.config.licenseKey, {
7980
7214
  source: "hls",
@@ -7994,10 +7228,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7994
7228
  }
7995
7229
  adPlayer.setAdVolume(currentMuted ? 0 : currentVolume);
7996
7230
  this.timing.consecutiveFailures = 0;
7997
- if (podCount === 1) {
7998
- this.continuousFetchingActive = true;
7999
- this.startContinuousFetching(baseVastUrl);
8000
- }
7231
+ this.continuousFetchingActive = true;
7232
+ this.startContinuousFetching(baseVastUrl);
8001
7233
  return [
8002
7234
  2,
8003
7235
  true
@@ -8030,20 +7262,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8030
7262
  }).call(this);
8031
7263
  }
8032
7264
  },
8033
- {
8034
- key: "swapToPreloadedAdPlayer",
8035
- value: function swapToPreloadedAdPlayer(preloadedController) {
8036
- var adPlayer = this.host.getAdPlayer();
8037
- var preservedMuted = adPlayer.getOriginalMutedState();
8038
- var preservedVolume = adPlayer.getOriginalVolume();
8039
- adPlayer.destroy();
8040
- this.host.video.muted = true;
8041
- this.host.setAdPlayer(preloadedController);
8042
- this.attachImaEventListeners();
8043
- preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
8044
- preloadedController.resume();
8045
- }
8046
- },
8047
7265
  {
8048
7266
  // ───────────────────────────────────────────────────────────────
8049
7267
  // Continuous fetching
@@ -8294,7 +7512,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8294
7512
  value: function tryNextAvailableAd() {
8295
7513
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
8296
7514
  return _async_to_generator(function() {
8297
- var remaining, preloaded, ap, error, nextAdUrl, error1, errorMessage, maxRetries;
7515
+ var remaining, nextAdUrl, error, errorMessage, maxRetries;
8298
7516
  return _ts_generator(this, function(_state) {
8299
7517
  switch(_state.label){
8300
7518
  case 0:
@@ -8332,132 +7550,71 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8332
7550
  ];
8333
7551
  }
8334
7552
  this.timing.cleanupTemporaryFailures();
8335
- preloaded = this.preloadPool.getPreloadedAd();
8336
- if (!preloaded) return [
8337
- 3,
8338
- 6
8339
- ];
8340
- if (this.debug) {
8341
- console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool");
8342
- }
8343
- sendAdLoadedTracking(this.host.config.licenseKey, {
8344
- source: "hls",
8345
- vastUrl: preloaded.vastUrl,
8346
- timestamp: /* @__PURE__ */ new Date().toISOString()
8347
- }, this.analyticsContext).catch(function() {});
8348
7553
  _state.label = 1;
8349
7554
  case 1:
8350
- _state.trys.push([
8351
- 1,
8352
- 5,
8353
- ,
8354
- 6
8355
- ]);
8356
- if (!!this.timing.ensureLoadedAdFitsBudget(preloaded.adController)) return [
8357
- 3,
8358
- 3
8359
- ];
8360
- this.timing.rejectLoadedAdForDuration(preloaded.adController);
8361
- return [
8362
- 4,
8363
- this.tryNextAvailableAdWithRateLimit()
8364
- ];
8365
- case 2:
8366
- _state.sent();
8367
- return [
8368
- 2
8369
- ];
8370
- case 3:
8371
- this.swapToPreloadedAdPlayer(preloaded.adController);
8372
- ap = this.host.getAdPlayer();
8373
- return [
8374
- 4,
8375
- ap.play()
8376
- ];
8377
- case 4:
8378
- _state.sent();
8379
- this.timing.markAdStarted();
8380
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
8381
- this.timing.scheduleAdStopAtBreakBoundary();
8382
- }
8383
- ap.setAdVolume(getAdAudioVolume(ap));
8384
- this.timing.consecutiveFailures = 0;
8385
- return [
8386
- 2
8387
- ];
8388
- case 5:
8389
- error = _state.sent();
8390
- if (this.debug) {
8391
- console.warn("[CONTINUOUS-FETCH] Preloaded ad failed to play:", error);
8392
- }
8393
- return [
8394
- 3,
8395
- 6
8396
- ];
8397
- case 6:
8398
7555
  if (!(this.adRequestQueue.length > 0)) return [
8399
7556
  3,
8400
- 14
7557
+ 9
8401
7558
  ];
8402
7559
  nextAdUrl = this.adRequestQueue.shift();
8403
7560
  if (!nextAdUrl) return [
8404
7561
  3,
8405
- 6
7562
+ 1
8406
7563
  ];
8407
7564
  if (this.timing.failedVastUrls.has(nextAdUrl)) {
8408
7565
  if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping permanently-failed URL, trying next...");
8409
7566
  return [
8410
7567
  3,
8411
- 6
7568
+ 1
8412
7569
  ];
8413
7570
  }
8414
7571
  if (this.timing.isUrlInCooldown(nextAdUrl)) {
8415
7572
  if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping URL in cooldown (recent no-fill), trying next...");
8416
7573
  return [
8417
7574
  3,
8418
- 6
7575
+ 1
8419
7576
  ];
8420
7577
  }
8421
7578
  if (this.debug) {
8422
7579
  console.log("[CONTINUOUS-FETCH] Requesting next ad via HLS ad player (".concat(this.timing.currentAdIndex + 1, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
8423
7580
  }
8424
- _state.label = 7;
8425
- case 7:
7581
+ _state.label = 2;
7582
+ case 2:
8426
7583
  _state.trys.push([
8427
- 7,
8428
- 9,
7584
+ 2,
7585
+ 4,
8429
7586
  ,
8430
- 13
7587
+ 8
8431
7588
  ]);
8432
7589
  return [
8433
7590
  4,
8434
7591
  this.playSingleAd(nextAdUrl)
8435
7592
  ];
8436
- case 8:
7593
+ case 3:
8437
7594
  _state.sent();
8438
7595
  this.timing.consecutiveFailures = 0;
8439
7596
  return [
8440
7597
  3,
8441
- 13
7598
+ 8
8442
7599
  ];
8443
- case 9:
8444
- error1 = _state.sent();
8445
- errorMessage = error1.message;
7600
+ case 4:
7601
+ error = _state.sent();
7602
+ errorMessage = error.message;
8446
7603
  if (this.debug) console.log("[CONTINUOUS-FETCH] Ad request failed:", errorMessage);
8447
7604
  if (!errorMessage.includes("ad_duration_exceeds_budget")) return [
8448
7605
  3,
8449
- 11
7606
+ 6
8450
7607
  ];
8451
7608
  return [
8452
7609
  4,
8453
7610
  this.tryNextAvailableAdWithRateLimit()
8454
7611
  ];
8455
- case 10:
7612
+ case 5:
8456
7613
  _state.sent();
8457
7614
  return [
8458
7615
  2
8459
7616
  ];
8460
- case 11:
7617
+ case 6:
8461
7618
  if (!errorMessage.includes("permanently failed") && !errorMessage.includes("in cooldown")) {
8462
7619
  this.timing.consecutiveFailures++;
8463
7620
  }
@@ -8465,21 +7622,21 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8465
7622
  4,
8466
7623
  this.tryNextAvailableAdWithRateLimit()
8467
7624
  ];
8468
- case 12:
7625
+ case 7:
8469
7626
  _state.sent();
8470
7627
  return [
8471
7628
  3,
8472
- 13
7629
+ 8
8473
7630
  ];
8474
- case 13:
7631
+ case 8:
8475
7632
  return [
8476
7633
  2
8477
7634
  ];
8478
- case 14:
7635
+ case 9:
8479
7636
  maxRetries = 3;
8480
7637
  if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
8481
7638
  3,
8482
- 17
7639
+ 12
8483
7640
  ];
8484
7641
  if (this.debug) {
8485
7642
  console.log("[CONTINUOUS-FETCH] Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
@@ -8490,18 +7647,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8490
7647
  return setTimeout(resolve, 500);
8491
7648
  })
8492
7649
  ];
8493
- case 15:
7650
+ case 10:
8494
7651
  _state.sent();
8495
7652
  return [
8496
7653
  4,
8497
7654
  this.tryNextAvailableAd(retryCount + 1)
8498
7655
  ];
8499
- case 16:
7656
+ case 11:
8500
7657
  _state.sent();
8501
7658
  return [
8502
7659
  2
8503
7660
  ];
8504
- case 17:
7661
+ case 12:
8505
7662
  if (!this.isShowingPlaceholder && remaining > 1e3) {
8506
7663
  this.showPlaceholderAndWaitForAds();
8507
7664
  } else {
@@ -8523,7 +7680,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8523
7680
  // ───────────────────────────────────────────────────────────────
8524
7681
  function playSingleAd(vastTagUrl) {
8525
7682
  return _async_to_generator(function() {
8526
- var adPlayer, requestToken, ap, playError, preloadedFallback, fbAp, fallbackError, error, errorMessage, preloadedFallback1, fbAp1, fallbackError1;
7683
+ var adPlayer, requestToken, ap, playError, error, errorMessage;
8527
7684
  return _ts_generator(this, function(_state) {
8528
7685
  switch(_state.label){
8529
7686
  case 0:
@@ -8555,9 +7712,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8555
7712
  case 1:
8556
7713
  _state.trys.push([
8557
7714
  1,
8558
- 12,
7715
+ 8,
8559
7716
  ,
8560
- 17
7717
+ 9
8561
7718
  ]);
8562
7719
  return [
8563
7720
  4,
@@ -8593,7 +7750,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8593
7750
  4,
8594
7751
  6,
8595
7752
  ,
8596
- 11
7753
+ 7
8597
7754
  ]);
8598
7755
  this.timing.startAdFailsafeTimer(requestToken);
8599
7756
  return [
@@ -8611,55 +7768,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8611
7768
  this.timing.temporaryFailureUrls.delete(vastTagUrl);
8612
7769
  return [
8613
7770
  3,
8614
- 11
7771
+ 7
8615
7772
  ];
8616
7773
  case 6:
8617
7774
  playError = _state.sent();
8618
7775
  if (this.debug) console.error("[AD-ERROR] Failed to play ad:", playError);
8619
- preloadedFallback = this.preloadPool.getPreloadedAd();
8620
- if (!preloadedFallback) return [
8621
- 3,
8622
- 10
8623
- ];
8624
- if (this.debug) console.log("[AD-ERROR] Play failed, trying preloaded fallback ad");
8625
- _state.label = 7;
8626
- case 7:
8627
- _state.trys.push([
8628
- 7,
8629
- 9,
8630
- ,
8631
- 10
8632
- ]);
8633
- if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback.adController)) {
8634
- this.timing.rejectLoadedAdForDuration(preloadedFallback.adController);
8635
- throw playError;
8636
- }
8637
- this.timing.clearAdFailsafeTimer();
8638
- this.swapToPreloadedAdPlayer(preloadedFallback.adController);
8639
- this.timing.consecutiveFailures = 0;
8640
- fbAp = this.host.getAdPlayer();
8641
- return [
8642
- 4,
8643
- fbAp.play()
8644
- ];
8645
- case 8:
8646
- _state.sent();
8647
- this.timing.markAdStarted();
8648
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
8649
- this.timing.scheduleAdStopAtBreakBoundary();
8650
- }
8651
- fbAp.setAdVolume(getAdAudioVolume(fbAp));
8652
- return [
8653
- 2
8654
- ];
8655
- case 9:
8656
- fallbackError = _state.sent();
8657
- if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError);
8658
- return [
8659
- 3,
8660
- 10
8661
- ];
8662
- case 10:
8663
7776
  if (this.timing.isTemporaryAdError(playError)) {
8664
7777
  this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
8665
7778
  if (this.debug) console.log("[AD-ERROR] Temporary play error - URL can be retried after cooldown");
@@ -8672,57 +7785,15 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8672
7785
  this.timing.activeAdRequestToken = null;
8673
7786
  }
8674
7787
  throw playError;
8675
- case 11:
7788
+ case 7:
8676
7789
  return [
8677
7790
  3,
8678
- 17
7791
+ 9
8679
7792
  ];
8680
- case 12:
7793
+ case 8:
8681
7794
  error = _state.sent();
8682
7795
  errorMessage = (error === null || error === void 0 ? void 0 : error.message) || "";
8683
7796
  if (this.debug) console.error("[AD-ERROR] Ad request failed:", errorMessage);
8684
- preloadedFallback1 = this.preloadPool.getPreloadedAd();
8685
- if (!preloadedFallback1) return [
8686
- 3,
8687
- 16
8688
- ];
8689
- if (this.debug) console.log("[AD-ERROR] Request failed, trying preloaded fallback ad");
8690
- _state.label = 13;
8691
- case 13:
8692
- _state.trys.push([
8693
- 13,
8694
- 15,
8695
- ,
8696
- 16
8697
- ]);
8698
- if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback1.adController)) {
8699
- this.timing.rejectLoadedAdForDuration(preloadedFallback1.adController);
8700
- throw error;
8701
- }
8702
- this.timing.clearAdRequestWatchdog();
8703
- this.timing.clearAdFailsafeTimer();
8704
- this.swapToPreloadedAdPlayer(preloadedFallback1.adController);
8705
- this.timing.consecutiveFailures = 0;
8706
- fbAp1 = this.host.getAdPlayer();
8707
- return [
8708
- 4,
8709
- fbAp1.play()
8710
- ];
8711
- case 14:
8712
- _state.sent();
8713
- this.timing.markAdStarted();
8714
- fbAp1.setAdVolume(getAdAudioVolume(fbAp1));
8715
- return [
8716
- 2
8717
- ];
8718
- case 15:
8719
- fallbackError1 = _state.sent();
8720
- if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError1);
8721
- return [
8722
- 3,
8723
- 16
8724
- ];
8725
- case 16:
8726
7797
  if (this.timing.isTemporaryAdError(error)) {
8727
7798
  this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
8728
7799
  if (this.debug) console.log("[AD-ERROR] Temporary error (no-fill/timeout) - URL can be retried after cooldown");
@@ -8736,7 +7807,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8736
7807
  this.timing.activeAdRequestToken = null;
8737
7808
  }
8738
7809
  throw error;
8739
- case 17:
7810
+ case 9:
8740
7811
  return [
8741
7812
  2
8742
7813
  ];
@@ -8926,7 +7997,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8926
7997
  }
8927
7998
  this.timing.resetForBreakEnd();
8928
7999
  this.stopContinuousFetching();
8929
- this.preloadPool.stop();
8930
8000
  this.clearPendingAdBreak();
8931
8001
  if (this.isShowingPlaceholder) {
8932
8002
  this.host.getAdPlayer().hidePlaceholder();
@@ -9036,25 +8106,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9036
8106
  return _this.adBreak.handleAdFailure();
9037
8107
  }
9038
8108
  });
9039
- this.preloadPool = new AdPreloadPool({
9040
- debug: !!this.config.debugAdTiming,
9041
- createAdPlayer: function createAdPlayer(c) {
9042
- return _this.createAdPlayer(c);
9043
- },
9044
- shouldContinueLiveStreamDuringAds: function shouldContinueLiveStreamDuringAds() {
9045
- return _this.shouldContinueLiveStreamDuringAds();
9046
- },
9047
- timing: this.timing,
9048
- generateVastUrlsWithCorrelators: function generateVastUrlsWithCorrelators(base, count) {
9049
- return _this.generateVastUrls(base, count);
9050
- },
9051
- isInAdBreak: function isInAdBreak() {
9052
- return _this.adBreak.inAdBreak;
9053
- },
9054
- getPendingAdBreak: function getPendingAdBreak() {
9055
- return _this.adBreak.pendingAdBreak;
9056
- }
9057
- });
9058
8109
  this.placeholder = new PlaceholderLayer(this.video, !!this.config.debugAdTiming);
9059
8110
  this.hlsEngine = new HlsEngine(this.config, this.video, this.cueManager, this.timing, {
9060
8111
  onManifestParsed: function onManifestParsed(isLive) {
@@ -9101,13 +8152,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9101
8152
  getLiveSyncPosition: function getLiveSyncPosition() {
9102
8153
  return _this.hlsEngine.getLiveSyncPosition();
9103
8154
  },
9104
- generateVastUrls: function generateVastUrls(base, count) {
9105
- return _this.generateVastUrls(base, count);
9106
- },
9107
8155
  generatePodVastUrl: function generatePodVastUrl(base, breakDurationMs) {
9108
8156
  return _this.generatePodVastUrl(base, breakDurationMs);
9109
8157
  }
9110
- }, this.timing, this.preloadPool, this.adConfig, this.cueManager, this.placeholder);
8158
+ }, this.timing, this.adConfig, this.cueManager, this.placeholder);
9111
8159
  }
9112
8160
  _create_class(StormcloudVideoPlayer, [
9113
8161
  {
@@ -9132,12 +8180,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9132
8180
  } : {}));
9133
8181
  }
9134
8182
  },
9135
- {
9136
- key: "generateVastUrls",
9137
- value: function generateVastUrls(baseUrl, count) {
9138
- return this.adConfig.generateVastUrlsWithCorrelators(baseUrl, count, this.adPlayer, this.palNonce, this.adBreak.inAdBreak);
9139
- }
9140
- },
9141
8183
  {
9142
8184
  key: "generatePodVastUrl",
9143
8185
  value: function generatePodVastUrl(baseUrl, breakDurationMs) {
@@ -9533,11 +8575,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9533
8575
  }
9534
8576
  this.adConfig.beginNewAdPod();
9535
8577
  this.adConfig.podAssignedByPrefetch = true;
9536
- var optimizedPods = this.config.optimizedPods !== false;
9537
8578
  var breakDurationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : void 0;
9538
- var generatedUrls = optimizedPods ? [
8579
+ var generatedUrls = [
9539
8580
  this.generatePodVastUrl(baseVastUrl, breakDurationMs)
9540
- ] : this.generateVastUrls(baseVastUrl, 1);
8581
+ ];
9541
8582
  this.adBreak.pendingAdBreak = _object_spread_props(_object_spread({
9542
8583
  marker: marker
9543
8584
  }, fragmentSn !== void 0 ? {
@@ -9559,15 +8600,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9559
8600
  }, detectPayload), buildAnalyticsContext(this.config)).catch(function() {});
9560
8601
  if (this.debug) {
9561
8602
  console.log("[PREFETCH] Starting ad prefetch for upcoming ad break");
9562
- console.log("[PREFETCH] Pre-generated ".concat(generatedUrls.length, " ").concat(optimizedPods ? "pod" : "VAST", " URL(s)"));
9563
- }
9564
- if (optimizedPods) {
9565
- if (this.debug) {
9566
- console.log("[PREFETCH] Optimized pods enabled - skipping single-ad preload pool");
9567
- }
9568
- return;
8603
+ console.log("[PREFETCH] Pre-generated pod request URL");
9569
8604
  }
9570
- this.preloadPool.startPreloadPool(baseVastUrl, generatedUrls.slice(0, 1), false);
9571
8605
  }
9572
8606
  },
9573
8607
  {
@@ -9806,7 +8840,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9806
8840
  value: function destroy() {
9807
8841
  var _this_adPlayer;
9808
8842
  this.adBreak.stopContinuousFetching();
9809
- this.preloadPool.stop();
9810
8843
  this.timing.destroy();
9811
8844
  this.adBreak.clearPendingAdBreak();
9812
8845
  this.placeholder.destroy();