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
@@ -3503,21 +3503,16 @@ function applyVastMacros(baseUrl, ctx) {
3503
3503
  if (ctx.pod != null) {
3504
3504
  params.set("pod", String(ctx.pod));
3505
3505
  }
3506
- var optimizedPodMode = ctx.podMaxAds != null || ctx.podMinDurationMs != null || ctx.podMaxDurationMs != null;
3507
- if (optimizedPodMode) {
3508
- params.delete("ppos");
3509
- params.delete("lip");
3510
- if (ctx.podMinDurationMs != null) {
3511
- params.set("pmnd", String(Math.max(0, Math.round(ctx.podMinDurationMs))));
3512
- }
3513
- if (ctx.podMaxDurationMs != null) {
3514
- params.set("pmxd", String(Math.max(0, Math.round(ctx.podMaxDurationMs))));
3515
- }
3516
- if (ctx.podMaxAds != null) {
3517
- params.set("pmad", String(Math.max(1, Math.round(ctx.podMaxAds))));
3518
- }
3519
- } else if (ctx.adPosition != null) {
3520
- params.set("ppos", String(ctx.adPosition));
3506
+ params.delete("ppos");
3507
+ params.delete("lip");
3508
+ if (ctx.podMinDurationMs != null) {
3509
+ params.set("pmnd", String(Math.max(0, Math.round(ctx.podMinDurationMs))));
3510
+ }
3511
+ if (ctx.podMaxDurationMs != null) {
3512
+ params.set("pmxd", String(Math.max(0, Math.round(ctx.podMaxDurationMs))));
3513
+ }
3514
+ if (ctx.podMaxAds != null) {
3515
+ params.set("pmad", String(Math.max(1, Math.round(ctx.podMaxAds))));
3521
3516
  }
3522
3517
  var requestUrl = ctx.contentUrl || ctx.pageUrl;
3523
3518
  if (requestUrl) {
@@ -4857,9 +4852,9 @@ var AdConfigManager = /*#__PURE__*/ function() {
4857
4852
  this.consentSignals = {};
4858
4853
  this.podCounter = 0;
4859
4854
  this.podAssignedByPrefetch = false;
4860
- this.adRequestPositionInBreak = 0;
4861
4855
  this.lastHeartbeatTime = 0;
4862
4856
  this.defaultPodMaxAds = 6;
4857
+ this.defaultPodMaxDurationMs = 12e4;
4863
4858
  this.config = config;
4864
4859
  this.video = video;
4865
4860
  }
@@ -5277,48 +5272,12 @@ var AdConfigManager = /*#__PURE__*/ function() {
5277
5272
  key: "beginNewAdPod",
5278
5273
  value: function beginNewAdPod() {
5279
5274
  this.podCounter++;
5280
- this.adRequestPositionInBreak = 0;
5281
- }
5282
- },
5283
- {
5284
- key: "generateVastUrlsWithCorrelators",
5285
- value: function generateVastUrlsWithCorrelators(baseUrl, count, adPlayer, palNonce, inAdBreak) {
5286
- var urls = [];
5287
- for(var i = 0; i < count; i++){
5288
- this.adRequestPositionInBreak++;
5289
- var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
5290
- var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest);
5291
- var urlWithMacros = applyVastMacros(baseUrl, {
5292
- correlator: this.viewCorrelator,
5293
- streamCorrelator: this.streamCorrelator,
5294
- pod: this.podCounter > 0 ? this.podCounter : void 0,
5295
- adPosition: this.adRequestPositionInBreak,
5296
- isCtv: envSignals.isCtv,
5297
- contentUrl: envSignals.contentUrl,
5298
- pageUrl: !envSignals.isCtv && typeof window !== "undefined" ? window.location.href : void 0,
5299
- adWillPlayMuted: adWillPlayMuted,
5300
- adWillAutoPlay: !!this.config.autoplay,
5301
- appId: envSignals.appId,
5302
- appName: envSignals.appName,
5303
- sessionId: envSignals.sessionId,
5304
- deviceId: envSignals.deviceId,
5305
- deviceIdType: envSignals.deviceIdType,
5306
- limitAdTracking: envSignals.limitAdTracking,
5307
- deviceTypeHint: envSignals.deviceTypeHint,
5308
- adTest: this.config.adTest,
5309
- consent: this.consentSignals
5310
- });
5311
- var finalUrl = palNonce.injectNonce(urlWithMacros);
5312
- console.log("[StormcloudVideoPlayer] Resolved ad request URL (pod=".concat(this.podCounter, ", pos=").concat(this.adRequestPositionInBreak, "):"), finalUrl);
5313
- urls.push(finalUrl);
5314
- }
5315
- return urls;
5316
5275
  }
5317
5276
  },
5318
5277
  {
5319
5278
  key: "resolvePodParams",
5320
5279
  value: function resolvePodParams(breakDurationMs) {
5321
- var maxDurationMs = breakDurationMs != null && breakDurationMs > 0 ? breakDurationMs : this.config.podMaxDurationMs;
5280
+ var maxDurationMs = breakDurationMs != null && breakDurationMs > 0 ? breakDurationMs : this.config.podMaxDurationMs != null && this.config.podMaxDurationMs > 0 ? this.config.podMaxDurationMs : this.defaultPodMaxDurationMs;
5322
5281
  var maxAds = this.config.podMaxAds && this.config.podMaxAds > 0 ? this.config.podMaxAds : this.apiNumberAds && this.apiNumberAds > 0 ? this.apiNumberAds : this.defaultPodMaxAds;
5323
5282
  var minDurationMs = this.config.podExactDuration && maxDurationMs != null ? maxDurationMs : 0;
5324
5283
  return {
@@ -5971,462 +5930,6 @@ var AdTimingService = /*#__PURE__*/ function() {
5971
5930
  ]);
5972
5931
  return AdTimingService;
5973
5932
  }();
5974
- // src/player/AdPreloadPool.ts
5975
- var AdPreloadPool = /*#__PURE__*/ function() {
5976
- function AdPreloadPool(deps) {
5977
- _class_call_check(this, AdPreloadPool);
5978
- this.pool = [];
5979
- this.maxPoolSize = 2;
5980
- this.poolActive = false;
5981
- this.loopRunning = false;
5982
- this.deps = deps;
5983
- }
5984
- _create_class(AdPreloadPool, [
5985
- {
5986
- key: "active",
5987
- get: function get() {
5988
- return this.poolActive;
5989
- },
5990
- set: function set(value) {
5991
- this.poolActive = value;
5992
- }
5993
- },
5994
- {
5995
- key: "isLoopRunning",
5996
- get: function get() {
5997
- return this.loopRunning;
5998
- }
5999
- },
6000
- {
6001
- key: "startPreloadPool",
6002
- value: function startPreloadPool(baseVastUrl, initialUrls) {
6003
- var startLoopImmediately = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
6004
- if (this.poolActive) {
6005
- if (this.deps.debug) {
6006
- console.log("[PRELOAD-POOL] Already active, skipping duplicate start");
6007
- }
6008
- return;
6009
- }
6010
- this.poolActive = true;
6011
- if (this.deps.debug) {
6012
- console.log("[PRELOAD-POOL] Starting preload pool EARLY (target size: ".concat(this.maxPoolSize, ")"));
6013
- console.log("[PRELOAD-POOL] Ad break hasn't started yet, but preloading ads in advance");
6014
- }
6015
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6016
- try {
6017
- for(var _iterator = initialUrls[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6018
- var url = _step.value;
6019
- if (this.pool.length < this.maxPoolSize) {
6020
- this.preloadAdIntoPool(url);
6021
- }
6022
- }
6023
- } catch (err) {
6024
- _didIteratorError = true;
6025
- _iteratorError = err;
6026
- } finally{
6027
- try {
6028
- if (!_iteratorNormalCompletion && _iterator.return != null) {
6029
- _iterator.return();
6030
- }
6031
- } finally{
6032
- if (_didIteratorError) {
6033
- throw _iteratorError;
6034
- }
6035
- }
6036
- }
6037
- if (startLoopImmediately) {
6038
- this.preloadPoolLoop(baseVastUrl);
6039
- } else if (this.deps.debug) {
6040
- console.log("[PRELOAD-POOL] Pre-break mode: preloaded once, waiting for SCTE start to continue fetching");
6041
- }
6042
- }
6043
- },
6044
- {
6045
- key: "preloadAdIntoPool",
6046
- value: function preloadAdIntoPool(vastUrl) {
6047
- return _async_to_generator(function() {
6048
- var _this, timing, epoch, loadPromise;
6049
- return _ts_generator(this, function(_state) {
6050
- _this = this;
6051
- timing = this.deps.timing;
6052
- if (timing.isGamInCooldown()) {
6053
- if (this.deps.debug) {
6054
- console.log("[CIRCUIT-BREAKER] GAM in cooldown, skipping preload");
6055
- }
6056
- return [
6057
- 2
6058
- ];
6059
- }
6060
- if (this.pool.some(function(entry) {
6061
- return entry.vastUrl === vastUrl;
6062
- }) || timing.failedVastUrls.has(vastUrl) || timing.isUrlInCooldown(vastUrl)) {
6063
- return [
6064
- 2
6065
- ];
6066
- }
6067
- if (this.pool.length >= this.maxPoolSize) {
6068
- return [
6069
- 2
6070
- ];
6071
- }
6072
- if (this.deps.debug) {
6073
- console.log("[PRELOAD-POOL] Preloading ad into pool: ".concat(vastUrl));
6074
- }
6075
- epoch = timing.adBreakEpoch;
6076
- loadPromise = function() {
6077
- return _async_to_generator(function() {
6078
- var _this, hasAdError, adErrorPayload, errorListenerCleanup, _preloadAd_getLoadedAdDuration, continueLiveStreamDuringAds, preloadAd, errorListener, isNoFill, poolEntry, loadedDuration, lateErrorListener, _poolEntry_durationSeconds, error;
6079
- return _ts_generator(this, function(_state) {
6080
- switch(_state.label){
6081
- case 0:
6082
- _this = this;
6083
- hasAdError = false;
6084
- adErrorPayload = null;
6085
- errorListenerCleanup = null;
6086
- _state.label = 1;
6087
- case 1:
6088
- _state.trys.push([
6089
- 1,
6090
- 5,
6091
- ,
6092
- 6
6093
- ]);
6094
- continueLiveStreamDuringAds = this.deps.shouldContinueLiveStreamDuringAds();
6095
- preloadAd = this.deps.createAdPlayer(continueLiveStreamDuringAds);
6096
- preloadAd.initialize();
6097
- errorListener = function errorListener(payload) {
6098
- hasAdError = true;
6099
- adErrorPayload = payload;
6100
- };
6101
- preloadAd.on("ad_error", errorListener);
6102
- errorListenerCleanup = function errorListenerCleanup() {
6103
- return preloadAd.off("ad_error", errorListener);
6104
- };
6105
- return [
6106
- 4,
6107
- timing.enforceGlobalRateLimit()
6108
- ];
6109
- case 2:
6110
- _state.sent();
6111
- return [
6112
- 4,
6113
- preloadAd.requestAds(vastUrl)
6114
- ];
6115
- case 3:
6116
- _state.sent();
6117
- preloadAd.pause();
6118
- return [
6119
- 4,
6120
- new Promise(function(resolve) {
6121
- return setTimeout(resolve, 1500);
6122
- })
6123
- ];
6124
- case 4:
6125
- _state.sent();
6126
- preloadAd.pause();
6127
- if (hasAdError) {
6128
- 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;
6129
- if (errorListenerCleanup) {
6130
- errorListenerCleanup();
6131
- }
6132
- preloadAd.destroy();
6133
- timing.recordGamNoFill();
6134
- if (isNoFill) {
6135
- if (this.deps.debug) {
6136
- console.log("[PRELOAD-POOL] Ad preload returned no-fill: ".concat(vastUrl));
6137
- }
6138
- timing.temporaryFailureUrls.set(vastUrl, Date.now());
6139
- } else {
6140
- if (this.deps.debug) {
6141
- console.log("[PRELOAD-POOL] Ad preload failed with error: ".concat(vastUrl), adErrorPayload);
6142
- }
6143
- if (adErrorPayload && !timing.isTemporaryAdError(adErrorPayload)) {
6144
- timing.failedVastUrls.add(vastUrl);
6145
- } else {
6146
- timing.temporaryFailureUrls.set(vastUrl, Date.now());
6147
- }
6148
- }
6149
- return [
6150
- 2
6151
- ];
6152
- }
6153
- if (!this.poolActive || epoch !== timing.adBreakEpoch) {
6154
- if (this.deps.debug) {
6155
- console.log("[PRELOAD-POOL] Discarding preloaded ad - break ended during fetch");
6156
- }
6157
- if (errorListenerCleanup) {
6158
- errorListenerCleanup();
6159
- }
6160
- try {
6161
- preloadAd.destroy();
6162
- } catch (unused) {}
6163
- return [
6164
- 2
6165
- ];
6166
- }
6167
- poolEntry = {
6168
- vastUrl: vastUrl,
6169
- adController: preloadAd,
6170
- loadedAt: Date.now(),
6171
- isReady: true,
6172
- loadPromise: Promise.resolve()
6173
- };
6174
- loadedDuration = (_preloadAd_getLoadedAdDuration = preloadAd.getLoadedAdDuration) === null || _preloadAd_getLoadedAdDuration === void 0 ? void 0 : _preloadAd_getLoadedAdDuration.call(preloadAd);
6175
- if (loadedDuration != null && loadedDuration > 0) {
6176
- poolEntry.durationSeconds = loadedDuration;
6177
- }
6178
- lateErrorListener = function lateErrorListener(payload) {
6179
- var index = _this.pool.findIndex(function(entry) {
6180
- return entry.vastUrl === vastUrl;
6181
- });
6182
- if (index >= 0) {
6183
- _this.pool.splice(index, 1);
6184
- if (_this.deps.debug) {
6185
- console.log("[PRELOAD-POOL] Late error detected, removed from pool: ".concat(vastUrl), payload);
6186
- }
6187
- try {
6188
- preloadAd.destroy();
6189
- } catch (unused) {}
6190
- }
6191
- };
6192
- preloadAd.on("ad_error", lateErrorListener);
6193
- this.pool.push(poolEntry);
6194
- if (this.deps.debug) {
6195
- ;
6196
- 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)"));
6197
- }
6198
- if (errorListenerCleanup) {
6199
- errorListenerCleanup();
6200
- }
6201
- return [
6202
- 3,
6203
- 6
6204
- ];
6205
- case 5:
6206
- error = _state.sent();
6207
- if (errorListenerCleanup) {
6208
- errorListenerCleanup();
6209
- }
6210
- timing.recordGamNoFill();
6211
- if (this.deps.debug) {
6212
- console.warn("[PRELOAD-POOL] Failed to preload ad: ".concat(vastUrl), error);
6213
- }
6214
- if (_instanceof(error, Error) && !timing.isTemporaryAdError(error)) {
6215
- timing.failedVastUrls.add(vastUrl);
6216
- } else if (_instanceof(error, Error) && timing.isTemporaryAdError(error)) {
6217
- timing.temporaryFailureUrls.set(vastUrl, Date.now());
6218
- }
6219
- return [
6220
- 3,
6221
- 6
6222
- ];
6223
- case 6:
6224
- return [
6225
- 2
6226
- ];
6227
- }
6228
- });
6229
- }).call(_this);
6230
- }();
6231
- loadPromise.catch(function() {});
6232
- return [
6233
- 2
6234
- ];
6235
- });
6236
- }).call(this);
6237
- }
6238
- },
6239
- {
6240
- key: "preloadPoolLoop",
6241
- value: function preloadPoolLoop(baseVastUrl) {
6242
- return _async_to_generator(function() {
6243
- var epoch, newUrls, newUrl;
6244
- return _ts_generator(this, function(_state) {
6245
- switch(_state.label){
6246
- case 0:
6247
- if (this.loopRunning) {
6248
- return [
6249
- 2
6250
- ];
6251
- }
6252
- this.loopRunning = true;
6253
- epoch = this.deps.timing.adBreakEpoch;
6254
- if (this.deps.debug) {
6255
- console.log("[PRELOAD-POOL] Starting continuous preload loop");
6256
- }
6257
- _state.label = 1;
6258
- case 1:
6259
- if (!(this.poolActive && epoch === this.deps.timing.adBreakEpoch)) return [
6260
- 3,
6261
- 10
6262
- ];
6263
- if (this.deps.timing.isGamInCooldown()) {
6264
- if (this.deps.debug) {
6265
- console.log("[CIRCUIT-BREAKER] GAM in cooldown, stopping preload pool loop");
6266
- }
6267
- return [
6268
- 3,
6269
- 10
6270
- ];
6271
- }
6272
- if (!(!this.deps.isInAdBreak() && this.pool.length >= this.maxPoolSize)) return [
6273
- 3,
6274
- 3
6275
- ];
6276
- return [
6277
- 4,
6278
- new Promise(function(resolve) {
6279
- return setTimeout(resolve, 2e3);
6280
- })
6281
- ];
6282
- case 2:
6283
- _state.sent();
6284
- return [
6285
- 3,
6286
- 1
6287
- ];
6288
- case 3:
6289
- if (!this.deps.isInAdBreak() && this.deps.getPendingAdBreak() === null) {
6290
- if (this.deps.debug) {
6291
- console.log("[PRELOAD-POOL] Ad break cancelled, stopping preload pool");
6292
- }
6293
- return [
6294
- 3,
6295
- 10
6296
- ];
6297
- }
6298
- _state.label = 4;
6299
- case 4:
6300
- if (!(this.pool.length < this.maxPoolSize)) return [
6301
- 3,
6302
- 8
6303
- ];
6304
- if (!this.poolActive || epoch !== this.deps.timing.adBreakEpoch || this.deps.timing.isGamInCooldown()) {
6305
- return [
6306
- 3,
6307
- 8
6308
- ];
6309
- }
6310
- if (this.deps.isInAdBreak() && !this.deps.timing.hasTimeToStartAnotherAd()) {
6311
- if (this.deps.debug) {
6312
- console.log("[PRELOAD-POOL] Not enough ad break time left, stopping preload");
6313
- }
6314
- return [
6315
- 3,
6316
- 8
6317
- ];
6318
- }
6319
- newUrls = this.deps.generateVastUrlsWithCorrelators(baseVastUrl, 1);
6320
- newUrl = newUrls[0];
6321
- if (!(newUrl && !this.deps.timing.failedVastUrls.has(newUrl) && !this.deps.timing.isUrlInCooldown(newUrl))) return [
6322
- 3,
6323
- 6
6324
- ];
6325
- return [
6326
- 4,
6327
- this.preloadAdIntoPool(newUrl)
6328
- ];
6329
- case 5:
6330
- _state.sent();
6331
- _state.label = 6;
6332
- case 6:
6333
- return [
6334
- 4,
6335
- new Promise(function(resolve) {
6336
- return setTimeout(resolve, 1e3);
6337
- })
6338
- ];
6339
- case 7:
6340
- _state.sent();
6341
- return [
6342
- 3,
6343
- 4
6344
- ];
6345
- case 8:
6346
- return [
6347
- 4,
6348
- new Promise(function(resolve) {
6349
- return setTimeout(resolve, 2e3);
6350
- })
6351
- ];
6352
- case 9:
6353
- _state.sent();
6354
- return [
6355
- 3,
6356
- 1
6357
- ];
6358
- case 10:
6359
- this.loopRunning = false;
6360
- if (this.deps.debug) {
6361
- console.log("[PRELOAD-POOL] Preload loop ended");
6362
- }
6363
- return [
6364
- 2
6365
- ];
6366
- }
6367
- });
6368
- }).call(this);
6369
- }
6370
- },
6371
- {
6372
- key: "getPreloadedAd",
6373
- value: function getPreloadedAd() {
6374
- if (this.pool.length === 0) {
6375
- return null;
6376
- }
6377
- var entry = this.pool.shift();
6378
- if (!entry || !entry.isReady) {
6379
- return null;
6380
- }
6381
- if (this.deps.debug) {
6382
- console.log("[PRELOAD-POOL] Using preloaded ad from pool (".concat(this.pool.length, " remaining)"));
6383
- }
6384
- return {
6385
- vastUrl: entry.vastUrl,
6386
- adController: entry.adController
6387
- };
6388
- }
6389
- },
6390
- {
6391
- key: "stop",
6392
- value: function stop() {
6393
- this.poolActive = false;
6394
- this.loopRunning = false;
6395
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6396
- try {
6397
- for(var _iterator = this.pool[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6398
- var entry = _step.value;
6399
- try {
6400
- entry.adController.destroy();
6401
- } catch (error) {
6402
- if (this.deps.debug) {
6403
- console.warn("[PRELOAD-POOL] Error destroying preloaded controller:", error);
6404
- }
6405
- }
6406
- }
6407
- } catch (err) {
6408
- _didIteratorError = true;
6409
- _iteratorError = err;
6410
- } finally{
6411
- try {
6412
- if (!_iteratorNormalCompletion && _iterator.return != null) {
6413
- _iterator.return();
6414
- }
6415
- } finally{
6416
- if (_didIteratorError) {
6417
- throw _iteratorError;
6418
- }
6419
- }
6420
- }
6421
- this.pool = [];
6422
- if (this.deps.debug) {
6423
- console.log("[PRELOAD-POOL] Preload pool stopped and cleaned up");
6424
- }
6425
- }
6426
- }
6427
- ]);
6428
- return AdPreloadPool;
6429
- }();
6430
5933
  // src/player/PlaceholderLayer.ts
6431
5934
  var PlaceholderLayer = /*#__PURE__*/ function() {
6432
5935
  function PlaceholderLayer(video, debug) {
@@ -7148,7 +6651,7 @@ function resizePlayer(video, adPlayer, debug) {
7148
6651
  }
7149
6652
  // src/player/AdBreakOrchestrator.ts
7150
6653
  var AdBreakOrchestrator = /*#__PURE__*/ function() {
7151
- function AdBreakOrchestrator(host, timing, preloadPool, adConfig, cueManager, placeholder) {
6654
+ function AdBreakOrchestrator(host, timing, adConfig, cueManager, placeholder) {
7152
6655
  _class_call_check(this, AdBreakOrchestrator);
7153
6656
  this.inAdBreak = false;
7154
6657
  this.showAds = false;
@@ -7162,7 +6665,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7162
6665
  this.pendingAdBreak = null;
7163
6666
  this.host = host;
7164
6667
  this.timing = timing;
7165
- this.preloadPool = preloadPool;
7166
6668
  this.adConfig = adConfig;
7167
6669
  this.cueManager = cueManager;
7168
6670
  this.placeholder = placeholder;
@@ -7181,12 +6683,19 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7181
6683
  }
7182
6684
  },
7183
6685
  {
7184
- key: "optimizedPodsEnabled",
7185
- get: // ───────────────────────────────────────────────────────────────
6686
+ // ───────────────────────────────────────────────────────────────
7186
6687
  // IMA event listeners
7187
6688
  // ───────────────────────────────────────────────────────────────
7188
- function get() {
7189
- return this.host.config.optimizedPods !== false;
6689
+ /**
6690
+ * Produces the next pod ad-request URL for the current break. Every request
6691
+ * (initial and continuous-fetch top-up) carries pod macros (pmad/pmnd/pmxd,
6692
+ * no ppos); pmxd tracks the remaining break time so top-up pods only ask for
6693
+ * what still fits.
6694
+ */ key: "nextAdRequestUrl",
6695
+ value: function nextAdRequestUrl(baseVastUrl) {
6696
+ var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
6697
+ var breakDurationMs = remaining > 0 ? remaining : void 0;
6698
+ return this.host.generatePodVastUrl(baseVastUrl, breakDurationMs);
7190
6699
  }
7191
6700
  },
7192
6701
  {
@@ -7358,7 +6867,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7358
6867
  // ───────────────────────────────────────────────────────────────
7359
6868
  function handleAdStart(_marker) {
7360
6869
  return _async_to_generator(function() {
7361
- 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;
6870
+ var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, podPlayed;
7362
6871
  return _ts_generator(this, function(_state) {
7363
6872
  switch(_state.label){
7364
6873
  case 0:
@@ -7405,292 +6914,29 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7405
6914
  if (this.timing.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
7406
6915
  this.timing.expectedAdBreakDurationMs = adBreakDurationMs;
7407
6916
  }
7408
- if (!this.optimizedPodsEnabled) return [
7409
- 3,
7410
- 2
7411
- ];
7412
6917
  return [
7413
6918
  4,
7414
6919
  this.startOptimizedPod(baseVastUrl, adBreakDurationMs, currentMuted, currentVolume)
7415
6920
  ];
7416
6921
  case 1:
7417
6922
  podPlayed = _state.sent();
7418
- if (podPlayed) {
7419
- return [
7420
- 2
7421
- ];
7422
- }
6923
+ if (!!podPlayed) return [
6924
+ 3,
6925
+ 3
6926
+ ];
7423
6927
  if (this.debug) {
7424
- console.log("[POD] Optimized pod unavailable, falling back to sequential single-ad path");
6928
+ console.log("[POD] Initial pod request did not fill; attempting top-up pod request");
7425
6929
  }
7426
- _state.label = 2;
6930
+ this.continuousFetchingActive = true;
6931
+ this.startContinuousFetching(baseVastUrl);
6932
+ return [
6933
+ 4,
6934
+ this.tryNextAvailableAdWithRateLimit()
6935
+ ];
7427
6936
  case 2:
7428
- usePreloadedAd = false;
7429
- preloaded = this.preloadPool.getPreloadedAd();
7430
- if (preloaded) {
7431
- firstAdUrl = preloaded.vastUrl;
7432
- preloadedController = preloaded.adController;
7433
- usePreloadedAd = true;
7434
- sendAdLoadedTracking(this.host.config.licenseKey, {
7435
- source: "hls",
7436
- vastUrl: firstAdUrl,
7437
- timestamp: /* @__PURE__ */ new Date().toISOString()
7438
- }, this.analyticsContext).catch(function() {});
7439
- if (this.debug) {
7440
- console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool (preloaded in advance, ready immediately!)");
7441
- }
7442
- } else if (this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0) {
7443
- this.adRequestQueue = _to_consumable_array(this.pendingAdBreak.vastUrls);
7444
- firstAdUrl = this.adRequestQueue.shift();
7445
- if (this.debug) {
7446
- console.log("[CONTINUOUS-FETCH] Pool empty, using prefetched URLs (".concat(this.adRequestQueue.length + 1, " available)"));
7447
- }
7448
- this.clearPendingAdBreak();
7449
- } else {
7450
- if (this.debug) {
7451
- console.log("[CONTINUOUS-FETCH] Generating new ad URLs...");
7452
- }
7453
- firstAdUrlArray = this.host.generateVastUrls(baseVastUrl, 1);
7454
- firstAdUrl = firstAdUrlArray[0];
7455
- this.adRequestQueue = [];
7456
- }
7457
- if (!firstAdUrl) {
7458
- if (this.debug) {
7459
- console.warn("[CONTINUOUS-FETCH] Failed to get first ad URL");
7460
- }
7461
- this.handleAdPodComplete();
7462
- return [
7463
- 2
7464
- ];
7465
- }
7466
- if (this.debug) {
7467
- console.log("[CONTINUOUS-FETCH] First VAST URL:", firstAdUrl);
7468
- }
6937
+ _state.sent();
7469
6938
  _state.label = 3;
7470
6939
  case 3:
7471
- _state.trys.push([
7472
- 3,
7473
- 14,
7474
- ,
7475
- 22
7476
- ]);
7477
- if (!(usePreloadedAd && preloadedController)) return [
7478
- 3,
7479
- 7
7480
- ];
7481
- if (!!this.timing.ensureLoadedAdFitsBudget(preloadedController)) return [
7482
- 3,
7483
- 5
7484
- ];
7485
- this.timing.rejectLoadedAdForDuration(preloadedController);
7486
- this.startContinuousFetching(baseVastUrl);
7487
- return [
7488
- 4,
7489
- this.tryNextAvailableAdWithRateLimit()
7490
- ];
7491
- case 4:
7492
- _state.sent();
7493
- return [
7494
- 2
7495
- ];
7496
- case 5:
7497
- adPlayer = this.host.getAdPlayer();
7498
- preservedMuted = adPlayer.getOriginalMutedState();
7499
- preservedVolume = adPlayer.getOriginalVolume();
7500
- adPlayer.destroy();
7501
- this.host.video.muted = true;
7502
- this.host.setAdPlayer(preloadedController);
7503
- preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
7504
- this.attachImaEventListeners();
7505
- if (this.debug) {
7506
- console.log("[CONTINUOUS-FETCH] Using preloaded ad, resuming and starting playback immediately (no request delay!)");
7507
- }
7508
- preloadedController.resume();
7509
- this.timing.consecutiveFailures = 0;
7510
- this.startContinuousFetching(baseVastUrl);
7511
- if (!this.preloadPool.active) {
7512
- this.preloadPool.active = true;
7513
- }
7514
- if (!this.preloadPool.isLoopRunning) {
7515
- this.preloadPool.preloadPoolLoop(baseVastUrl);
7516
- }
7517
- return [
7518
- 4,
7519
- preloadedController.play()
7520
- ];
7521
- case 6:
7522
- _state.sent();
7523
- this.timing.markAdStarted();
7524
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7525
- this.timing.scheduleAdStopAtBreakBoundary();
7526
- }
7527
- adVolume = currentMuted ? 0 : currentVolume;
7528
- preloadedController.setAdVolume(adVolume);
7529
- return [
7530
- 3,
7531
- 13
7532
- ];
7533
- case 7:
7534
- adPlayer1 = this.host.getAdPlayer();
7535
- return [
7536
- 4,
7537
- this.timing.enforceGlobalRateLimit()
7538
- ];
7539
- case 8:
7540
- _state.sent();
7541
- this.timing.lastAdRequestTime = Date.now();
7542
- return [
7543
- 4,
7544
- adPlayer1.requestAds(firstAdUrl)
7545
- ];
7546
- case 9:
7547
- _state.sent();
7548
- sendAdLoadedTracking(this.host.config.licenseKey, {
7549
- source: "hls",
7550
- vastUrl: firstAdUrl,
7551
- timestamp: /* @__PURE__ */ new Date().toISOString()
7552
- }, this.analyticsContext).catch(function() {});
7553
- if (this.debug) {
7554
- console.log("[CONTINUOUS-FETCH] First ad request successful, starting playback");
7555
- }
7556
- if (!!this.timing.ensureLoadedAdFitsBudget(adPlayer1)) return [
7557
- 3,
7558
- 11
7559
- ];
7560
- this.timing.rejectLoadedAdForDuration(adPlayer1);
7561
- this.recreateAdController();
7562
- this.startContinuousFetching(baseVastUrl);
7563
- return [
7564
- 4,
7565
- this.tryNextAvailableAdWithRateLimit()
7566
- ];
7567
- case 10:
7568
- _state.sent();
7569
- return [
7570
- 2
7571
- ];
7572
- case 11:
7573
- this.timing.consecutiveFailures = 0;
7574
- this.startContinuousFetching(baseVastUrl);
7575
- if (!this.preloadPool.active) {
7576
- this.preloadPool.startPreloadPool(baseVastUrl, []);
7577
- }
7578
- return [
7579
- 4,
7580
- adPlayer1.play()
7581
- ];
7582
- case 12:
7583
- _state.sent();
7584
- this.timing.markAdStarted();
7585
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7586
- this.timing.scheduleAdStopAtBreakBoundary();
7587
- }
7588
- adVolume1 = currentMuted ? 0 : currentVolume;
7589
- adPlayer1.setAdVolume(adVolume1);
7590
- _state.label = 13;
7591
- case 13:
7592
- return [
7593
- 3,
7594
- 22
7595
- ];
7596
- case 14:
7597
- error = _state.sent();
7598
- if (this.debug) {
7599
- console.warn("[CONTINUOUS-FETCH] First ad request failed:", error);
7600
- }
7601
- if (!!usePreloadedAd) return [
7602
- 3,
7603
- 20
7604
- ];
7605
- fallbackPreloaded = this.preloadPool.getPreloadedAd();
7606
- if (!fallbackPreloaded) return [
7607
- 3,
7608
- 20
7609
- ];
7610
- if (this.debug) {
7611
- console.log("[CONTINUOUS-FETCH] First ad failed, using preloaded fallback");
7612
- }
7613
- _state.label = 15;
7614
- case 15:
7615
- _state.trys.push([
7616
- 15,
7617
- 19,
7618
- ,
7619
- 20
7620
- ]);
7621
- if (!!this.timing.ensureLoadedAdFitsBudget(fallbackPreloaded.adController)) return [
7622
- 3,
7623
- 17
7624
- ];
7625
- this.timing.rejectLoadedAdForDuration(fallbackPreloaded.adController);
7626
- this.startContinuousFetching(baseVastUrl);
7627
- return [
7628
- 4,
7629
- this.tryNextAvailableAdWithRateLimit()
7630
- ];
7631
- case 16:
7632
- _state.sent();
7633
- return [
7634
- 2
7635
- ];
7636
- case 17:
7637
- this.swapToPreloadedAdPlayer(fallbackPreloaded.adController);
7638
- this.timing.consecutiveFailures = 0;
7639
- this.startContinuousFetching(baseVastUrl);
7640
- if (!this.preloadPool.active) {
7641
- this.preloadPool.active = true;
7642
- this.preloadPool.preloadPoolLoop(baseVastUrl);
7643
- }
7644
- ap = this.host.getAdPlayer();
7645
- return [
7646
- 4,
7647
- ap.play()
7648
- ];
7649
- case 18:
7650
- _state.sent();
7651
- this.timing.markAdStarted();
7652
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7653
- this.timing.scheduleAdStopAtBreakBoundary();
7654
- }
7655
- adVolume2 = currentMuted ? 0 : currentVolume;
7656
- ap.setAdVolume(adVolume2);
7657
- return [
7658
- 2
7659
- ];
7660
- case 19:
7661
- fallbackError = _state.sent();
7662
- if (this.debug) {
7663
- console.warn("[CONTINUOUS-FETCH] Preloaded fallback also failed:", fallbackError);
7664
- }
7665
- return [
7666
- 3,
7667
- 20
7668
- ];
7669
- case 20:
7670
- if (this.timing.isTemporaryAdError(error)) {
7671
- this.timing.temporaryFailureUrls.set(firstAdUrl, Date.now());
7672
- if (this.debug) {
7673
- console.log("[CONTINUOUS-FETCH] First ad had temporary error (no-fill) - will try alternatives");
7674
- }
7675
- } else {
7676
- this.timing.failedVastUrls.add(firstAdUrl);
7677
- if (this.debug) {
7678
- console.log("[CONTINUOUS-FETCH] First ad had permanent error - URL blacklisted");
7679
- }
7680
- }
7681
- this.timing.consecutiveFailures++;
7682
- this.startContinuousFetching(baseVastUrl);
7683
- return [
7684
- 4,
7685
- this.tryNextAvailableAdWithRateLimit()
7686
- ];
7687
- case 21:
7688
- _state.sent();
7689
- return [
7690
- 3,
7691
- 22
7692
- ];
7693
- case 22:
7694
6940
  return [
7695
6941
  2
7696
6942
  ];
@@ -7764,7 +7010,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7764
7010
  ];
7765
7011
  }
7766
7012
  if (this.debug) {
7767
- 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"));
7013
+ 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"));
7768
7014
  }
7769
7015
  sendAdLoadedTracking(this.host.config.licenseKey, {
7770
7016
  source: "hls",
@@ -7784,13 +7030,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7784
7030
  }
7785
7031
  adPlayer.setAdVolume(currentMuted ? 0 : currentVolume);
7786
7032
  this.timing.consecutiveFailures = 0;
7787
- if (podCount === 1) {
7788
- this.continuousFetchingActive = true;
7789
- this.startContinuousFetching(baseVastUrl);
7790
- if (!this.preloadPool.active) {
7791
- this.preloadPool.startPreloadPool(baseVastUrl, []);
7792
- }
7793
- }
7033
+ this.continuousFetchingActive = true;
7034
+ this.startContinuousFetching(baseVastUrl);
7794
7035
  return [
7795
7036
  2,
7796
7037
  true
@@ -7823,20 +7064,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7823
7064
  }).call(this);
7824
7065
  }
7825
7066
  },
7826
- {
7827
- key: "swapToPreloadedAdPlayer",
7828
- value: function swapToPreloadedAdPlayer(preloadedController) {
7829
- var adPlayer = this.host.getAdPlayer();
7830
- var preservedMuted = adPlayer.getOriginalMutedState();
7831
- var preservedVolume = adPlayer.getOriginalVolume();
7832
- adPlayer.destroy();
7833
- this.host.video.muted = true;
7834
- this.host.setAdPlayer(preloadedController);
7835
- this.attachImaEventListeners();
7836
- preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
7837
- preloadedController.resume();
7838
- }
7839
- },
7840
7067
  {
7841
7068
  // ───────────────────────────────────────────────────────────────
7842
7069
  // Continuous fetching
@@ -7930,7 +7157,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7930
7157
  "continue"
7931
7158
  ];
7932
7159
  case 2:
7933
- newAdUrl = _this.host.generateVastUrls(baseVastUrl, 1)[0];
7160
+ newAdUrl = _this.nextAdRequestUrl(baseVastUrl);
7934
7161
  if (!(!newAdUrl || _this.timing.failedVastUrls.has(newAdUrl) || _this.timing.isUrlInCooldown(newAdUrl))) return [
7935
7162
  3,
7936
7163
  4
@@ -8087,7 +7314,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8087
7314
  value: function tryNextAvailableAd() {
8088
7315
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
8089
7316
  return _async_to_generator(function() {
8090
- var remaining, preloaded, ap, error, nextAdUrl, error1, errorMessage, maxRetries;
7317
+ var remaining, nextAdUrl, error, errorMessage, maxRetries;
8091
7318
  return _ts_generator(this, function(_state) {
8092
7319
  switch(_state.label){
8093
7320
  case 0:
@@ -8125,132 +7352,71 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8125
7352
  ];
8126
7353
  }
8127
7354
  this.timing.cleanupTemporaryFailures();
8128
- preloaded = this.preloadPool.getPreloadedAd();
8129
- if (!preloaded) return [
8130
- 3,
8131
- 6
8132
- ];
8133
- if (this.debug) {
8134
- console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool");
8135
- }
8136
- sendAdLoadedTracking(this.host.config.licenseKey, {
8137
- source: "hls",
8138
- vastUrl: preloaded.vastUrl,
8139
- timestamp: /* @__PURE__ */ new Date().toISOString()
8140
- }, this.analyticsContext).catch(function() {});
8141
7355
  _state.label = 1;
8142
7356
  case 1:
8143
- _state.trys.push([
8144
- 1,
8145
- 5,
8146
- ,
8147
- 6
8148
- ]);
8149
- if (!!this.timing.ensureLoadedAdFitsBudget(preloaded.adController)) return [
8150
- 3,
8151
- 3
8152
- ];
8153
- this.timing.rejectLoadedAdForDuration(preloaded.adController);
8154
- return [
8155
- 4,
8156
- this.tryNextAvailableAdWithRateLimit()
8157
- ];
8158
- case 2:
8159
- _state.sent();
8160
- return [
8161
- 2
8162
- ];
8163
- case 3:
8164
- this.swapToPreloadedAdPlayer(preloaded.adController);
8165
- ap = this.host.getAdPlayer();
8166
- return [
8167
- 4,
8168
- ap.play()
8169
- ];
8170
- case 4:
8171
- _state.sent();
8172
- this.timing.markAdStarted();
8173
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
8174
- this.timing.scheduleAdStopAtBreakBoundary();
8175
- }
8176
- ap.setAdVolume(getAdAudioVolume(ap));
8177
- this.timing.consecutiveFailures = 0;
8178
- return [
8179
- 2
8180
- ];
8181
- case 5:
8182
- error = _state.sent();
8183
- if (this.debug) {
8184
- console.warn("[CONTINUOUS-FETCH] Preloaded ad failed to play:", error);
8185
- }
8186
- return [
8187
- 3,
8188
- 6
8189
- ];
8190
- case 6:
8191
7357
  if (!(this.adRequestQueue.length > 0)) return [
8192
7358
  3,
8193
- 14
7359
+ 9
8194
7360
  ];
8195
7361
  nextAdUrl = this.adRequestQueue.shift();
8196
7362
  if (!nextAdUrl) return [
8197
7363
  3,
8198
- 6
7364
+ 1
8199
7365
  ];
8200
7366
  if (this.timing.failedVastUrls.has(nextAdUrl)) {
8201
7367
  if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping permanently-failed URL, trying next...");
8202
7368
  return [
8203
7369
  3,
8204
- 6
7370
+ 1
8205
7371
  ];
8206
7372
  }
8207
7373
  if (this.timing.isUrlInCooldown(nextAdUrl)) {
8208
7374
  if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping URL in cooldown (recent no-fill), trying next...");
8209
7375
  return [
8210
7376
  3,
8211
- 6
7377
+ 1
8212
7378
  ];
8213
7379
  }
8214
7380
  if (this.debug) {
8215
7381
  console.log("[CONTINUOUS-FETCH] Requesting next ad via HLS ad player (".concat(this.timing.currentAdIndex + 1, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
8216
7382
  }
8217
- _state.label = 7;
8218
- case 7:
7383
+ _state.label = 2;
7384
+ case 2:
8219
7385
  _state.trys.push([
8220
- 7,
8221
- 9,
7386
+ 2,
7387
+ 4,
8222
7388
  ,
8223
- 13
7389
+ 8
8224
7390
  ]);
8225
7391
  return [
8226
7392
  4,
8227
7393
  this.playSingleAd(nextAdUrl)
8228
7394
  ];
8229
- case 8:
7395
+ case 3:
8230
7396
  _state.sent();
8231
7397
  this.timing.consecutiveFailures = 0;
8232
7398
  return [
8233
7399
  3,
8234
- 13
7400
+ 8
8235
7401
  ];
8236
- case 9:
8237
- error1 = _state.sent();
8238
- errorMessage = error1.message;
7402
+ case 4:
7403
+ error = _state.sent();
7404
+ errorMessage = error.message;
8239
7405
  if (this.debug) console.log("[CONTINUOUS-FETCH] Ad request failed:", errorMessage);
8240
7406
  if (!errorMessage.includes("ad_duration_exceeds_budget")) return [
8241
7407
  3,
8242
- 11
7408
+ 6
8243
7409
  ];
8244
7410
  return [
8245
7411
  4,
8246
7412
  this.tryNextAvailableAdWithRateLimit()
8247
7413
  ];
8248
- case 10:
7414
+ case 5:
8249
7415
  _state.sent();
8250
7416
  return [
8251
7417
  2
8252
7418
  ];
8253
- case 11:
7419
+ case 6:
8254
7420
  if (!errorMessage.includes("permanently failed") && !errorMessage.includes("in cooldown")) {
8255
7421
  this.timing.consecutiveFailures++;
8256
7422
  }
@@ -8258,21 +7424,21 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8258
7424
  4,
8259
7425
  this.tryNextAvailableAdWithRateLimit()
8260
7426
  ];
8261
- case 12:
7427
+ case 7:
8262
7428
  _state.sent();
8263
7429
  return [
8264
7430
  3,
8265
- 13
7431
+ 8
8266
7432
  ];
8267
- case 13:
7433
+ case 8:
8268
7434
  return [
8269
7435
  2
8270
7436
  ];
8271
- case 14:
7437
+ case 9:
8272
7438
  maxRetries = 3;
8273
7439
  if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
8274
7440
  3,
8275
- 17
7441
+ 12
8276
7442
  ];
8277
7443
  if (this.debug) {
8278
7444
  console.log("[CONTINUOUS-FETCH] Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
@@ -8283,18 +7449,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8283
7449
  return setTimeout(resolve, 500);
8284
7450
  })
8285
7451
  ];
8286
- case 15:
7452
+ case 10:
8287
7453
  _state.sent();
8288
7454
  return [
8289
7455
  4,
8290
7456
  this.tryNextAvailableAd(retryCount + 1)
8291
7457
  ];
8292
- case 16:
7458
+ case 11:
8293
7459
  _state.sent();
8294
7460
  return [
8295
7461
  2
8296
7462
  ];
8297
- case 17:
7463
+ case 12:
8298
7464
  if (!this.isShowingPlaceholder && remaining > 1e3) {
8299
7465
  this.showPlaceholderAndWaitForAds();
8300
7466
  } else {
@@ -8316,7 +7482,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8316
7482
  // ───────────────────────────────────────────────────────────────
8317
7483
  function playSingleAd(vastTagUrl) {
8318
7484
  return _async_to_generator(function() {
8319
- var adPlayer, requestToken, ap, playError, preloadedFallback, fbAp, fallbackError, error, errorMessage, preloadedFallback1, fbAp1, fallbackError1;
7485
+ var adPlayer, requestToken, ap, playError, error, errorMessage;
8320
7486
  return _ts_generator(this, function(_state) {
8321
7487
  switch(_state.label){
8322
7488
  case 0:
@@ -8348,9 +7514,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8348
7514
  case 1:
8349
7515
  _state.trys.push([
8350
7516
  1,
8351
- 12,
7517
+ 8,
8352
7518
  ,
8353
- 17
7519
+ 9
8354
7520
  ]);
8355
7521
  return [
8356
7522
  4,
@@ -8386,7 +7552,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8386
7552
  4,
8387
7553
  6,
8388
7554
  ,
8389
- 11
7555
+ 7
8390
7556
  ]);
8391
7557
  this.timing.startAdFailsafeTimer(requestToken);
8392
7558
  return [
@@ -8404,55 +7570,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8404
7570
  this.timing.temporaryFailureUrls.delete(vastTagUrl);
8405
7571
  return [
8406
7572
  3,
8407
- 11
7573
+ 7
8408
7574
  ];
8409
7575
  case 6:
8410
7576
  playError = _state.sent();
8411
7577
  if (this.debug) console.error("[AD-ERROR] Failed to play ad:", playError);
8412
- preloadedFallback = this.preloadPool.getPreloadedAd();
8413
- if (!preloadedFallback) return [
8414
- 3,
8415
- 10
8416
- ];
8417
- if (this.debug) console.log("[AD-ERROR] Play failed, trying preloaded fallback ad");
8418
- _state.label = 7;
8419
- case 7:
8420
- _state.trys.push([
8421
- 7,
8422
- 9,
8423
- ,
8424
- 10
8425
- ]);
8426
- if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback.adController)) {
8427
- this.timing.rejectLoadedAdForDuration(preloadedFallback.adController);
8428
- throw playError;
8429
- }
8430
- this.timing.clearAdFailsafeTimer();
8431
- this.swapToPreloadedAdPlayer(preloadedFallback.adController);
8432
- this.timing.consecutiveFailures = 0;
8433
- fbAp = this.host.getAdPlayer();
8434
- return [
8435
- 4,
8436
- fbAp.play()
8437
- ];
8438
- case 8:
8439
- _state.sent();
8440
- this.timing.markAdStarted();
8441
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
8442
- this.timing.scheduleAdStopAtBreakBoundary();
8443
- }
8444
- fbAp.setAdVolume(getAdAudioVolume(fbAp));
8445
- return [
8446
- 2
8447
- ];
8448
- case 9:
8449
- fallbackError = _state.sent();
8450
- if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError);
8451
- return [
8452
- 3,
8453
- 10
8454
- ];
8455
- case 10:
8456
7578
  if (this.timing.isTemporaryAdError(playError)) {
8457
7579
  this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
8458
7580
  if (this.debug) console.log("[AD-ERROR] Temporary play error - URL can be retried after cooldown");
@@ -8465,57 +7587,15 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8465
7587
  this.timing.activeAdRequestToken = null;
8466
7588
  }
8467
7589
  throw playError;
8468
- case 11:
7590
+ case 7:
8469
7591
  return [
8470
7592
  3,
8471
- 17
7593
+ 9
8472
7594
  ];
8473
- case 12:
7595
+ case 8:
8474
7596
  error = _state.sent();
8475
7597
  errorMessage = (error === null || error === void 0 ? void 0 : error.message) || "";
8476
7598
  if (this.debug) console.error("[AD-ERROR] Ad request failed:", errorMessage);
8477
- preloadedFallback1 = this.preloadPool.getPreloadedAd();
8478
- if (!preloadedFallback1) return [
8479
- 3,
8480
- 16
8481
- ];
8482
- if (this.debug) console.log("[AD-ERROR] Request failed, trying preloaded fallback ad");
8483
- _state.label = 13;
8484
- case 13:
8485
- _state.trys.push([
8486
- 13,
8487
- 15,
8488
- ,
8489
- 16
8490
- ]);
8491
- if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback1.adController)) {
8492
- this.timing.rejectLoadedAdForDuration(preloadedFallback1.adController);
8493
- throw error;
8494
- }
8495
- this.timing.clearAdRequestWatchdog();
8496
- this.timing.clearAdFailsafeTimer();
8497
- this.swapToPreloadedAdPlayer(preloadedFallback1.adController);
8498
- this.timing.consecutiveFailures = 0;
8499
- fbAp1 = this.host.getAdPlayer();
8500
- return [
8501
- 4,
8502
- fbAp1.play()
8503
- ];
8504
- case 14:
8505
- _state.sent();
8506
- this.timing.markAdStarted();
8507
- fbAp1.setAdVolume(getAdAudioVolume(fbAp1));
8508
- return [
8509
- 2
8510
- ];
8511
- case 15:
8512
- fallbackError1 = _state.sent();
8513
- if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError1);
8514
- return [
8515
- 3,
8516
- 16
8517
- ];
8518
- case 16:
8519
7599
  if (this.timing.isTemporaryAdError(error)) {
8520
7600
  this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
8521
7601
  if (this.debug) console.log("[AD-ERROR] Temporary error (no-fill/timeout) - URL can be retried after cooldown");
@@ -8529,7 +7609,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8529
7609
  this.timing.activeAdRequestToken = null;
8530
7610
  }
8531
7611
  throw error;
8532
- case 17:
7612
+ case 9:
8533
7613
  return [
8534
7614
  2
8535
7615
  ];
@@ -8719,7 +7799,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8719
7799
  }
8720
7800
  this.timing.resetForBreakEnd();
8721
7801
  this.stopContinuousFetching();
8722
- this.preloadPool.stop();
8723
7802
  this.clearPendingAdBreak();
8724
7803
  if (this.isShowingPlaceholder) {
8725
7804
  this.host.getAdPlayer().hidePlaceholder();
@@ -8829,25 +7908,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8829
7908
  return _this.adBreak.handleAdFailure();
8830
7909
  }
8831
7910
  });
8832
- this.preloadPool = new AdPreloadPool({
8833
- debug: !!this.config.debugAdTiming,
8834
- createAdPlayer: function createAdPlayer(c) {
8835
- return _this.createAdPlayer(c);
8836
- },
8837
- shouldContinueLiveStreamDuringAds: function shouldContinueLiveStreamDuringAds() {
8838
- return _this.shouldContinueLiveStreamDuringAds();
8839
- },
8840
- timing: this.timing,
8841
- generateVastUrlsWithCorrelators: function generateVastUrlsWithCorrelators(base, count) {
8842
- return _this.generateVastUrls(base, count);
8843
- },
8844
- isInAdBreak: function isInAdBreak() {
8845
- return _this.adBreak.inAdBreak;
8846
- },
8847
- getPendingAdBreak: function getPendingAdBreak() {
8848
- return _this.adBreak.pendingAdBreak;
8849
- }
8850
- });
8851
7911
  this.placeholder = new PlaceholderLayer(this.video, !!this.config.debugAdTiming);
8852
7912
  this.hlsEngine = new HlsEngine(this.config, this.video, this.cueManager, this.timing, {
8853
7913
  onManifestParsed: function onManifestParsed(isLive) {
@@ -8894,13 +7954,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8894
7954
  getLiveSyncPosition: function getLiveSyncPosition() {
8895
7955
  return _this.hlsEngine.getLiveSyncPosition();
8896
7956
  },
8897
- generateVastUrls: function generateVastUrls(base, count) {
8898
- return _this.generateVastUrls(base, count);
8899
- },
8900
7957
  generatePodVastUrl: function generatePodVastUrl(base, breakDurationMs) {
8901
7958
  return _this.generatePodVastUrl(base, breakDurationMs);
8902
7959
  }
8903
- }, this.timing, this.preloadPool, this.adConfig, this.cueManager, this.placeholder);
7960
+ }, this.timing, this.adConfig, this.cueManager, this.placeholder);
8904
7961
  }
8905
7962
  _create_class(StormcloudVideoPlayer, [
8906
7963
  {
@@ -8925,12 +7982,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8925
7982
  } : {}));
8926
7983
  }
8927
7984
  },
8928
- {
8929
- key: "generateVastUrls",
8930
- value: function generateVastUrls(baseUrl, count) {
8931
- return this.adConfig.generateVastUrlsWithCorrelators(baseUrl, count, this.adPlayer, this.palNonce, this.adBreak.inAdBreak);
8932
- }
8933
- },
8934
7985
  {
8935
7986
  key: "generatePodVastUrl",
8936
7987
  value: function generatePodVastUrl(baseUrl, breakDurationMs) {
@@ -9326,11 +8377,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9326
8377
  }
9327
8378
  this.adConfig.beginNewAdPod();
9328
8379
  this.adConfig.podAssignedByPrefetch = true;
9329
- var optimizedPods = this.config.optimizedPods !== false;
9330
8380
  var breakDurationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : void 0;
9331
- var generatedUrls = optimizedPods ? [
8381
+ var generatedUrls = [
9332
8382
  this.generatePodVastUrl(baseVastUrl, breakDurationMs)
9333
- ] : this.generateVastUrls(baseVastUrl, 1);
8383
+ ];
9334
8384
  this.adBreak.pendingAdBreak = _object_spread_props(_object_spread({
9335
8385
  marker: marker
9336
8386
  }, fragmentSn !== void 0 ? {
@@ -9352,15 +8402,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9352
8402
  }, detectPayload), buildAnalyticsContext(this.config)).catch(function() {});
9353
8403
  if (this.debug) {
9354
8404
  console.log("[PREFETCH] Starting ad prefetch for upcoming ad break");
9355
- console.log("[PREFETCH] Pre-generated ".concat(generatedUrls.length, " ").concat(optimizedPods ? "pod" : "VAST", " URL(s)"));
9356
- }
9357
- if (optimizedPods) {
9358
- if (this.debug) {
9359
- console.log("[PREFETCH] Optimized pods enabled - skipping single-ad preload pool");
9360
- }
9361
- return;
8405
+ console.log("[PREFETCH] Pre-generated pod request URL");
9362
8406
  }
9363
- this.preloadPool.startPreloadPool(baseVastUrl, generatedUrls.slice(0, 1), false);
9364
8407
  }
9365
8408
  },
9366
8409
  {
@@ -9599,7 +8642,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9599
8642
  value: function destroy() {
9600
8643
  var _this_adPlayer;
9601
8644
  this.adBreak.stopContinuousFetching();
9602
- this.preloadPool.stop();
9603
8645
  this.timing.destroy();
9604
8646
  this.adBreak.clearPendingAdBreak();
9605
8647
  this.placeholder.destroy();