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
@@ -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,23 +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;
7190
- }
7191
- },
7192
- {
7193
- key: "nextAdRequestUrl",
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",
7194
6695
  value: function nextAdRequestUrl(baseVastUrl) {
7195
- if (this.optimizedPodsEnabled) {
7196
- var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
7197
- var breakDurationMs = remaining > 0 ? remaining : void 0;
7198
- return this.host.generatePodVastUrl(baseVastUrl, breakDurationMs);
7199
- }
7200
- return this.host.generateVastUrls(baseVastUrl, 1)[0];
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);
7201
6699
  }
7202
6700
  },
7203
6701
  {
@@ -7369,7 +6867,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7369
6867
  // ───────────────────────────────────────────────────────────────
7370
6868
  function handleAdStart(_marker) {
7371
6869
  return _async_to_generator(function() {
7372
- var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, podPlayed, firstAdUrl, usePreloadedAd, preloadedController, preloaded, adPlayer, preservedMuted, preservedVolume, adVolume, adPlayer1, adVolume1, error, fallbackPreloaded, ap, adVolume2, fallbackError;
6870
+ var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, podPlayed;
7373
6871
  return _ts_generator(this, function(_state) {
7374
6872
  switch(_state.label){
7375
6873
  case 0:
@@ -7416,293 +6914,29 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7416
6914
  if (this.timing.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
7417
6915
  this.timing.expectedAdBreakDurationMs = adBreakDurationMs;
7418
6916
  }
7419
- if (!this.optimizedPodsEnabled) return [
7420
- 3,
7421
- 2
7422
- ];
7423
6917
  return [
7424
6918
  4,
7425
6919
  this.startOptimizedPod(baseVastUrl, adBreakDurationMs, currentMuted, currentVolume)
7426
6920
  ];
7427
6921
  case 1:
7428
6922
  podPlayed = _state.sent();
7429
- if (podPlayed) {
7430
- return [
7431
- 2
7432
- ];
7433
- }
6923
+ if (!!podPlayed) return [
6924
+ 3,
6925
+ 3
6926
+ ];
7434
6927
  if (this.debug) {
7435
- 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");
7436
6929
  }
7437
- _state.label = 2;
6930
+ this.continuousFetchingActive = true;
6931
+ this.startContinuousFetching(baseVastUrl);
6932
+ return [
6933
+ 4,
6934
+ this.tryNextAvailableAdWithRateLimit()
6935
+ ];
7438
6936
  case 2:
7439
- usePreloadedAd = false;
7440
- preloaded = this.preloadPool.getPreloadedAd();
7441
- if (preloaded) {
7442
- firstAdUrl = preloaded.vastUrl;
7443
- preloadedController = preloaded.adController;
7444
- usePreloadedAd = true;
7445
- sendAdLoadedTracking(this.host.config.licenseKey, {
7446
- source: "hls",
7447
- vastUrl: firstAdUrl,
7448
- timestamp: /* @__PURE__ */ new Date().toISOString()
7449
- }, this.analyticsContext).catch(function() {});
7450
- if (this.debug) {
7451
- console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool (preloaded in advance, ready immediately!)");
7452
- }
7453
- } else if (this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0) {
7454
- this.adRequestQueue = _to_consumable_array(this.pendingAdBreak.vastUrls);
7455
- firstAdUrl = this.adRequestQueue.shift();
7456
- if (this.debug) {
7457
- console.log("[CONTINUOUS-FETCH] Pool empty, using prefetched URLs (".concat(this.adRequestQueue.length + 1, " available)"));
7458
- }
7459
- this.clearPendingAdBreak();
7460
- } else {
7461
- if (this.debug) {
7462
- console.log("[CONTINUOUS-FETCH] Generating new ad URLs...");
7463
- }
7464
- firstAdUrl = this.nextAdRequestUrl(baseVastUrl);
7465
- this.adRequestQueue = [];
7466
- }
7467
- if (!firstAdUrl) {
7468
- if (this.debug) {
7469
- console.warn("[CONTINUOUS-FETCH] Failed to get first ad URL");
7470
- }
7471
- this.handleAdPodComplete();
7472
- return [
7473
- 2
7474
- ];
7475
- }
7476
- if (this.debug) {
7477
- console.log("[CONTINUOUS-FETCH] First VAST URL:", firstAdUrl);
7478
- }
6937
+ _state.sent();
7479
6938
  _state.label = 3;
7480
6939
  case 3:
7481
- _state.trys.push([
7482
- 3,
7483
- 14,
7484
- ,
7485
- 22
7486
- ]);
7487
- if (!(usePreloadedAd && preloadedController)) return [
7488
- 3,
7489
- 7
7490
- ];
7491
- if (!!this.timing.ensureLoadedAdFitsBudget(preloadedController)) return [
7492
- 3,
7493
- 5
7494
- ];
7495
- this.timing.rejectLoadedAdForDuration(preloadedController);
7496
- this.startContinuousFetching(baseVastUrl);
7497
- return [
7498
- 4,
7499
- this.tryNextAvailableAdWithRateLimit()
7500
- ];
7501
- case 4:
7502
- _state.sent();
7503
- return [
7504
- 2
7505
- ];
7506
- case 5:
7507
- adPlayer = this.host.getAdPlayer();
7508
- preservedMuted = adPlayer.getOriginalMutedState();
7509
- preservedVolume = adPlayer.getOriginalVolume();
7510
- adPlayer.destroy();
7511
- this.host.video.muted = true;
7512
- this.host.setAdPlayer(preloadedController);
7513
- preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
7514
- this.attachImaEventListeners();
7515
- if (this.debug) {
7516
- console.log("[CONTINUOUS-FETCH] Using preloaded ad, resuming and starting playback immediately (no request delay!)");
7517
- }
7518
- preloadedController.resume();
7519
- this.timing.consecutiveFailures = 0;
7520
- this.startContinuousFetching(baseVastUrl);
7521
- if (!this.optimizedPodsEnabled) {
7522
- if (!this.preloadPool.active) {
7523
- this.preloadPool.active = true;
7524
- }
7525
- if (!this.preloadPool.isLoopRunning) {
7526
- this.preloadPool.preloadPoolLoop(baseVastUrl);
7527
- }
7528
- }
7529
- return [
7530
- 4,
7531
- preloadedController.play()
7532
- ];
7533
- case 6:
7534
- _state.sent();
7535
- this.timing.markAdStarted();
7536
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7537
- this.timing.scheduleAdStopAtBreakBoundary();
7538
- }
7539
- adVolume = currentMuted ? 0 : currentVolume;
7540
- preloadedController.setAdVolume(adVolume);
7541
- return [
7542
- 3,
7543
- 13
7544
- ];
7545
- case 7:
7546
- adPlayer1 = this.host.getAdPlayer();
7547
- return [
7548
- 4,
7549
- this.timing.enforceGlobalRateLimit()
7550
- ];
7551
- case 8:
7552
- _state.sent();
7553
- this.timing.lastAdRequestTime = Date.now();
7554
- return [
7555
- 4,
7556
- adPlayer1.requestAds(firstAdUrl)
7557
- ];
7558
- case 9:
7559
- _state.sent();
7560
- sendAdLoadedTracking(this.host.config.licenseKey, {
7561
- source: "hls",
7562
- vastUrl: firstAdUrl,
7563
- timestamp: /* @__PURE__ */ new Date().toISOString()
7564
- }, this.analyticsContext).catch(function() {});
7565
- if (this.debug) {
7566
- console.log("[CONTINUOUS-FETCH] First ad request successful, starting playback");
7567
- }
7568
- if (!!this.timing.ensureLoadedAdFitsBudget(adPlayer1)) return [
7569
- 3,
7570
- 11
7571
- ];
7572
- this.timing.rejectLoadedAdForDuration(adPlayer1);
7573
- this.recreateAdController();
7574
- this.startContinuousFetching(baseVastUrl);
7575
- return [
7576
- 4,
7577
- this.tryNextAvailableAdWithRateLimit()
7578
- ];
7579
- case 10:
7580
- _state.sent();
7581
- return [
7582
- 2
7583
- ];
7584
- case 11:
7585
- this.timing.consecutiveFailures = 0;
7586
- this.startContinuousFetching(baseVastUrl);
7587
- if (!this.optimizedPodsEnabled && !this.preloadPool.active) {
7588
- this.preloadPool.startPreloadPool(baseVastUrl, []);
7589
- }
7590
- return [
7591
- 4,
7592
- adPlayer1.play()
7593
- ];
7594
- case 12:
7595
- _state.sent();
7596
- this.timing.markAdStarted();
7597
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7598
- this.timing.scheduleAdStopAtBreakBoundary();
7599
- }
7600
- adVolume1 = currentMuted ? 0 : currentVolume;
7601
- adPlayer1.setAdVolume(adVolume1);
7602
- _state.label = 13;
7603
- case 13:
7604
- return [
7605
- 3,
7606
- 22
7607
- ];
7608
- case 14:
7609
- error = _state.sent();
7610
- if (this.debug) {
7611
- console.warn("[CONTINUOUS-FETCH] First ad request failed:", error);
7612
- }
7613
- if (!!usePreloadedAd) return [
7614
- 3,
7615
- 20
7616
- ];
7617
- fallbackPreloaded = this.preloadPool.getPreloadedAd();
7618
- if (!fallbackPreloaded) return [
7619
- 3,
7620
- 20
7621
- ];
7622
- if (this.debug) {
7623
- console.log("[CONTINUOUS-FETCH] First ad failed, using preloaded fallback");
7624
- }
7625
- _state.label = 15;
7626
- case 15:
7627
- _state.trys.push([
7628
- 15,
7629
- 19,
7630
- ,
7631
- 20
7632
- ]);
7633
- if (!!this.timing.ensureLoadedAdFitsBudget(fallbackPreloaded.adController)) return [
7634
- 3,
7635
- 17
7636
- ];
7637
- this.timing.rejectLoadedAdForDuration(fallbackPreloaded.adController);
7638
- this.startContinuousFetching(baseVastUrl);
7639
- return [
7640
- 4,
7641
- this.tryNextAvailableAdWithRateLimit()
7642
- ];
7643
- case 16:
7644
- _state.sent();
7645
- return [
7646
- 2
7647
- ];
7648
- case 17:
7649
- this.swapToPreloadedAdPlayer(fallbackPreloaded.adController);
7650
- this.timing.consecutiveFailures = 0;
7651
- this.startContinuousFetching(baseVastUrl);
7652
- if (!this.optimizedPodsEnabled && !this.preloadPool.active) {
7653
- this.preloadPool.active = true;
7654
- this.preloadPool.preloadPoolLoop(baseVastUrl);
7655
- }
7656
- ap = this.host.getAdPlayer();
7657
- return [
7658
- 4,
7659
- ap.play()
7660
- ];
7661
- case 18:
7662
- _state.sent();
7663
- this.timing.markAdStarted();
7664
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7665
- this.timing.scheduleAdStopAtBreakBoundary();
7666
- }
7667
- adVolume2 = currentMuted ? 0 : currentVolume;
7668
- ap.setAdVolume(adVolume2);
7669
- return [
7670
- 2
7671
- ];
7672
- case 19:
7673
- fallbackError = _state.sent();
7674
- if (this.debug) {
7675
- console.warn("[CONTINUOUS-FETCH] Preloaded fallback also failed:", fallbackError);
7676
- }
7677
- return [
7678
- 3,
7679
- 20
7680
- ];
7681
- case 20:
7682
- if (this.timing.isTemporaryAdError(error)) {
7683
- this.timing.temporaryFailureUrls.set(firstAdUrl, Date.now());
7684
- if (this.debug) {
7685
- console.log("[CONTINUOUS-FETCH] First ad had temporary error (no-fill) - will try alternatives");
7686
- }
7687
- } else {
7688
- this.timing.failedVastUrls.add(firstAdUrl);
7689
- if (this.debug) {
7690
- console.log("[CONTINUOUS-FETCH] First ad had permanent error - URL blacklisted");
7691
- }
7692
- }
7693
- this.timing.consecutiveFailures++;
7694
- this.startContinuousFetching(baseVastUrl);
7695
- return [
7696
- 4,
7697
- this.tryNextAvailableAdWithRateLimit()
7698
- ];
7699
- case 21:
7700
- _state.sent();
7701
- return [
7702
- 3,
7703
- 22
7704
- ];
7705
- case 22:
7706
6940
  return [
7707
6941
  2
7708
6942
  ];
@@ -7776,7 +7010,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7776
7010
  ];
7777
7011
  }
7778
7012
  if (this.debug) {
7779
- 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"));
7780
7014
  }
7781
7015
  sendAdLoadedTracking(this.host.config.licenseKey, {
7782
7016
  source: "hls",
@@ -7796,10 +7030,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7796
7030
  }
7797
7031
  adPlayer.setAdVolume(currentMuted ? 0 : currentVolume);
7798
7032
  this.timing.consecutiveFailures = 0;
7799
- if (podCount === 1) {
7800
- this.continuousFetchingActive = true;
7801
- this.startContinuousFetching(baseVastUrl);
7802
- }
7033
+ this.continuousFetchingActive = true;
7034
+ this.startContinuousFetching(baseVastUrl);
7803
7035
  return [
7804
7036
  2,
7805
7037
  true
@@ -7832,20 +7064,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7832
7064
  }).call(this);
7833
7065
  }
7834
7066
  },
