stormcloud-video-player 0.8.28 → 0.8.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/stormcloud-vp.min.js +2 -2
  2. package/lib/index.cjs +80 -1038
  3. package/lib/index.cjs.map +1 -1
  4. package/lib/index.d.cts +0 -3
  5. package/lib/index.d.ts +0 -3
  6. package/lib/index.js +80 -1039
  7. package/lib/index.js.map +1 -1
  8. package/lib/player/AdBreakOrchestrator.cjs +59 -483
  9. package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
  10. package/lib/player/AdBreakOrchestrator.d.cts +9 -7
  11. package/lib/player/AdConfigManager.cjs +12 -53
  12. package/lib/player/AdConfigManager.cjs.map +1 -1
  13. package/lib/player/AdConfigManager.d.cts +4 -5
  14. package/lib/player/AdTimingService.d.cts +1 -1
  15. package/lib/player/HlsEngine.d.cts +1 -1
  16. package/lib/player/PlayerControls.d.cts +1 -1
  17. package/lib/player/Scte35CueManager.d.cts +1 -1
  18. package/lib/player/Scte35Parser.d.cts +1 -1
  19. package/lib/player/StormcloudVideoPlayer.cjs +80 -1038
  20. package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
  21. package/lib/player/StormcloudVideoPlayer.d.cts +1 -3
  22. package/lib/player/playerTypes.d.cts +1 -1
  23. package/lib/players/HlsPlayer.cjs +80 -1038
  24. package/lib/players/HlsPlayer.cjs.map +1 -1
  25. package/lib/players/HlsPlayer.d.cts +1 -1
  26. package/lib/players/index.cjs +80 -1038
  27. package/lib/players/index.cjs.map +1 -1
  28. package/lib/sdk/hlsAdPlayer.d.cts +1 -1
  29. package/lib/{types-Xgz2_W1C.d.cts → types-CSHvCbhZ.d.cts} +0 -1
  30. package/lib/ui/StormcloudVideoPlayer.cjs +80 -1038
  31. package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
  32. package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
  33. package/lib/utils/tracking.d.cts +1 -1
  34. package/lib/utils/vastMacros.cjs +10 -15
  35. package/lib/utils/vastMacros.cjs.map +1 -1
  36. package/lib/utils/vastMacros.d.cts +0 -1
  37. package/package.json +1 -1
  38. package/lib/player/AdPreloadPool.cjs +0 -673
  39. package/lib/player/AdPreloadPool.cjs.map +0 -1
  40. package/lib/player/AdPreloadPool.d.cts +0 -37