7835
- {
7836
- key: "swapToPreloadedAdPlayer",
7837
- value: function swapToPreloadedAdPlayer(preloadedController) {
7838
- var adPlayer = this.host.getAdPlayer();
7839
- var preservedMuted = adPlayer.getOriginalMutedState();
7840
- var preservedVolume = adPlayer.getOriginalVolume();
7841
- adPlayer.destroy();
7842
- this.host.video.muted = true;
7843
- this.host.setAdPlayer(preloadedController);
7844
- this.attachImaEventListeners();
7845
- preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
7846
- preloadedController.resume();
7847
- }
7848
- },
7849
7067
  {
7850
7068
  // ───────────────────────────────────────────────────────────────
7851
7069
  // Continuous fetching
@@ -8096,7 +7314,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8096
7314
  value: function tryNextAvailableAd() {
8097
7315
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
8098
7316
  return _async_to_generator(function() {
8099
- var remaining, preloaded, ap, error, nextAdUrl, error1, errorMessage, maxRetries;
7317
+ var remaining, nextAdUrl, error, errorMessage, maxRetries;
8100
7318
  return _ts_generator(this, function(_state) {
8101
7319
  switch(_state.label){
8102
7320
  case 0:
@@ -8134,132 +7352,71 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8134
7352
  ];
8135
7353
  }
8136
7354
  this.timing.cleanupTemporaryFailures();
8137
- preloaded = this.preloadPool.getPreloadedAd();
8138
- if (!preloaded) return [
8139
- 3,
8140
- 6
8141
- ];
8142
- if (this.debug) {
8143
- console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool");
8144
- }
8145
- sendAdLoadedTracking(this.host.config.licenseKey, {
8146
- source: "hls",
8147
- vastUrl: preloaded.vastUrl,
8148
- timestamp: /* @__PURE__ */ new Date().toISOString()
8149
- }, this.analyticsContext).catch(function() {});
8150
7355
  _state.label = 1;
8151
7356
  case 1:
8152
- _state.trys.push([
8153
- 1,
8154
- 5,
8155
- ,
8156
- 6
8157
- ]);
8158
- if (!!this.timing.ensureLoadedAdFitsBudget(preloaded.adController)) return [
8159
- 3,
8160
- 3
8161
- ];
8162
- this.timing.rejectLoadedAdForDuration(preloaded.adController);
8163
- return [
8164
- 4,
8165
- this.tryNextAvailableAdWithRateLimit()
8166
- ];
8167
- case 2:
8168
- _state.sent();
8169
- return [
8170
- 2
8171
- ];
8172
- case 3:
8173
- this.swapToPreloadedAdPlayer(preloaded.adController);
8174
- ap = this.host.getAdPlayer();
8175
- return [
8176
- 4,
8177
- ap.play()
8178
- ];
8179
- case 4:
8180
- _state.sent();
8181
- this.timing.markAdStarted();
8182
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
8183
- this.timing.scheduleAdStopAtBreakBoundary();
8184
- }
8185
- ap.setAdVolume(getAdAudioVolume(ap));
8186
- this.timing.consecutiveFailures = 0;
8187
- return [
8188
- 2
8189
- ];
8190
- case 5:
8191
- error = _state.sent();
8192
- if (this.debug) {
8193
- console.warn("[CONTINUOUS-FETCH] Preloaded ad failed to play:", error);
8194
- }
8195
- return [
8196
- 3,
8197
- 6
8198
- ];
8199
- case 6:
8200
7357
  if (!(this.adRequestQueue.length > 0)) return [
8201
7358
  3,
8202
- 14
7359
+ 9
8203
7360
  ];
8204
7361
  nextAdUrl = this.adRequestQueue.shift();
8205
7362
  if (!nextAdUrl) return [
8206
7363
  3,
8207
- 6
7364
+ 1
8208
7365
  ];
8209
7366
  if (this.timing.failedVastUrls.has(nextAdUrl)) {
8210
7367
  if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping permanently-failed URL, trying next...");
8211
7368
  return [
8212
7369
  3,
8213
- 6
7370
+ 1
8214
7371
  ];
8215
7372
  }
8216
7373
  if (this.timing.isUrlInCooldown(nextAdUrl)) {
8217
7374
  if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping URL in cooldown (recent no-fill), trying next...");
8218
7375
  return [
8219
7376
  3,
8220
- 6
7377
+ 1
8221
7378
  ];
8222
7379
  }
8223
7380
  if (this.debug) {
8224
7381
  console.log("[CONTINUOUS-FETCH] Requesting next ad via HLS ad player (".concat(this.timing.currentAdIndex + 1, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
8225
7382
  }
8226
- _state.label = 7;
8227
- case 7:
7383
+ _state.label = 2;
7384
+ case 2:
8228
7385
  _state.trys.push([
8229
- 7,
8230
- 9,
7386
+ 2,
7387
+ 4,
8231
7388
  ,
8232
- 13
7389
+ 8
8233
7390
  ]);
8234
7391
  return [
8235
7392
  4,
8236
7393
  this.playSingleAd(nextAdUrl)
8237
7394
  ];
8238
- case 8:
7395
+ case 3:
8239
7396
  _state.sent();
8240
7397
  this.timing.consecutiveFailures = 0;
8241
7398
  return [
8242
7399
  3,
8243
- 13
7400
+ 8
8244
7401
  ];
8245
- case 9:
8246
- error1 = _state.sent();
8247
- errorMessage = error1.message;
7402
+ case 4:
7403
+ error = _state.sent();
7404
+ errorMessage = error.message;
8248
7405
  if (this.debug) console.log("[CONTINUOUS-FETCH] Ad request failed:", errorMessage);
8249
7406
  if (!errorMessage.includes("ad_duration_exceeds_budget")) return [
8250
7407
  3,
8251
- 11
7408
+ 6
8252
7409
  ];
8253
7410
  return [
8254
7411
  4,
8255
7412
  this.tryNextAvailableAdWithRateLimit()
8256
7413
  ];
8257
- case 10:
7414
+ case 5:
8258
7415
  _state.sent();
8259
7416
  return [
8260
7417
  2
8261
7418
  ];
8262
- case 11:
7419
+ case 6:
8263
7420
  if (!errorMessage.includes("permanently failed") && !errorMessage.includes("in cooldown")) {
8264
7421
  this.timing.consecutiveFailures++;
8265
7422
  }
@@ -8267,21 +7424,21 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8267
7424
  4,
8268
7425
  this.tryNextAvailableAdWithRateLimit()
8269
7426
  ];
8270
- case 12:
7427
+ case 7:
8271
7428
  _state.sent();
8272
7429
  return [
8273
7430
  3,
8274
- 13
7431
+ 8
8275
7432
  ];
8276
- case 13:
7433
+ case 8:
8277
7434
  return [
8278
7435
  2
8279
7436
  ];
8280
- case 14:
7437
+ case 9:
8281
7438
  maxRetries = 3;
8282
7439
  if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
8283
7440
  3,
8284
- 17
7441
+ 12
8285
7442
  ];
8286
7443
  if (this.debug) {
8287
7444
  console.log("[CONTINUOUS-FETCH] Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
@@ -8292,18 +7449,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8292
7449
  return setTimeout(resolve, 500);
8293
7450
  })
8294
7451
  ];
8295
- case 15:
7452
+ case 10:
8296
7453
  _state.sent();
8297
7454
  return [
8298
7455
  4,
8299
7456
  this.tryNextAvailableAd(retryCount + 1)
8300
7457
  ];
8301
- case 16:
7458
+ case 11:
8302
7459
  _state.sent();
8303
7460
  return [
8304
7461
  2
8305
7462
  ];
8306
- case 17:
7463
+ case 12:
8307
7464
  if (!this.isShowingPlaceholder && remaining > 1e3) {
8308
7465
  this.showPlaceholderAndWaitForAds();
8309
7466
  } else {
@@ -8325,7 +7482,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8325
7482
  // ───────────────────────────────────────────────────────────────
8326
7483
  function playSingleAd(vastTagUrl) {
8327
7484
  return _async_to_generator(function() {
8328
- var adPlayer, requestToken, ap, playError, preloadedFallback, fbAp, fallbackError, error, errorMessage, preloadedFallback1, fbAp1, fallbackError1;
7485
+ var adPlayer, requestToken, ap, playError, error, errorMessage;
8329
7486
  return _ts_generator(this, function(_state) {
8330
7487
  switch(_state.label){
8331
7488
  case 0:
@@ -8357,9 +7514,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8357
7514
  case 1:
8358
7515
  _state.trys.push([
8359
7516
  1,
8360
- 12,
7517
+ 8,
8361
7518
  ,
8362
- 17
7519
+ 9
8363
7520
  ]);
8364
7521
  return [
8365
7522
  4,
@@ -8395,7 +7552,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8395
7552
  4,
8396
7553
  6,
8397
7554
  ,
8398
- 11
7555
+ 7
8399
7556
  ]);
8400
7557
  this.timing.startAdFailsafeTimer(requestToken);
8401
7558
  return [
@@ -8413,55 +7570,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8413
7570
  this.timing.temporaryFailureUrls.delete(vastTagUrl);
8414
7571
  return [
8415
7572
  3,
8416
- 11
7573
+ 7
8417
7574
  ];
8418
7575
  case 6:
8419
7576
  playError = _state.sent();
8420
7577
  if (this.debug) console.error("[AD-ERROR] Failed to play ad:", playError);
8421
- preloadedFallback = this.preloadPool.getPreloadedAd();
8422
- if (!preloadedFallback) return [
8423
- 3,
8424
- 10
8425
- ];
8426
- if (this.debug) console.log("[AD-ERROR] Play failed, trying preloaded fallback ad");
8427
- _state.label = 7;
8428
- case 7:
8429
- _state.trys.push([
8430
- 7,
8431
- 9,
8432
- ,
8433
- 10
8434
- ]);
8435
- if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback.adController)) {
8436
- this.timing.rejectLoadedAdForDuration(preloadedFallback.adController);
8437
- throw playError;
8438
- }
8439
- this.timing.clearAdFailsafeTimer();
8440
- this.swapToPreloadedAdPlayer(preloadedFallback.adController);
8441
- this.timing.consecutiveFailures = 0;
8442
- fbAp = this.host.getAdPlayer();
8443
- return [
8444
- 4,
8445
- fbAp.play()
8446
- ];
8447
- case 8:
8448
- _state.sent();
8449
- this.timing.markAdStarted();
8450
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
8451
- this.timing.scheduleAdStopAtBreakBoundary();
8452
- }
8453
- fbAp.setAdVolume(getAdAudioVolume(fbAp));
8454
- return [
8455
- 2
8456
- ];
8457
- case 9:
8458
- fallbackError = _state.sent();
8459
- if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError);
8460
- return [
8461
- 3,
8462
- 10
8463
- ];
8464
- case 10:
8465
7578
  if (this.timing.isTemporaryAdError(playError)) {
8466
7579
  this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
8467
7580
  if (this.debug) console.log("[AD-ERROR] Temporary play error - URL can be retried after cooldown");
@@ -8474,57 +7587,15 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8474
7587
  this.timing.activeAdRequestToken = null;
8475
7588
  }
8476
7589
  throw playError;
8477
- case 11:
7590
+ case 7:
8478
7591
  return [
8479
7592
  3,
8480
- 17
7593
+ 9
8481
7594
  ];
8482
- case 12:
7595
+ case 8:
8483
7596
  error = _state.sent();
8484
7597
  errorMessage = (error === null || error === void 0 ? void 0 : error.message) || "";
8485
7598
  if (this.debug) console.error("[AD-ERROR] Ad request failed:", errorMessage);
8486
- preloadedFallback1 = this.preloadPool.getPreloadedAd();
8487
- if (!preloadedFallback1) return [
8488
- 3,
8489
- 16
8490
- ];
8491
- if (this.debug) console.log("[AD-ERROR] Request failed, trying preloaded fallback ad");
8492
- _state.label = 13;
8493
- case 13:
8494
- _state.trys.push([
8495
- 13,
8496
- 15,
8497
- ,
8498
- 16
8499
- ]);
8500
- if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback1.adController)) {
8501
- this.timing.rejectLoadedAdForDuration(preloadedFallback1.adController);
8502
- throw error;
8503
- }
8504
- this.timing.clearAdRequestWatchdog();
8505
- this.timing.clearAdFailsafeTimer();
8506
- this.swapToPreloadedAdPlayer(preloadedFallback1.adController);
8507
- this.timing.consecutiveFailures = 0;
8508
- fbAp1 = this.host.getAdPlayer();
8509
- return [
8510
- 4,
8511
- fbAp1.play()
8512
- ];
8513
- case 14:
8514
- _state.sent();
8515
- this.timing.markAdStarted();
8516
- fbAp1.setAdVolume(getAdAudioVolume(fbAp1));
8517
- return [
8518
- 2
8519
- ];
8520
- case 15:
8521
- fallbackError1 = _state.sent();
8522
- if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError1);
8523
- return [
8524
- 3,
8525
- 16
8526
- ];
8527
- case 16:
8528
7599
  if (this.timing.isTemporaryAdError(error)) {
8529
7600
  this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
8530
7601
  if (this.debug) console.log("[AD-ERROR] Temporary error (no-fill/timeout) - URL can be retried after cooldown");
@@ -8538,7 +7609,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8538
7609
  this.timing.activeAdRequestToken = null;
8539
7610
  }
8540
7611
  throw error;
8541
- case 17:
7612
+ case 9:
8542
7613
  return [
8543
7614
  2
8544
7615
  ];
@@ -8728,7 +7799,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8728
7799
  }
8729
7800
  this.timing.resetForBreakEnd();
8730
7801
  this.stopContinuousFetching();
8731
- this.preloadPool.stop();
8732
7802
  this.clearPendingAdBreak();
8733
7803
  if (this.isShowingPlaceholder) {
8734
7804
  this.host.getAdPlayer().hidePlaceholder();
@@ -8838,25 +7908,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8838
7908
  return _this.adBreak.handleAdFailure();
8839
7909
  }
8840
7910
  });