package/lib/index.js CHANGED
@@ -3463,21 +3463,16 @@ function applyVastMacros(baseUrl, ctx) {
3463
3463
  if (ctx.pod != null) {
3464
3464
  params.set("pod", String(ctx.pod));
3465
3465
  }
3466
- var optimizedPodMode = ctx.podMaxAds != null || ctx.podMinDurationMs != null || ctx.podMaxDurationMs != null;
3467
- if (optimizedPodMode) {
3468
- params.delete("ppos");
3469
- params.delete("lip");
3470
- if (ctx.podMinDurationMs != null) {
3471
- params.set("pmnd", String(Math.max(0, Math.round(ctx.podMinDurationMs))));
3472
- }
3473
- if (ctx.podMaxDurationMs != null) {
3474
- params.set("pmxd", String(Math.max(0, Math.round(ctx.podMaxDurationMs))));
3475
- }
3476
- if (ctx.podMaxAds != null) {
3477
- params.set("pmad", String(Math.max(1, Math.round(ctx.podMaxAds))));
3478
- }
3479
- } else if (ctx.adPosition != null) {
3480
- params.set("ppos", String(ctx.adPosition));
3466
+ params.delete("ppos");
3467
+ params.delete("lip");
3468
+ if (ctx.podMinDurationMs != null) {
3469
+ params.set("pmnd", String(Math.max(0, Math.round(ctx.podMinDurationMs))));
3470
+ }
3471
+ if (ctx.podMaxDurationMs != null) {
3472
+ params.set("pmxd", String(Math.max(0, Math.round(ctx.podMaxDurationMs))));
3473
+ }
3474
+ if (ctx.podMaxAds != null) {
3475
+ params.set("pmad", String(Math.max(1, Math.round(ctx.podMaxAds))));
3481
3476
  }
3482
3477
  var requestUrl = ctx.contentUrl || ctx.pageUrl;
3483
3478
  if (requestUrl) {
@@ -4843,9 +4838,9 @@ var AdConfigManager = /*#__PURE__*/ function() {
4843
4838
  this.consentSignals = {};
4844
4839
  this.podCounter = 0;
4845
4840
  this.podAssignedByPrefetch = false;
4846
- this.adRequestPositionInBreak = 0;
4847
4841
  this.lastHeartbeatTime = 0;
4848
4842
  this.defaultPodMaxAds = 6;
4843
+ this.defaultPodMaxDurationMs = 12e4;
4849
4844
  this.config = config;
4850
4845
  this.video = video;
4851
4846
  }
@@ -5263,48 +5258,12 @@ var AdConfigManager = /*#__PURE__*/ function() {
5263
5258
  key: "beginNewAdPod",
5264
5259
  value: function beginNewAdPod() {
5265
5260
  this.podCounter++;
5266
- this.adRequestPositionInBreak = 0;
5267
- }
5268
- },
5269
- {
5270
- key: "generateVastUrlsWithCorrelators",
5271
- value: function generateVastUrlsWithCorrelators(baseUrl, count, adPlayer, palNonce, inAdBreak) {
5272
- var urls = [];
5273
- for(var i = 0; i < count; i++){
5274
- this.adRequestPositionInBreak++;
5275
- var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
5276
- var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest);
5277
- var urlWithMacros = applyVastMacros(baseUrl, {
5278
- correlator: this.viewCorrelator,
5279
- streamCorrelator: this.streamCorrelator,
5280
- pod: this.podCounter > 0 ? this.podCounter : void 0,
5281
- adPosition: this.adRequestPositionInBreak,
5282
- isCtv: envSignals.isCtv,
5283
- contentUrl: envSignals.contentUrl,
5284
- pageUrl: !envSignals.isCtv && typeof window !== "undefined" ? window.location.href : void 0,
5285
- adWillPlayMuted: adWillPlayMuted,
5286
- adWillAutoPlay: !!this.config.autoplay,
5287
- appId: envSignals.appId,
5288
- appName: envSignals.appName,
5289
- sessionId: envSignals.sessionId,
5290
- deviceId: envSignals.deviceId,
5291
- deviceIdType: envSignals.deviceIdType,
5292
- limitAdTracking: envSignals.limitAdTracking,
5293
- deviceTypeHint: envSignals.deviceTypeHint,
5294
- adTest: this.config.adTest,
5295
- consent: this.consentSignals
5296
- });
5297
- var finalUrl = palNonce.injectNonce(urlWithMacros);
5298
- console.log("[StormcloudVideoPlayer] Resolved ad request URL (pod=".concat(this.podCounter, ", pos=").concat(this.adRequestPositionInBreak, "):"), finalUrl);
5299
- urls.push(finalUrl);
5300
- }
5301
- return urls;
5302
5261
  }
5303
5262
  },
5304
5263
  {
5305
5264
  key: "resolvePodParams",
5306
5265
  value: function resolvePodParams(breakDurationMs) {
5307
- var maxDurationMs = breakDurationMs != null && breakDurationMs > 0 ? breakDurationMs : this.config.podMaxDurationMs;
5266
+ var maxDurationMs = breakDurationMs != null && breakDurationMs > 0 ? breakDurationMs : this.config.podMaxDurationMs != null && this.config.podMaxDurationMs > 0 ? this.config.podMaxDurationMs : this.defaultPodMaxDurationMs;
5308
5267
  var maxAds = this.config.podMaxAds && this.config.podMaxAds > 0 ? this.config.podMaxAds : this.apiNumberAds && this.apiNumberAds > 0 ? this.apiNumberAds : this.defaultPodMaxAds;
5309
5268
  var minDurationMs = this.config.podExactDuration && maxDurationMs != null ? maxDurationMs : 0;
5310
5269
  return {
@@ -5958,463 +5917,6 @@ var AdTimingService = /*#__PURE__*/ function() {
5958
5917
  ]);
5959
5918
  return AdTimingService;
5960
5919
  }();
5961
- // src/player/AdPreloadPool.ts
5962
- var AdPreloadPool = /*#__PURE__*/ function() {
5963
- "use strict";
5964
- function AdPreloadPool(deps) {
5965
- _class_call_check(this, AdPreloadPool);
5966
- this.pool = [];
5967
- this.maxPoolSize = 2;
5968
- this.poolActive = false;
5969
- this.loopRunning = false;
5970
- this.deps = deps;
5971
- }
5972
- _create_class(AdPreloadPool, [
5973
- {
5974
- key: "active",
5975
- get: function get() {
5976
- return this.poolActive;
5977
- },
5978
- set: function set(value) {
5979
- this.poolActive = value;
5980
- }
5981
- },
5982
- {
5983
- key: "isLoopRunning",
5984
- get: function get() {
5985
- return this.loopRunning;
5986
- }
5987
- },
5988
- {
5989
- key: "startPreloadPool",
5990
- value: function startPreloadPool(baseVastUrl, initialUrls) {
5991
- var startLoopImmediately = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
5992
- if (this.poolActive) {
5993
- if (this.deps.debug) {
5994
- console.log("[PRELOAD-POOL] Already active, skipping duplicate start");
5995
- }
5996
- return;
5997
- }
5998
- this.poolActive = true;
5999
- if (this.deps.debug) {
6000
- console.log("[PRELOAD-POOL] Starting preload pool EARLY (target size: ".concat(this.maxPoolSize, ")"));
6001
- console.log("[PRELOAD-POOL] Ad break hasn't started yet, but preloading ads in advance");
6002
- }
6003
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6004
- try {
6005
- for(var _iterator = initialUrls[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6006
- var url = _step.value;
6007
- if (this.pool.length < this.maxPoolSize) {
6008
- this.preloadAdIntoPool(url);
6009
- }
6010
- }
6011
- } catch (err) {
6012
- _didIteratorError = true;
6013
- _iteratorError = err;
6014
- } finally{
6015
- try {
6016
- if (!_iteratorNormalCompletion && _iterator.return != null) {
6017
- _iterator.return();
6018
- }
6019
- } finally{
6020
- if (_didIteratorError) {
6021
- throw _iteratorError;
6022
- }
6023
- }
6024
- }
6025
- if (startLoopImmediately) {
6026
- this.preloadPoolLoop(baseVastUrl);
6027
- } else if (this.deps.debug) {
6028
- console.log("[PRELOAD-POOL] Pre-break mode: preloaded once, waiting for SCTE start to continue fetching");
6029
- }
6030
- }
6031
- },
6032
- {
6033
- key: "preloadAdIntoPool",
6034
- value: function preloadAdIntoPool(vastUrl) {
6035
- return _async_to_generator(function() {
6036
- var _this, timing, epoch, loadPromise;
6037
- return _ts_generator(this, function(_state) {
6038
- _this = this;
6039
- timing = this.deps.timing;
6040
- if (timing.isGamInCooldown()) {
6041
- if (this.deps.debug) {
6042
- console.log("[CIRCUIT-BREAKER] GAM in cooldown, skipping preload");
6043
- }
6044
- return [
6045
- 2
6046
- ];
6047
- }
6048
- if (this.pool.some(function(entry) {
6049
- return entry.vastUrl === vastUrl;
6050
- }) || timing.failedVastUrls.has(vastUrl) || timing.isUrlInCooldown(vastUrl)) {
6051
- return [
6052
- 2
6053
- ];
6054
- }
6055
- if (this.pool.length >= this.maxPoolSize) {
6056
- return [
6057
- 2
6058
- ];
6059
- }
6060
- if (this.deps.debug) {
6061
- console.log("[PRELOAD-POOL] Preloading ad into pool: ".concat(vastUrl));
6062
- }
6063
- epoch = timing.adBreakEpoch;
6064
- loadPromise = function() {
6065
- return _async_to_generator(function() {
6066
- var _this, hasAdError, adErrorPayload, errorListenerCleanup, _preloadAd_getLoadedAdDuration, continueLiveStreamDuringAds, preloadAd, errorListener, isNoFill, poolEntry, loadedDuration, lateErrorListener, _poolEntry_durationSeconds, error;
6067
- return _ts_generator(this, function(_state) {
6068
- switch(_state.label){
6069
- case 0:
6070
- _this = this;
6071
- hasAdError = false;
6072
- adErrorPayload = null;
6073
- errorListenerCleanup = null;
6074
- _state.label = 1;
6075
- case 1:
6076
- _state.trys.push([
6077
- 1,
6078
- 5,
6079
- ,
6080
- 6
6081
- ]);
6082
- continueLiveStreamDuringAds = this.deps.shouldContinueLiveStreamDuringAds();
6083
- preloadAd = this.deps.createAdPlayer(continueLiveStreamDuringAds);
6084
- preloadAd.initialize();
6085
- errorListener = function errorListener(payload) {
6086
- hasAdError = true;
6087
- adErrorPayload = payload;
6088
- };
6089
- preloadAd.on("ad_error", errorListener);
6090
- errorListenerCleanup = function errorListenerCleanup() {
6091
- return preloadAd.off("ad_error", errorListener);
6092
- };
6093
- return [
6094
- 4,
6095
- timing.enforceGlobalRateLimit()
6096
- ];
6097
- case 2:
6098
- _state.sent();
6099
- return [
6100
- 4,
6101
- preloadAd.requestAds(vastUrl)
6102
- ];
6103
- case 3:
6104
- _state.sent();
6105
- preloadAd.pause();
6106
- return [
6107
- 4,
6108
- new Promise(function(resolve) {
6109
- return setTimeout(resolve, 1500);
6110
- })
6111
- ];
6112
- case 4:
6113
- _state.sent();
6114
- preloadAd.pause();
6115
- if (hasAdError) {
6116
- 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;
6117
- if (errorListenerCleanup) {
6118
- errorListenerCleanup();
6119
- }
6120
- preloadAd.destroy();
6121
- timing.recordGamNoFill();
6122
- if (isNoFill) {
6123
- if (this.deps.debug) {
6124
- console.log("[PRELOAD-POOL] Ad preload returned no-fill: ".concat(vastUrl));
6125
- }
6126
- timing.temporaryFailureUrls.set(vastUrl, Date.now());
6127
- } else {
6128
- if (this.deps.debug) {
6129
- console.log("[PRELOAD-POOL] Ad preload failed with error: ".concat(vastUrl), adErrorPayload);
6130
- }
6131
- if (adErrorPayload && !timing.isTemporaryAdError(adErrorPayload)) {
6132
- timing.failedVastUrls.add(vastUrl);
6133
- } else {
6134
- timing.temporaryFailureUrls.set(vastUrl, Date.now());
6135
- }
6136
- }
6137
- return [
6138
- 2
6139
- ];
6140
- }
6141
- if (!this.poolActive || epoch !== timing.adBreakEpoch) {
6142
- if (this.deps.debug) {
6143
- console.log("[PRELOAD-POOL] Discarding preloaded ad - break ended during fetch");
6144
- }
6145
- if (errorListenerCleanup) {
6146
- errorListenerCleanup();
6147
- }
6148
- try {
6149
- preloadAd.destroy();
6150
- } catch (unused) {}
6151
- return [
6152
- 2
6153
- ];
6154
- }
6155
- poolEntry = {
6156
- vastUrl: vastUrl,
6157
- adController: preloadAd,
6158
- loadedAt: Date.now(),
6159
- isReady: true,
6160
- loadPromise: Promise.resolve()
6161
- };
6162
- loadedDuration = (_preloadAd_getLoadedAdDuration = preloadAd.getLoadedAdDuration) === null || _preloadAd_getLoadedAdDuration === void 0 ? void 0 : _preloadAd_getLoadedAdDuration.call(preloadAd);
6163
- if (loadedDuration != null && loadedDuration > 0) {
6164
- poolEntry.durationSeconds = loadedDuration;
6165
- }
6166
- lateErrorListener = function lateErrorListener(payload) {
6167
- var index = _this.pool.findIndex(function(entry) {
6168
- return entry.vastUrl === vastUrl;
6169
- });
6170
- if (index >= 0) {
6171
- _this.pool.splice(index, 1);
6172
- if (_this.deps.debug) {
6173
- console.log("[PRELOAD-POOL] Late error detected, removed from pool: ".concat(vastUrl), payload);
6174
- }
6175
- try {
6176
- preloadAd.destroy();
6177
- } catch (unused) {}
6178
- }
6179
- };
6180
- preloadAd.on("ad_error", lateErrorListener);
6181
- this.pool.push(poolEntry);
6182
- if (this.deps.debug) {
6183
- ;
6184
- 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)"));
6185
- }
6186
- if (errorListenerCleanup) {
6187
- errorListenerCleanup();
6188
- }
6189
- return [
6190
- 3,
6191
- 6
6192
- ];
6193
- case 5:
6194
- error = _state.sent();
6195
- if (errorListenerCleanup) {
6196
- errorListenerCleanup();
6197
- }
6198
- timing.recordGamNoFill();
6199
- if (this.deps.debug) {
6200
- console.warn("[PRELOAD-POOL] Failed to preload ad: ".concat(vastUrl), error);
6201
- }
6202
- if (_instanceof(error, Error) && !timing.isTemporaryAdError(error)) {
6203
- timing.failedVastUrls.add(vastUrl);
6204
- } else if (_instanceof(error, Error) && timing.isTemporaryAdError(error)) {
6205
- timing.temporaryFailureUrls.set(vastUrl, Date.now());
6206
- }
6207
- return [
6208
- 3,
6209
- 6
6210
- ];
6211
- case 6:
6212
- return [
6213
- 2
6214
- ];
6215
- }
6216
- });
6217
- }).call(_this);
6218
- }();
6219
- loadPromise.catch(function() {});
6220
- return [
6221
- 2
6222
- ];
6223
- });
6224
- }).call(this);
6225
- }
6226
- },
6227
- {
6228
- key: "preloadPoolLoop",
6229
- value: function preloadPoolLoop(baseVastUrl) {
6230
- return _async_to_generator(function() {
6231
- var epoch, newUrls, newUrl;
6232
- return _ts_generator(this, function(_state) {
6233
- switch(_state.label){
6234
- case 0:
6235
- if (this.loopRunning) {
6236
- return [
6237
- 2
6238
- ];
6239
- }
6240
- this.loopRunning = true;
6241
- epoch = this.deps.timing.adBreakEpoch;
6242
- if (this.deps.debug) {
6243
- console.log("[PRELOAD-POOL] Starting continuous preload loop");
6244
- }
6245
- _state.label = 1;
6246
- case 1:
6247
- if (!(this.poolActive && epoch === this.deps.timing.adBreakEpoch)) return [
6248
- 3,
6249
- 10
6250
- ];
6251
- if (this.deps.timing.isGamInCooldown()) {
6252
- if (this.deps.debug) {
6253
- console.log("[CIRCUIT-BREAKER] GAM in cooldown, stopping preload pool loop");
6254
- }
6255
- return [
6256
- 3,
6257
- 10
6258
- ];
6259
- }
6260
- if (!(!this.deps.isInAdBreak() && this.pool.length >= this.maxPoolSize)) return [
6261
- 3,
6262
- 3
6263
- ];
6264
- return [
6265
- 4,
6266
- new Promise(function(resolve) {
6267
- return setTimeout(resolve, 2e3);
6268
- })
6269
- ];
6270
- case 2:
6271
- _state.sent();
6272
- return [
6273
- 3,
6274
- 1
6275
- ];
6276
- case 3:
6277
- if (!this.deps.isInAdBreak() && this.deps.getPendingAdBreak() === null) {
6278
- if (this.deps.debug) {
6279
- console.log("[PRELOAD-POOL] Ad break cancelled, stopping preload pool");
6280
- }
6281
- return [
6282
- 3,
6283
- 10
6284
- ];
6285
- }
6286
- _state.label = 4;
6287
- case 4:
6288
- if (!(this.pool.length < this.maxPoolSize)) return [
6289
- 3,
6290
- 8
6291
- ];
6292
- if (!this.poolActive || epoch !== this.deps.timing.adBreakEpoch || this.deps.timing.isGamInCooldown()) {
6293
- return [
6294
- 3,
6295
- 8
6296
- ];
6297
- }
6298
- if (this.deps.isInAdBreak() && !this.deps.timing.hasTimeToStartAnotherAd()) {
6299
- if (this.deps.debug) {
6300
- console.log("[PRELOAD-POOL] Not enough ad break time left, stopping preload");
6301
- }
6302
- return [
6303
- 3,
6304
- 8
6305
- ];
6306
- }
6307
- newUrls = this.deps.generateVastUrlsWithCorrelators(baseVastUrl, 1);
6308
- newUrl = newUrls[0];
6309
- if (!(newUrl && !this.deps.timing.failedVastUrls.has(newUrl) && !this.deps.timing.isUrlInCooldown(newUrl))) return [
6310
- 3,
6311
- 6
6312
- ];
6313
- return [
6314
- 4,
6315
- this.preloadAdIntoPool(newUrl)
6316
- ];
6317
- case 5:
6318
- _state.sent();
6319
- _state.label = 6;
6320
- case 6:
6321
- return [
6322
- 4,
6323
- new Promise(function(resolve) {
6324
- return setTimeout(resolve, 1e3);
6325
- })
6326
- ];
6327
- case 7:
6328
- _state.sent();
6329
- return [
6330
- 3,
6331
- 4
6332
- ];
6333
- case 8:
6334
- return [
6335
- 4,
6336
- new Promise(function(resolve) {
6337
- return setTimeout(resolve, 2e3);
6338
- })
6339
- ];
6340
- case 9:
6341
- _state.sent();
6342
- return [
6343
- 3,
6344
- 1
6345
- ];
6346
- case 10:
6347
- this.loopRunning = false;
6348
- if (this.deps.debug) {
6349
- console.log("[PRELOAD-POOL] Preload loop ended");
6350
- }
6351
- return [
6352
- 2
6353
- ];
6354
- }
6355
- });
6356
- }).call(this);
6357
- }
6358
- },
6359
- {
6360
- key: "getPreloadedAd",
6361
- value: function getPreloadedAd() {
6362
- if (this.pool.length === 0) {
6363
- return null;
6364
- }
6365
- var entry = this.pool.shift();
6366
- if (!entry || !entry.isReady) {
6367
- return null;
6368
- }
6369
- if (this.deps.debug) {
6370
- console.log("[PRELOAD-POOL] Using preloaded ad from pool (".concat(this.pool.length, " remaining)"));
6371
- }
6372
- return {
6373
- vastUrl: entry.vastUrl,
6374
- adController: entry.adController
6375
- };
6376
- }
6377
- },
6378
- {
6379
- key: "stop",
6380
- value: function stop() {
6381
- this.poolActive = false;
6382
- this.loopRunning = false;
6383
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6384
- try {
6385
- for(var _iterator = this.pool[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6386
- var entry = _step.value;
6387
- try {
6388
- entry.adController.destroy();
6389
- } catch (error) {
6390
- if (this.deps.debug) {
6391
- console.warn("[PRELOAD-POOL] Error destroying preloaded controller:", error);
6392
- }
6393
- }
6394
- }
6395
- } catch (err) {
6396
- _didIteratorError = true;
6397
- _iteratorError = err;
6398
- } finally{
6399
- try {
6400
- if (!_iteratorNormalCompletion && _iterator.return != null) {
6401
- _iterator.return();
6402
- }
6403
- } finally{
6404
- if (_didIteratorError) {
6405
- throw _iteratorError;
6406
- }
6407
- }
6408
- }
6409
- this.pool = [];
6410
- if (this.deps.debug) {
6411
- console.log("[PRELOAD-POOL] Preload pool stopped and cleaned up");
6412
- }
6413
- }
6414
- }
6415
- ]);
6416
- return AdPreloadPool;
6417
- }();
6418
5920
  // src/player/PlaceholderLayer.ts
6419
5921
  var PlaceholderLayer = /*#__PURE__*/ function() {
6420
5922
  "use strict";
@@ -7139,7 +6641,7 @@ function resizePlayer(video, adPlayer, debug) {
7139
6641
  // src/player/AdBreakOrchestrator.ts
7140
6642
  var AdBreakOrchestrator = /*#__PURE__*/ function() {
7141
6643
  "use strict";
7142
- function AdBreakOrchestrator(host, timing, preloadPool, adConfig, cueManager, placeholder) {
6644
+ function AdBreakOrchestrator(host, timing, adConfig, cueManager, placeholder) {
7143
6645
  _class_call_check(this, AdBreakOrchestrator);
7144
6646
  this.inAdBreak = false;
7145
6647
  this.showAds = false;
@@ -7153,7 +6655,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7153
6655
  this.pendingAdBreak = null;
7154
6656
  this.host = host;
7155
6657
  this.timing = timing;
7156
- this.preloadPool = preloadPool;
7157
6658
  this.adConfig = adConfig;
7158
6659
  this.cueManager = cueManager;
7159
6660
  this.placeholder = placeholder;
@@ -7172,12 +6673,19 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7172
6673
  }
7173
6674
  },
7174
6675
  {
7175
- key: "optimizedPodsEnabled",
7176
- get: // ───────────────────────────────────────────────────────────────
6676
+ // ───────────────────────────────────────────────────────────────
7177
6677
  // IMA event listeners
7178
6678
  // ───────────────────────────────────────────────────────────────
7179
- function get() {
7180
- return this.host.config.optimizedPods !== false;
6679
+ /**
6680
+ * Produces the next pod ad-request URL for the current break. Every request
6681
+ * (initial and continuous-fetch top-up) carries pod macros (pmad/pmnd/pmxd,
6682
+ * no ppos); pmxd tracks the remaining break time so top-up pods only ask for
6683
+ * what still fits.
6684
+ */ key: "nextAdRequestUrl",
6685
+ value: function nextAdRequestUrl(baseVastUrl) {
6686
+ var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
6687
+ var breakDurationMs = remaining > 0 ? remaining : void 0;
6688
+ return this.host.generatePodVastUrl(baseVastUrl, breakDurationMs);
7181
6689
  }
7182
6690
  },
7183
6691
  {
@@ -7349,7 +6857,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7349
6857
  // ───────────────────────────────────────────────────────────────
7350
6858
  function handleAdStart(_marker) {
7351
6859
  return _async_to_generator(function() {
7352
- 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;
6860
+ var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, podPlayed;
7353
6861
  return _ts_generator(this, function(_state) {
7354
6862
  switch(_state.label){
7355
6863
  case 0:
@@ -7396,292 +6904,29 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7396
6904
  if (this.timing.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
7397
6905
  this.timing.expectedAdBreakDurationMs = adBreakDurationMs;
7398
6906
  }
7399
- if (!this.optimizedPodsEnabled) return [
7400
- 3,
7401
- 2
7402
- ];
7403
6907
  return [
7404
6908
  4,
7405
6909
  this.startOptimizedPod(baseVastUrl, adBreakDurationMs, currentMuted, currentVolume)
7406
6910
  ];
7407
6911
  case 1:
7408
6912
  podPlayed = _state.sent();
7409
- if (podPlayed) {
7410
- return [
7411
- 2
7412
- ];
7413
- }
6913
+ if (!!podPlayed) return [
6914
+ 3,
6915
+ 3
6916
+ ];
7414
6917
  if (this.debug) {
7415
- console.log("[POD] Optimized pod unavailable, falling back to sequential single-ad path");
6918
+ console.log("[POD] Initial pod request did not fill; attempting top-up pod request");
7416
6919
  }
7417
- _state.label = 2;
6920
+ this.continuousFetchingActive = true;
6921
+ this.startContinuousFetching(baseVastUrl);
6922
+ return [
6923
+ 4,
6924
+ this.tryNextAvailableAdWithRateLimit()
6925
+ ];
7418
6926
  case 2:
7419
- usePreloadedAd = false;
7420
- preloaded = this.preloadPool.getPreloadedAd();
7421
- if (preloaded) {
7422
- firstAdUrl = preloaded.vastUrl;
7423
- preloadedController = preloaded.adController;
7424
- usePreloadedAd = true;
7425
- sendAdLoadedTracking(this.host.config.licenseKey, {
7426
- source: "hls",
7427
- vastUrl: firstAdUrl,
7428
- timestamp: /* @__PURE__ */ new Date().toISOString()
7429
- }, this.analyticsContext).catch(function() {});
7430
- if (this.debug) {
7431
- console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool (preloaded in advance, ready immediately!)");
7432
- }
7433
- } else if (this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0) {
7434
- this.adRequestQueue = _to_consumable_array(this.pendingAdBreak.vastUrls);
7435
- firstAdUrl = this.adRequestQueue.shift();
7436
- if (this.debug) {
7437
- console.log("[CONTINUOUS-FETCH] Pool empty, using prefetched URLs (".concat(this.adRequestQueue.length + 1, " available)"));
7438
- }
7439
- this.clearPendingAdBreak();
7440
- } else {
7441
- if (this.debug) {
7442
- console.log("[CONTINUOUS-FETCH] Generating new ad URLs...");
7443
- }
7444
- firstAdUrlArray = this.host.generateVastUrls(baseVastUrl, 1);
7445
- firstAdUrl = firstAdUrlArray[0];
7446
- this.adRequestQueue = [];
7447
- }
7448
- if (!firstAdUrl) {
7449
- if (this.debug) {
7450
- console.warn("[CONTINUOUS-FETCH] Failed to get first ad URL");
7451
- }
7452
- this.handleAdPodComplete();
7453
- return [
7454
- 2
7455
- ];
7456
- }
7457
- if (this.debug) {
7458
- console.log("[CONTINUOUS-FETCH] First VAST URL:", firstAdUrl);
7459
- }
6927
+ _state.sent();
7460
6928
  _state.label = 3;
7461
6929
  case 3:
7462
- _state.trys.push([
7463
- 3,
7464
- 14,
7465
- ,
7466
- 22
7467
- ]);
7468
- if (!(usePreloadedAd && preloadedController)) return [
7469
- 3,
7470
- 7
7471
- ];
7472
- if (!!this.timing.ensureLoadedAdFitsBudget(preloadedController)) return [
7473
- 3,
7474
- 5
7475
- ];
7476
- this.timing.rejectLoadedAdForDuration(preloadedController);
7477
- this.startContinuousFetching(baseVastUrl);
7478
- return [
7479
- 4,
7480
- this.tryNextAvailableAdWithRateLimit()
7481
- ];
7482
- case 4:
7483
- _state.sent();
7484
- return [
7485
- 2
7486
- ];
7487
- case 5:
7488
- adPlayer = this.host.getAdPlayer();
7489
- preservedMuted = adPlayer.getOriginalMutedState();
7490
- preservedVolume = adPlayer.getOriginalVolume();
7491
- adPlayer.destroy();
7492
- this.host.video.muted = true;
7493
- this.host.setAdPlayer(preloadedController);
7494
- preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
7495
- this.attachImaEventListeners();
7496
- if (this.debug) {
7497
- console.log("[CONTINUOUS-FETCH] Using preloaded ad, resuming and starting playback immediately (no request delay!)");
7498
- }
7499
- preloadedController.resume();
7500
- this.timing.consecutiveFailures = 0;
7501
- this.startContinuousFetching(baseVastUrl);
7502
- if (!this.preloadPool.active) {
7503
- this.preloadPool.active = true;
7504
- }
7505
- if (!this.preloadPool.isLoopRunning) {
7506
- this.preloadPool.preloadPoolLoop(baseVastUrl);
7507
- }
7508
- return [
7509
- 4,
7510
- preloadedController.play()
7511
- ];
7512
- case 6:
7513
- _state.sent();
7514
- this.timing.markAdStarted();
7515
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7516
- this.timing.scheduleAdStopAtBreakBoundary();
7517
- }
7518
- adVolume = currentMuted ? 0 : currentVolume;
7519
- preloadedController.setAdVolume(adVolume);
7520
- return [
7521
- 3,
7522
- 13
7523
- ];
7524
- case 7:
7525
- adPlayer1 = this.host.getAdPlayer();
7526
- return [
7527
- 4,
7528
- this.timing.enforceGlobalRateLimit()
7529
- ];
7530
- case 8:
7531
- _state.sent();
7532
- this.timing.lastAdRequestTime = Date.now();
7533
- return [
7534
- 4,
7535
- adPlayer1.requestAds(firstAdUrl)
7536
- ];
7537
- case 9:
7538
- _state.sent();
7539
- sendAdLoadedTracking(this.host.config.licenseKey, {
7540
- source: "hls",
7541
- vastUrl: firstAdUrl,
7542
- timestamp: /* @__PURE__ */ new Date().toISOString()
7543
- }, this.analyticsContext).catch(function() {});
7544
- if (this.debug) {
7545
- console.log("[CONTINUOUS-FETCH] First ad request successful, starting playback");
7546
- }
7547
- if (!!this.timing.ensureLoadedAdFitsBudget(adPlayer1)) return [
7548
- 3,
7549
- 11
7550
- ];
7551
- this.timing.rejectLoadedAdForDuration(adPlayer1);
7552
- this.recreateAdController();
7553
- this.startContinuousFetching(baseVastUrl);
7554
- return [
7555
- 4,
7556
- this.tryNextAvailableAdWithRateLimit()
7557
- ];
7558
- case 10:
7559
- _state.sent();
7560
- return [
7561
- 2
7562
- ];
7563
- case 11:
7564
- this.timing.consecutiveFailures = 0;
7565
- this.startContinuousFetching(baseVastUrl);
7566
- if (!this.preloadPool.active) {
7567
- this.preloadPool.startPreloadPool(baseVastUrl, []);
7568
- }
7569
- return [
7570
- 4,
7571
- adPlayer1.play()
7572
- ];
7573
- case 12:
7574
- _state.sent();
7575
- this.timing.markAdStarted();
7576
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7577
- this.timing.scheduleAdStopAtBreakBoundary();
7578
- }
7579
- adVolume1 = currentMuted ? 0 : currentVolume;
7580
- adPlayer1.setAdVolume(adVolume1);
7581
- _state.label = 13;
7582
- case 13:
7583
- return [
7584
- 3,
7585
- 22
7586
- ];
7587
- case 14:
7588
- error = _state.sent();
7589
- if (this.debug) {
7590
- console.warn("[CONTINUOUS-FETCH] First ad request failed:", error);
7591
- }
7592
- if (!!usePreloadedAd) return [
7593
- 3,
7594
- 20
7595
- ];
7596
- fallbackPreloaded = this.preloadPool.getPreloadedAd();
7597
- if (!fallbackPreloaded) return [
7598
- 3,
7599
- 20
7600
- ];
7601
- if (this.debug) {
7602
- console.log("[CONTINUOUS-FETCH] First ad failed, using preloaded fallback");
7603
- }
7604
- _state.label = 15;
7605
- case 15:
7606
- _state.trys.push([
7607
- 15,
7608
- 19,
7609
- ,
7610
- 20
7611
- ]);
7612
- if (!!this.timing.ensureLoadedAdFitsBudget(fallbackPreloaded.adController)) return [
7613
- 3,
7614
- 17
7615
- ];
7616
- this.timing.rejectLoadedAdForDuration(fallbackPreloaded.adController);
7617
- this.startContinuousFetching(baseVastUrl);
7618
- return [
7619
- 4,
7620
- this.tryNextAvailableAdWithRateLimit()
7621
- ];
7622
- case 16:
7623
- _state.sent();
7624
- return [
7625
- 2
7626
- ];
7627
- case 17:
7628
- this.swapToPreloadedAdPlayer(fallbackPreloaded.adController);
7629
- this.timing.consecutiveFailures = 0;
7630
- this.startContinuousFetching(baseVastUrl);
7631
- if (!this.preloadPool.active) {
7632
- this.preloadPool.active = true;
7633
- this.preloadPool.preloadPoolLoop(baseVastUrl);
7634
- }
7635
- ap = this.host.getAdPlayer();
7636
- return [
7637
- 4,
7638
- ap.play()
7639
- ];
7640
- case 18:
7641
- _state.sent();
7642
- this.timing.markAdStarted();
7643
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7644
- this.timing.scheduleAdStopAtBreakBoundary();
7645
- }
7646
- adVolume2 = currentMuted ? 0 : currentVolume;
7647
- ap.setAdVolume(adVolume2);
7648
- return [
7649
- 2
7650
- ];
7651
- case 19:
7652
- fallbackError = _state.sent();
7653
- if (this.debug) {
7654
- console.warn("[CONTINUOUS-FETCH] Preloaded fallback also failed:", fallbackError);
7655
- }
7656
- return [
7657
- 3,
7658
- 20
7659
- ];
7660
- case 20:
7661
- if (this.timing.isTemporaryAdError(error)) {
7662
- this.timing.temporaryFailureUrls.set(firstAdUrl, Date.now());
7663
- if (this.debug) {
7664
- console.log("[CONTINUOUS-FETCH] First ad had temporary error (no-fill) - will try alternatives");
7665
- }
7666
- } else {
7667
- this.timing.failedVastUrls.add(firstAdUrl);
7668
- if (this.debug) {
7669
- console.log("[CONTINUOUS-FETCH] First ad had permanent error - URL blacklisted");
7670
- }
7671
- }
7672
- this.timing.consecutiveFailures++;
7673
- this.startContinuousFetching(baseVastUrl);
7674
- return [
7675
- 4,
7676
- this.tryNextAvailableAdWithRateLimit()
7677
- ];
7678
- case 21:
7679
- _state.sent();
7680
- return [
7681
- 3,
7682
- 22
7683
- ];
7684
- case 22:
7685
6930
  return [
7686
6931
  2
7687
6932
  ];
@@ -7755,7 +7000,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7755
7000
  ];
7756
7001
  }
7757
7002
  if (this.debug) {
7758
- 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"));
7003
+ 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"));
7759
7004
  }
7760
7005
  sendAdLoadedTracking(this.host.config.licenseKey, {
7761
7006
  source: "hls",
@@ -7775,13 +7020,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7775
7020
  }
7776
7021
  adPlayer.setAdVolume(currentMuted ? 0 : currentVolume);
7777
7022
  this.timing.consecutiveFailures = 0;
7778
- if (podCount === 1) {
7779
- this.continuousFetchingActive = true;
7780
- this.startContinuousFetching(baseVastUrl);
7781
- if (!this.preloadPool.active) {
7782
- this.preloadPool.startPreloadPool(baseVastUrl, []);
7783
- }
7784
- }
7023
+ this.continuousFetchingActive = true;
7024
+ this.startContinuousFetching(baseVastUrl);
7785
7025
  return [
7786
7026
  2,
7787
7027
  true
@@ -7814,20 +7054,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7814
7054
  }).call(this);
7815
7055
  }
7816
7056
  },
7817
- {
7818
- key: "swapToPreloadedAdPlayer",
7819
- value: function swapToPreloadedAdPlayer(preloadedController) {
7820
- var adPlayer = this.host.getAdPlayer();
7821
- var preservedMuted = adPlayer.getOriginalMutedState();
7822
- var preservedVolume = adPlayer.getOriginalVolume();
7823
- adPlayer.destroy();
7824
- this.host.video.muted = true;
7825
- this.host.setAdPlayer(preloadedController);
7826
- this.attachImaEventListeners();
7827
- preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
7828
- preloadedController.resume();
7829
- }
7830
- },
7831
7057
  {
7832
7058
  // ───────────────────────────────────────────────────────────────
7833
7059
  // Continuous fetching
@@ -7921,7 +7147,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7921
7147
  "continue"
7922
7148
  ];
7923
7149
  case 2:
7924
- newAdUrl = _this.host.generateVastUrls(baseVastUrl, 1)[0];
7150
+ newAdUrl = _this.nextAdRequestUrl(baseVastUrl);
7925
7151
  if (!(!newAdUrl || _this.timing.failedVastUrls.has(newAdUrl) || _this.timing.isUrlInCooldown(newAdUrl))) return [
7926
7152
  3,
7927
7153
  4
@@ -8078,7 +7304,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8078
7304
  value: function tryNextAvailableAd() {
8079
7305
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
8080
7306
  return _async_to_generator(function() {
8081
- var remaining, preloaded, ap, error, nextAdUrl, error1, errorMessage, maxRetries;
7307
+ var remaining, nextAdUrl, error, errorMessage, maxRetries;
8082
7308
  return _ts_generator(this, function(_state) {
8083
7309
  switch(_state.label){
8084
7310
  case 0:
@@ -8116,132 +7342,71 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8116
7342
  ];
8117
7343
  }
8118
7344
  this.timing.cleanupTemporaryFailures();
8119
- preloaded = this.preloadPool.getPreloadedAd();
8120
- if (!preloaded) return [
8121
- 3,
8122
- 6
8123
- ];
8124
- if (this.debug) {
8125
- console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool");
8126
- }
8127
- sendAdLoadedTracking(this.host.config.licenseKey, {
8128
- source: "hls",
8129
- vastUrl: preloaded.vastUrl,
8130
- timestamp: /* @__PURE__ */ new Date().toISOString()
8131
- }, this.analyticsContext).catch(function() {});
8132
7345
  _state.label = 1;
8133
7346
  case 1:
8134
- _state.trys.push([
8135
- 1,
8136
- 5,
8137
- ,
8138
- 6
8139
- ]);
8140
- if (!!this.timing.ensureLoadedAdFitsBudget(preloaded.adController)) return [
8141
- 3,
8142
- 3
8143
- ];
8144
- this.timing.rejectLoadedAdForDuration(preloaded.adController);
8145
- return [
8146
- 4,
8147
- this.tryNextAvailableAdWithRateLimit()
8148
- ];
8149
- case 2:
8150
- _state.sent();
8151
- return [
8152
- 2
8153
- ];
8154
- case 3:
8155
- this.swapToPreloadedAdPlayer(preloaded.adController);
8156
- ap = this.host.getAdPlayer();
8157
- return [
8158
- 4,
8159
- ap.play()
8160
- ];
8161
- case 4:
8162
- _state.sent();
8163
- this.timing.markAdStarted();
8164
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
8165
- this.timing.scheduleAdStopAtBreakBoundary();
8166
- }
8167
- ap.setAdVolume(getAdAudioVolume(ap));
8168
- this.timing.consecutiveFailures = 0;
8169
- return [
8170
- 2
8171
- ];
8172
- case 5:
8173
- error = _state.sent();
8174
- if (this.debug) {
8175
- console.warn("[CONTINUOUS-FETCH] Preloaded ad failed to play:", error);
8176
- }
8177
- return [
8178
- 3,
8179
- 6
8180
- ];
8181
- case 6:
8182
7347
  if (!(this.adRequestQueue.length > 0)) return [
8183
7348
  3,
8184
- 14
7349
+ 9
8185
7350
  ];
8186
7351
  nextAdUrl = this.adRequestQueue.shift();
8187
7352
  if (!nextAdUrl) return [
8188
7353
  3,
8189
- 6
7354
+ 1
8190
7355
  ];
8191
7356
  if (this.timing.failedVastUrls.has(nextAdUrl)) {
8192
7357
  if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping permanently-failed URL, trying next...");
8193
7358
  return [
8194
7359
  3,
8195
- 6
7360
+ 1
8196
7361
  ];
8197
7362
  }
8198
7363
  if (this.timing.isUrlInCooldown(nextAdUrl)) {
8199
7364
  if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping URL in cooldown (recent no-fill), trying next...");
8200
7365
  return [
8201
7366
  3,
8202
- 6
7367
+ 1
8203
7368
  ];
8204
7369
  }
8205
7370
  if (this.debug) {
8206
7371
  console.log("[CONTINUOUS-FETCH] Requesting next ad via HLS ad player (".concat(this.timing.currentAdIndex + 1, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
8207
7372
  }
8208
- _state.label = 7;
8209
- case 7:
7373
+ _state.label = 2;
7374
+ case 2:
8210
7375
  _state.trys.push([
8211
- 7,
8212
- 9,
7376
+ 2,
7377
+ 4,
8213
7378
  ,
8214
- 13
7379
+ 8
8215
7380
  ]);
8216
7381
  return [
8217
7382
  4,
8218
7383
  this.playSingleAd(nextAdUrl)
8219
7384
  ];
8220
- case 8:
7385
+ case 3:
8221
7386
  _state.sent();
8222
7387
  this.timing.consecutiveFailures = 0;
8223
7388
  return [
8224
7389
  3,
8225
- 13
7390
+ 8
8226
7391
  ];
8227
- case 9:
8228
- error1 = _state.sent();
8229
- errorMessage = error1.message;
7392
+ case 4:
7393
+ error = _state.sent();
7394
+ errorMessage = error.message;
8230
7395
  if (this.debug) console.log("[CONTINUOUS-FETCH] Ad request failed:", errorMessage);
8231
7396
  if (!errorMessage.includes("ad_duration_exceeds_budget")) return [
8232
7397
  3,
8233
- 11
7398
+ 6
8234
7399
  ];
8235
7400
  return [
8236
7401
  4,
8237
7402
  this.tryNextAvailableAdWithRateLimit()
8238
7403
  ];
8239
- case 10:
7404
+ case 5:
8240
7405
  _state.sent();
8241
7406
  return [
8242
7407
  2
8243
7408
  ];
8244
- case 11:
7409
+ case 6:
8245
7410
  if (!errorMessage.includes("permanently failed") && !errorMessage.includes("in cooldown")) {
8246
7411
  this.timing.consecutiveFailures++;
8247
7412
  }
@@ -8249,21 +7414,21 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8249
7414
  4,
8250
7415
  this.tryNextAvailableAdWithRateLimit()
8251
7416
  ];
8252
- case 12:
7417
+ case 7:
8253
7418
  _state.sent();
8254
7419
  return [
8255
7420
  3,
8256
- 13
7421
+ 8
8257
7422
  ];
8258
- case 13:
7423
+ case 8:
8259
7424
  return [
8260
7425
  2
8261
7426
  ];
8262
- case 14:
7427
+ case 9:
8263
7428
  maxRetries = 3;
8264
7429
  if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
8265
7430
  3,
8266
- 17
7431
+ 12
8267
7432
  ];
8268
7433
  if (this.debug) {
8269
7434
  console.log("[CONTINUOUS-FETCH] Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
@@ -8274,18 +7439,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8274
7439
  return setTimeout(resolve, 500);
8275
7440
  })
8276
7441
  ];
8277
- case 15:
7442
+ case 10:
8278
7443
  _state.sent();
8279
7444
  return [
8280
7445
  4,
8281
7446
  this.tryNextAvailableAd(retryCount + 1)
8282
7447
  ];
8283
- case 16:
7448
+ case 11:
8284
7449
  _state.sent();
8285
7450
  return [
8286
7451
  2
8287
7452
  ];
8288
- case 17:
7453
+ case 12:
8289
7454
  if (!this.isShowingPlaceholder && remaining > 1e3) {
8290
7455
  this.showPlaceholderAndWaitForAds();
8291
7456
  } else {
@@ -8307,7 +7472,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8307
7472
  // ───────────────────────────────────────────────────────────────
8308
7473
  function playSingleAd(vastTagUrl) {
8309
7474
  return _async_to_generator(function() {
8310
- var adPlayer, requestToken, ap, playError, preloadedFallback, fbAp, fallbackError, error, errorMessage, preloadedFallback1, fbAp1, fallbackError1;
7475
+ var adPlayer, requestToken, ap, playError, error, errorMessage;
8311
7476
  return _ts_generator(this, function(_state) {
8312
7477
  switch(_state.label){
8313
7478
  case 0:
@@ -8339,9 +7504,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8339
7504
  case 1:
8340
7505
  _state.trys.push([
8341
7506
  1,
8342
- 12,
7507
+ 8,
8343
7508
  ,
8344
- 17
7509
+ 9
8345
7510
  ]);
8346
7511
  return [
8347
7512
  4,
@@ -8377,7 +7542,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8377
7542
  4,
8378
7543
  6,
8379
7544
  ,
8380
- 11
7545
+ 7
8381
7546
  ]);
8382
7547
  this.timing.startAdFailsafeTimer(requestToken);
8383
7548
  return [
@@ -8395,55 +7560,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8395
7560
  this.timing.temporaryFailureUrls.delete(vastTagUrl);
8396
7561
  return [
8397
7562
  3,
8398
- 11
7563
+ 7
8399
7564
  ];
8400
7565
  case 6:
8401
7566
  playError = _state.sent();
8402
7567
  if (this.debug) console.error("[AD-ERROR] Failed to play ad:", playError);
8403
- preloadedFallback = this.preloadPool.getPreloadedAd();
8404
- if (!preloadedFallback) return [
8405
- 3,
8406
- 10
8407
- ];
8408
- if (this.debug) console.log("[AD-ERROR] Play failed, trying preloaded fallback ad");
8409
- _state.label = 7;
8410
- case 7:
8411
- _state.trys.push([
8412
- 7,
8413
- 9,
8414
- ,
8415
- 10
8416
- ]);
8417
- if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback.adController)) {
8418
- this.timing.rejectLoadedAdForDuration(preloadedFallback.adController);
8419
- throw playError;
8420
- }
8421
- this.timing.clearAdFailsafeTimer();
8422
- this.swapToPreloadedAdPlayer(preloadedFallback.adController);
8423
- this.timing.consecutiveFailures = 0;
8424
- fbAp = this.host.getAdPlayer();
8425
- return [
8426
- 4,
8427
- fbAp.play()
8428
- ];
8429
- case 8:
8430
- _state.sent();
8431
- this.timing.markAdStarted();
8432
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
8433
- this.timing.scheduleAdStopAtBreakBoundary();
8434
- }
8435
- fbAp.setAdVolume(getAdAudioVolume(fbAp));
8436
- return [
8437
- 2
8438
- ];
8439
- case 9:
8440
- fallbackError = _state.sent();
8441
- if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError);
8442
- return [
8443
- 3,
8444
- 10
8445
- ];
8446
- case 10:
8447
7568
  if (this.timing.isTemporaryAdError(playError)) {
8448
7569
  this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
8449
7570
  if (this.debug) console.log("[AD-ERROR] Temporary play error - URL can be retried after cooldown");
@@ -8456,57 +7577,15 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8456
7577
  this.timing.activeAdRequestToken = null;
8457
7578
  }
8458
7579
  throw playError;
8459
- case 11:
7580
+ case 7:
8460
7581
  return [
8461
7582
  3,
8462
- 17
7583
+ 9
8463
7584
  ];
8464
- case 12:
7585
+ case 8:
8465
7586
  error = _state.sent();
8466
7587
  errorMessage = (error === null || error === void 0 ? void 0 : error.message) || "";
8467
7588
  if (this.debug) console.error("[AD-ERROR] Ad request failed:", errorMessage);
8468
- preloadedFallback1 = this.preloadPool.getPreloadedAd();
8469
- if (!preloadedFallback1) return [
8470
- 3,
8471
- 16
8472
- ];
8473
- if (this.debug) console.log("[AD-ERROR] Request failed, trying preloaded fallback ad");
8474
- _state.label = 13;
8475
- case 13:
8476
- _state.trys.push([
8477
- 13,
8478
- 15,
8479
- ,
8480
- 16
8481
- ]);
8482
- if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback1.adController)) {
8483
- this.timing.rejectLoadedAdForDuration(preloadedFallback1.adController);
8484
- throw error;
8485
- }
8486
- this.timing.clearAdRequestWatchdog();
8487
- this.timing.clearAdFailsafeTimer();
8488
- this.swapToPreloadedAdPlayer(preloadedFallback1.adController);
8489
- this.timing.consecutiveFailures = 0;
8490
- fbAp1 = this.host.getAdPlayer();
8491
- return [
8492
- 4,
8493
- fbAp1.play()
8494
- ];
8495
- case 14:
8496
- _state.sent();
8497
- this.timing.markAdStarted();
8498
- fbAp1.setAdVolume(getAdAudioVolume(fbAp1));
8499
- return [
8500
- 2
8501
- ];
8502
- case 15:
8503
- fallbackError1 = _state.sent();
8504
- if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError1);
8505
- return [
8506
- 3,
8507
- 16
8508
- ];
8509
- case 16:
8510
7589
  if (this.timing.isTemporaryAdError(error)) {
8511
7590
  this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
8512
7591
  if (this.debug) console.log("[AD-ERROR] Temporary error (no-fill/timeout) - URL can be retried after cooldown");
@@ -8520,7 +7599,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8520
7599
  this.timing.activeAdRequestToken = null;
8521
7600
  }
8522
7601
  throw error;
8523
- case 17:
7602
+ case 9:
8524
7603
  return [
8525
7604
  2
8526
7605
  ];
@@ -8710,7 +7789,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8710
7789
  }
8711
7790
  this.timing.resetForBreakEnd();
8712
7791
  this.stopContinuousFetching();
8713
- this.preloadPool.stop();
8714
7792
  this.clearPendingAdBreak();
8715
7793
  if (this.isShowingPlaceholder) {
8716
7794
  this.host.getAdPlayer().hidePlaceholder();
@@ -8821,25 +7899,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8821
7899
  return _this.adBreak.handleAdFailure();
8822
7900
  }
8823
7901
  });
8824
- this.preloadPool = new AdPreloadPool({
8825
- debug: !!this.config.debugAdTiming,
8826
- createAdPlayer: function createAdPlayer(c) {
8827
- return _this.createAdPlayer(c);
8828
- },
8829
- shouldContinueLiveStreamDuringAds: function shouldContinueLiveStreamDuringAds() {
8830
- return _this.shouldContinueLiveStreamDuringAds();
8831
- },
8832
- timing: this.timing,
8833
- generateVastUrlsWithCorrelators: function generateVastUrlsWithCorrelators(base, count) {
8834
- return _this.generateVastUrls(base, count);
8835
- },
8836
- isInAdBreak: function isInAdBreak() {
8837
- return _this.adBreak.inAdBreak;
8838
- },
8839
- getPendingAdBreak: function getPendingAdBreak() {
8840
- return _this.adBreak.pendingAdBreak;
8841
- }
8842
- });
8843
7902
  this.placeholder = new PlaceholderLayer(this.video, !!this.config.debugAdTiming);
8844
7903
  this.hlsEngine = new HlsEngine(this.config, this.video, this.cueManager, this.timing, {
8845
7904
  onManifestParsed: function onManifestParsed(isLive) {
@@ -8886,13 +7945,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8886
7945
  getLiveSyncPosition: function getLiveSyncPosition() {
8887
7946
  return _this.hlsEngine.getLiveSyncPosition();
8888
7947
  },
8889
- generateVastUrls: function generateVastUrls(base, count) {
8890
- return _this.generateVastUrls(base, count);
8891
- },
8892
7948
  generatePodVastUrl: function generatePodVastUrl(base, breakDurationMs) {
8893
7949
  return _this.generatePodVastUrl(base, breakDurationMs);
8894
7950
  }
8895
- }, this.timing, this.preloadPool, this.adConfig, this.cueManager, this.placeholder);
7951
+ }, this.timing, this.adConfig, this.cueManager, this.placeholder);
8896
7952
  }
8897
7953
  _create_class(StormcloudVideoPlayer, [
8898
7954
  {
@@ -8917,12 +7973,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8917
7973
  } : {}));
8918
7974
  }
8919
7975
  },
8920
- {
8921
- key: "generateVastUrls",
8922
- value: function generateVastUrls(baseUrl, count) {
8923
- return this.adConfig.generateVastUrlsWithCorrelators(baseUrl, count, this.adPlayer, this.palNonce, this.adBreak.inAdBreak);
8924
- }
8925
- },
8926
7976
  {
8927
7977
  key: "generatePodVastUrl",
8928
7978
  value: function generatePodVastUrl(baseUrl, breakDurationMs) {
@@ -9318,11 +8368,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9318
8368
  }
9319
8369
  this.adConfig.beginNewAdPod();
9320
8370
  this.adConfig.podAssignedByPrefetch = true;
9321
- var optimizedPods = this.config.optimizedPods !== false;
9322
8371
  var breakDurationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : void 0;
9323
- var generatedUrls = optimizedPods ? [
8372
+ var generatedUrls = [
9324
8373
  this.generatePodVastUrl(baseVastUrl, breakDurationMs)
9325
- ] : this.generateVastUrls(baseVastUrl, 1);
8374
+ ];
9326
8375
  this.adBreak.pendingAdBreak = _object_spread_props(_object_spread({
9327
8376
  marker: marker
9328
8377
  }, fragmentSn !== void 0 ? {
@@ -9344,15 +8393,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9344
8393
  }, detectPayload), buildAnalyticsContext(this.config)).catch(function() {});
9345
8394
  if (this.debug) {
9346
8395
  console.log("[PREFETCH] Starting ad prefetch for upcoming ad break");
9347
- console.log("[PREFETCH] Pre-generated ".concat(generatedUrls.length, " ").concat(optimizedPods ? "pod" : "VAST", " URL(s)"));
9348
- }
9349
- if (optimizedPods) {
9350
- if (this.debug) {
9351
- console.log("[PREFETCH] Optimized pods enabled - skipping single-ad preload pool");
9352
- }
9353
- return;
8396
+ console.log("[PREFETCH] Pre-generated pod request URL");
9354
8397
  }
9355
- this.preloadPool.startPreloadPool(baseVastUrl, generatedUrls.slice(0, 1), false);
9356
8398
  }
9357
8399
  },
9358
8400
  {
@@ -9591,7 +8633,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9591
8633
  value: function destroy() {
9592
8634
  var _this_adPlayer;
9593
8635
  this.adBreak.stopContinuousFetching();
9594
- this.preloadPool.stop();
9595
8636
  this.timing.destroy();
9596
8637
  this.adBreak.clearPendingAdBreak();
9597
8638
  this.placeholder.destroy();