8841
- this.preloadPool = new AdPreloadPool({
8842
- debug: !!this.config.debugAdTiming,
8843
- createAdPlayer: function createAdPlayer(c) {
8844
- return _this.createAdPlayer(c);
8845
- },
8846
- shouldContinueLiveStreamDuringAds: function shouldContinueLiveStreamDuringAds() {
8847
- return _this.shouldContinueLiveStreamDuringAds();
8848
- },
8849
- timing: this.timing,
8850
- generateVastUrlsWithCorrelators: function generateVastUrlsWithCorrelators(base, count) {
8851
- return _this.generateVastUrls(base, count);
8852
- },
8853
- isInAdBreak: function isInAdBreak() {
8854
- return _this.adBreak.inAdBreak;
8855
- },
8856
- getPendingAdBreak: function getPendingAdBreak() {
8857
- return _this.adBreak.pendingAdBreak;
8858
- }
8859
- });
8860
7911
  this.placeholder = new PlaceholderLayer(this.video, !!this.config.debugAdTiming);
8861
7912
  this.hlsEngine = new HlsEngine(this.config, this.video, this.cueManager, this.timing, {
8862
7913
  onManifestParsed: function onManifestParsed(isLive) {
@@ -8903,13 +7954,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8903
7954
  getLiveSyncPosition: function getLiveSyncPosition() {
8904
7955
  return _this.hlsEngine.getLiveSyncPosition();
8905
7956
  },
8906
- generateVastUrls: function generateVastUrls(base, count) {
8907
- return _this.generateVastUrls(base, count);
8908
- },
8909
7957
  generatePodVastUrl: function generatePodVastUrl(base, breakDurationMs) {
8910
7958
  return _this.generatePodVastUrl(base, breakDurationMs);
8911
7959
  }
8912
- }, this.timing, this.preloadPool, this.adConfig, this.cueManager, this.placeholder);
7960
+ }, this.timing, this.adConfig, this.cueManager, this.placeholder);
8913
7961
  }
8914
7962
  _create_class(StormcloudVideoPlayer, [
8915
7963
  {
@@ -8934,12 +7982,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8934
7982
  } : {}));
8935
7983
  }
8936
7984
  },
8937
- {
8938
- key: "generateVastUrls",
8939
- value: function generateVastUrls(baseUrl, count) {
8940
- return this.adConfig.generateVastUrlsWithCorrelators(baseUrl, count, this.adPlayer, this.palNonce, this.adBreak.inAdBreak);
8941
- }
8942
- },
8943
7985
  {
8944
7986
  key: "generatePodVastUrl",
8945
7987
  value: function generatePodVastUrl(baseUrl, breakDurationMs) {
@@ -9335,11 +8377,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9335
8377
  }
9336
8378
  this.adConfig.beginNewAdPod();
9337
8379
  this.adConfig.podAssignedByPrefetch = true;
9338
- var optimizedPods = this.config.optimizedPods !== false;
9339
8380
  var breakDurationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : void 0;
9340
- var generatedUrls = optimizedPods ? [
8381
+ var generatedUrls = [
9341
8382
  this.generatePodVastUrl(baseVastUrl, breakDurationMs)
9342
- ] : this.generateVastUrls(baseVastUrl, 1);
8383
+ ];
9343
8384
  this.adBreak.pendingAdBreak = _object_spread_props(_object_spread({
9344
8385
  marker: marker
9345
8386
  }, fragmentSn !== void 0 ? {
@@ -9361,15 +8402,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9361
8402
  }, detectPayload), buildAnalyticsContext(this.config)).catch(function() {});
9362
8403
  if (this.debug) {
9363
8404
  console.log("[PREFETCH] Starting ad prefetch for upcoming ad break");
9364
- console.log("[PREFETCH] Pre-generated ".concat(generatedUrls.length, " ").concat(optimizedPods ? "pod" : "VAST", " URL(s)"));
9365
- }
9366
- if (optimizedPods) {
9367
- if (this.debug) {
9368
- console.log("[PREFETCH] Optimized pods enabled - skipping single-ad preload pool");
9369
- }
9370
- return;
8405
+ console.log("[PREFETCH] Pre-generated pod request URL");
9371
8406
  }
9372
- this.preloadPool.startPreloadPool(baseVastUrl, generatedUrls.slice(0, 1), false);
9373
8407
  }
9374
8408
  },
9375
8409
  {
@@ -9608,7 +8642,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9608
8642
  value: function destroy() {
9609
8643
  var _this_adPlayer;
9610
8644
  this.adBreak.stopContinuousFetching();
9611
- this.preloadPool.stop();
9612
8645
  this.timing.destroy();
9613
8646
  this.adBreak.clearPendingAdBreak();
9614
8647
  this.placeholder.destroy();