stormcloud-video-player 0.8.29 → 0.8.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/stormcloud-vp.min.js +2 -2
  2. package/lib/index.cjs +78 -1045
  3. package/lib/index.cjs.map +1 -1
  4. package/lib/index.d.cts +0 -3
  5. package/lib/index.d.ts +0 -3
  6. package/lib/index.js +78 -1046
  7. package/lib/index.js.map +1 -1
  8. package/lib/player/AdBreakOrchestrator.cjs +57 -490
  9. package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
  10. package/lib/player/AdBreakOrchestrator.d.cts +8 -7
  11. package/lib/player/AdConfigManager.cjs +12 -53
  12. package/lib/player/AdConfigManager.cjs.map +1 -1
  13. package/lib/player/AdConfigManager.d.cts +4 -5
  14. package/lib/player/AdTimingService.d.cts +1 -1
  15. package/lib/player/HlsEngine.d.cts +1 -1
  16. package/lib/player/PlayerControls.d.cts +1 -1
  17. package/lib/player/Scte35CueManager.d.cts +1 -1
  18. package/lib/player/Scte35Parser.d.cts +1 -1
  19. package/lib/player/StormcloudVideoPlayer.cjs +78 -1045
  20. package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
  21. package/lib/player/StormcloudVideoPlayer.d.cts +1 -3
  22. package/lib/player/playerTypes.d.cts +1 -1
  23. package/lib/players/HlsPlayer.cjs +78 -1045
  24. package/lib/players/HlsPlayer.cjs.map +1 -1
  25. package/lib/players/HlsPlayer.d.cts +1 -1
  26. package/lib/players/index.cjs +78 -1045
  27. package/lib/players/index.cjs.map +1 -1
  28. package/lib/sdk/hlsAdPlayer.d.cts +1 -1
  29. package/lib/{types-Xgz2_W1C.d.cts → types-CSHvCbhZ.d.cts} +0 -1
  30. package/lib/ui/StormcloudVideoPlayer.cjs +78 -1045
  31. package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
  32. package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
  33. package/lib/utils/tracking.d.cts +1 -1
  34. package/lib/utils/vastMacros.cjs +10 -15
  35. package/lib/utils/vastMacros.cjs.map +1 -1
  36. package/lib/utils/vastMacros.d.cts +0 -1
  37. package/package.json +1 -1
  38. package/lib/player/AdPreloadPool.cjs +0 -673
  39. package/lib/player/AdPreloadPool.cjs.map +0 -1
  40. package/lib/player/AdPreloadPool.d.cts +0 -37
package/lib/index.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,23 +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;
7181
- }
7182
- },
7183
- {
7184
- key: "nextAdRequestUrl",
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",
7185
6685
  value: function nextAdRequestUrl(baseVastUrl) {
7186
- if (this.optimizedPodsEnabled) {
7187
- var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
7188
- var breakDurationMs = remaining > 0 ? remaining : void 0;
7189
- return this.host.generatePodVastUrl(baseVastUrl, breakDurationMs);
7190
- }
7191
- return this.host.generateVastUrls(baseVastUrl, 1)[0];
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);
7192
6689
  }
7193
6690
  },
7194
6691
  {
@@ -7360,7 +6857,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7360
6857
  // ───────────────────────────────────────────────────────────────
7361
6858
  function handleAdStart(_marker) {
7362
6859
  return _async_to_generator(function() {
7363
- var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, podPlayed, firstAdUrl, usePreloadedAd, preloadedController, preloaded, adPlayer, preservedMuted, preservedVolume, adVolume, adPlayer1, adVolume1, error, fallbackPreloaded, ap, adVolume2, fallbackError;
6860
+ var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, podPlayed;
7364
6861
  return _ts_generator(this, function(_state) {
7365
6862
  switch(_state.label){
7366
6863
  case 0:
@@ -7407,293 +6904,29 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7407
6904
  if (this.timing.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
7408
6905
  this.timing.expectedAdBreakDurationMs = adBreakDurationMs;
7409
6906
  }
7410
- if (!this.optimizedPodsEnabled) return [
7411
- 3,
7412
- 2
7413
- ];
7414
6907
  return [
7415
6908
  4,
7416
6909
  this.startOptimizedPod(baseVastUrl, adBreakDurationMs, currentMuted, currentVolume)
7417
6910
  ];
7418
6911
  case 1:
7419
6912
  podPlayed = _state.sent();
7420
- if (podPlayed) {
7421
- return [
7422
- 2
7423
- ];
7424
- }
6913
+ if (!!podPlayed) return [
6914
+ 3,
6915
+ 3
6916
+ ];
7425
6917
  if (this.debug) {
7426
- 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");
7427
6919
  }
7428
- _state.label = 2;
6920
+ this.continuousFetchingActive = true;
6921
+ this.startContinuousFetching(baseVastUrl);
6922
+ return [
6923
+ 4,
6924
+ this.tryNextAvailableAdWithRateLimit()
6925
+ ];
7429
6926
  case 2:
7430
- usePreloadedAd = false;
7431
- preloaded = this.preloadPool.getPreloadedAd();
7432
- if (preloaded) {
7433
- firstAdUrl = preloaded.vastUrl;
7434
- preloadedController = preloaded.adController;
7435
- usePreloadedAd = true;
7436
- sendAdLoadedTracking(this.host.config.licenseKey, {
7437
- source: "hls",
7438
- vastUrl: firstAdUrl,
7439
- timestamp: /* @__PURE__ */ new Date().toISOString()
7440
- }, this.analyticsContext).catch(function() {});
7441
- if (this.debug) {
7442
- console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool (preloaded in advance, ready immediately!)");
7443
- }
7444
- } else if (this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0) {
7445
- this.adRequestQueue = _to_consumable_array(this.pendingAdBreak.vastUrls);
7446
- firstAdUrl = this.adRequestQueue.shift();
7447
- if (this.debug) {
7448
- console.log("[CONTINUOUS-FETCH] Pool empty, using prefetched URLs (".concat(this.adRequestQueue.length + 1, " available)"));
7449
- }
7450
- this.clearPendingAdBreak();
7451
- } else {
7452
- if (this.debug) {
7453
- console.log("[CONTINUOUS-FETCH] Generating new ad URLs...");
7454
- }
7455
- firstAdUrl = this.nextAdRequestUrl(baseVastUrl);
7456
- this.adRequestQueue = [];
7457
- }
7458
- if (!firstAdUrl) {
7459
- if (this.debug) {
7460
- console.warn("[CONTINUOUS-FETCH] Failed to get first ad URL");
7461
- }
7462
- this.handleAdPodComplete();
7463
- return [
7464
- 2
7465
- ];
7466
- }
7467
- if (this.debug) {
7468
- console.log("[CONTINUOUS-FETCH] First VAST URL:", firstAdUrl);
7469
- }
6927
+ _state.sent();
7470
6928
  _state.label = 3;
7471
6929
  case 3:
7472
- _state.trys.push([
7473
- 3,
7474
- 14,
7475
- ,
7476
- 22
7477
- ]);
7478
- if (!(usePreloadedAd && preloadedController)) return [
7479
- 3,
7480
- 7
7481
- ];
7482
- if (!!this.timing.ensureLoadedAdFitsBudget(preloadedController)) return [
7483
- 3,
7484
- 5
7485
- ];
7486
- this.timing.rejectLoadedAdForDuration(preloadedController);
7487
- this.startContinuousFetching(baseVastUrl);
7488
- return [
7489
- 4,
7490
- this.tryNextAvailableAdWithRateLimit()
7491
- ];
7492
- case 4:
7493
- _state.sent();
7494
- return [
7495
- 2
7496
- ];
7497
- case 5:
7498
- adPlayer = this.host.getAdPlayer();
7499
- preservedMuted = adPlayer.getOriginalMutedState();
7500
- preservedVolume = adPlayer.getOriginalVolume();
7501
- adPlayer.destroy();
7502
- this.host.video.muted = true;
7503
- this.host.setAdPlayer(preloadedController);
7504
- preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
7505
- this.attachImaEventListeners();
7506
- if (this.debug) {
7507
- console.log("[CONTINUOUS-FETCH] Using preloaded ad, resuming and starting playback immediately (no request delay!)");
7508
- }
7509
- preloadedController.resume();
7510
- this.timing.consecutiveFailures = 0;
7511
- this.startContinuousFetching(baseVastUrl);
7512
- if (!this.optimizedPodsEnabled) {
7513
- if (!this.preloadPool.active) {
7514
- this.preloadPool.active = true;
7515
- }
7516
- if (!this.preloadPool.isLoopRunning) {
7517
- this.preloadPool.preloadPoolLoop(baseVastUrl);
7518
- }
7519
- }
7520
- return [
7521
- 4,
7522
- preloadedController.play()
7523
- ];
7524
- case 6:
7525
- _state.sent();
7526
- this.timing.markAdStarted();
7527
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7528
- this.timing.scheduleAdStopAtBreakBoundary();
7529
- }
7530
- adVolume = currentMuted ? 0 : currentVolume;
7531
- preloadedController.setAdVolume(adVolume);
7532
- return [
7533
- 3,
7534
- 13
7535
- ];
7536
- case 7:
7537
- adPlayer1 = this.host.getAdPlayer();
7538
- return [
7539
- 4,
7540
- this.timing.enforceGlobalRateLimit()
7541
- ];
7542
- case 8:
7543
- _state.sent();
7544
- this.timing.lastAdRequestTime = Date.now();
7545
- return [
7546
- 4,
7547
- adPlayer1.requestAds(firstAdUrl)
7548
- ];
7549
- case 9:
7550
- _state.sent();
7551
- sendAdLoadedTracking(this.host.config.licenseKey, {
7552
- source: "hls",
7553
- vastUrl: firstAdUrl,
7554
- timestamp: /* @__PURE__ */ new Date().toISOString()
7555
- }, this.analyticsContext).catch(function() {});
7556
- if (this.debug) {
7557
- console.log("[CONTINUOUS-FETCH] First ad request successful, starting playback");
7558
- }
7559
- if (!!this.timing.ensureLoadedAdFitsBudget(adPlayer1)) return [
7560
- 3,
7561
- 11
7562
- ];
7563
- this.timing.rejectLoadedAdForDuration(adPlayer1);
7564
- this.recreateAdController();
7565
- this.startContinuousFetching(baseVastUrl);
7566
- return [
7567
- 4,
7568
- this.tryNextAvailableAdWithRateLimit()
7569
- ];
7570
- case 10:
7571
- _state.sent();
7572
- return [
7573
- 2
7574
- ];
7575
- case 11:
7576
- this.timing.consecutiveFailures = 0;
7577
- this.startContinuousFetching(baseVastUrl);
7578
- if (!this.optimizedPodsEnabled && !this.preloadPool.active) {
7579
- this.preloadPool.startPreloadPool(baseVastUrl, []);
7580
- }
7581
- return [
7582
- 4,
7583
- adPlayer1.play()
7584
- ];
7585
- case 12:
7586
- _state.sent();
7587
- this.timing.markAdStarted();
7588
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7589
- this.timing.scheduleAdStopAtBreakBoundary();
7590
- }
7591
- adVolume1 = currentMuted ? 0 : currentVolume;
7592
- adPlayer1.setAdVolume(adVolume1);
7593
- _state.label = 13;
7594
- case 13:
7595
- return [
7596
- 3,
7597
- 22
7598
- ];
7599
- case 14:
7600
- error = _state.sent();
7601
- if (this.debug) {
7602
- console.warn("[CONTINUOUS-FETCH] First ad request failed:", error);
7603
- }
7604
- if (!!usePreloadedAd) return [
7605
- 3,
7606
- 20
7607
- ];
7608
- fallbackPreloaded = this.preloadPool.getPreloadedAd();
7609
- if (!fallbackPreloaded) return [
7610
- 3,
7611
- 20
7612
- ];
7613
- if (this.debug) {
7614
- console.log("[CONTINUOUS-FETCH] First ad failed, using preloaded fallback");
7615
- }
7616
- _state.label = 15;
7617
- case 15:
7618
- _state.trys.push([
7619
- 15,
7620
- 19,
7621
- ,
7622
- 20
7623
- ]);
7624
- if (!!this.timing.ensureLoadedAdFitsBudget(fallbackPreloaded.adController)) return [
7625
- 3,
7626
- 17
7627
- ];
7628
- this.timing.rejectLoadedAdForDuration(fallbackPreloaded.adController);
7629
- this.startContinuousFetching(baseVastUrl);
7630
- return [
7631
- 4,
7632
- this.tryNextAvailableAdWithRateLimit()
7633
- ];
7634
- case 16:
7635
- _state.sent();
7636
- return [
7637
- 2
7638
- ];
7639
- case 17:
7640
- this.swapToPreloadedAdPlayer(fallbackPreloaded.adController);
7641
- this.timing.consecutiveFailures = 0;
7642
- this.startContinuousFetching(baseVastUrl);
7643
- if (!this.optimizedPodsEnabled && !this.preloadPool.active) {
7644
- this.preloadPool.active = true;
7645
- this.preloadPool.preloadPoolLoop(baseVastUrl);
7646
- }
7647
- ap = this.host.getAdPlayer();
7648
- return [
7649
- 4,
7650
- ap.play()
7651
- ];
7652
- case 18:
7653
- _state.sent();
7654
- this.timing.markAdStarted();
7655
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7656
- this.timing.scheduleAdStopAtBreakBoundary();
7657
- }
7658
- adVolume2 = currentMuted ? 0 : currentVolume;
7659
- ap.setAdVolume(adVolume2);
7660
- return [
7661
- 2
7662
- ];
7663
- case 19:
7664
- fallbackError = _state.sent();
7665
- if (this.debug) {
7666
- console.warn("[CONTINUOUS-FETCH] Preloaded fallback also failed:", fallbackError);
7667
- }
7668
- return [
7669
- 3,
7670
- 20
7671
- ];
7672
- case 20:
7673
- if (this.timing.isTemporaryAdError(error)) {
7674
- this.timing.temporaryFailureUrls.set(firstAdUrl, Date.now());
7675
- if (this.debug) {
7676
- console.log("[CONTINUOUS-FETCH] First ad had temporary error (no-fill) - will try alternatives");
7677
- }
7678
- } else {
7679
- this.timing.failedVastUrls.add(firstAdUrl);
7680
- if (this.debug) {
7681
- console.log("[CONTINUOUS-FETCH] First ad had permanent error - URL blacklisted");
7682
- }
7683
- }
7684
- this.timing.consecutiveFailures++;
7685
- this.startContinuousFetching(baseVastUrl);
7686
- return [
7687
- 4,
7688
- this.tryNextAvailableAdWithRateLimit()
7689
- ];
7690
- case 21:
7691
- _state.sent();
7692
- return [
7693
- 3,
7694
- 22
7695
- ];
7696
- case 22:
7697
6930
  return [
7698
6931
  2
7699
6932
  ];
@@ -7767,7 +7000,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7767
7000
  ];
7768
7001
  }
7769
7002
  if (this.debug) {
7770
- 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"));
7771
7004
  }
7772
7005
  sendAdLoadedTracking(this.host.config.licenseKey, {
7773
7006
  source: "hls",
@@ -7787,10 +7020,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7787
7020
  }
7788
7021
  adPlayer.setAdVolume(currentMuted ? 0 : currentVolume);
7789
7022
  this.timing.consecutiveFailures = 0;
7790
- if (podCount === 1) {
7791
- this.continuousFetchingActive = true;
7792
- this.startContinuousFetching(baseVastUrl);
7793
- }
7023
+ this.continuousFetchingActive = true;
7024
+ this.startContinuousFetching(baseVastUrl);
7794
7025
  return [
7795
7026
  2,
7796
7027
  true
@@ -7823,20 +7054,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7823
7054
  }).call(this);
7824
7055
  }
7825
7056
  },
7826
- {
7827
- key: "swapToPreloadedAdPlayer",
7828
- value: function swapToPreloadedAdPlayer(preloadedController) {
7829
- var adPlayer = this.host.getAdPlayer();
7830
- var preservedMuted = adPlayer.getOriginalMutedState();
7831
- var preservedVolume = adPlayer.getOriginalVolume();
7832
- adPlayer.destroy();
7833
- this.host.video.muted = true;
7834
- this.host.setAdPlayer(preloadedController);
7835
- this.attachImaEventListeners();
7836
- preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
7837
- preloadedController.resume();
7838
- }
7839
- },
7840
7057
  {
7841
7058
  // ───────────────────────────────────────────────────────────────
7842
7059
  // Continuous fetching
@@ -8087,7 +7304,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8087
7304
  value: function tryNextAvailableAd() {
8088
7305
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
8089
7306
  return _async_to_generator(function() {
8090
- var remaining, preloaded, ap, error, nextAdUrl, error1, errorMessage, maxRetries;
7307
+ var remaining, nextAdUrl, error, errorMessage, maxRetries;
8091
7308
  return _ts_generator(this, function(_state) {
8092
7309
  switch(_state.label){
8093
7310
  case 0:
@@ -8125,132 +7342,71 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8125
7342
  ];
8126
7343
  }
8127
7344
  this.timing.cleanupTemporaryFailures();
8128
- preloaded = this.preloadPool.getPreloadedAd();
8129
- if (!preloaded) return [
8130
- 3,
8131
- 6
8132
- ];
8133
- if (this.debug) {
8134
- console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool");
8135
- }
8136
- sendAdLoadedTracking(this.host.config.licenseKey, {
8137
- source: "hls",
8138
- vastUrl: preloaded.vastUrl,
8139
- timestamp: /* @__PURE__ */ new Date().toISOString()
8140
- }, this.analyticsContext).catch(function() {});
8141
7345
  _state.label = 1;
8142
7346
  case 1:
8143
- _state.trys.push([
8144
- 1,
8145
- 5,
8146
- ,
8147
- 6
8148
- ]);
8149
- if (!!this.timing.ensureLoadedAdFitsBudget(preloaded.adController)) return [
8150
- 3,
8151
- 3
8152
- ];
8153
- this.timing.rejectLoadedAdForDuration(preloaded.adController);
8154
- return [
8155
- 4,
8156
- this.tryNextAvailableAdWithRateLimit()
8157
- ];
8158
- case 2:
8159
- _state.sent();
8160
- return [
8161
- 2
8162
- ];
8163
- case 3:
8164
- this.swapToPreloadedAdPlayer(preloaded.adController);
8165
- ap = this.host.getAdPlayer();
8166
- return [
8167
- 4,
8168
- ap.play()
8169
- ];
8170
- case 4:
8171
- _state.sent();
8172
- this.timing.markAdStarted();
8173
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
8174
- this.timing.scheduleAdStopAtBreakBoundary();
8175
- }
8176
- ap.setAdVolume(getAdAudioVolume(ap));
8177
- this.timing.consecutiveFailures = 0;
8178
- return [
8179
- 2
8180
- ];
8181
- case 5:
8182
- error = _state.sent();
8183
- if (this.debug) {
8184
- console.warn("[CONTINUOUS-FETCH] Preloaded ad failed to play:", error);
8185
- }
8186
- return [
8187
- 3,
8188
- 6
8189
- ];
8190
- case 6:
8191
7347
  if (!(this.adRequestQueue.length > 0)) return [
8192
7348
  3,
8193
- 14
7349
+ 9
8194
7350
  ];
8195
7351
  nextAdUrl = this.adRequestQueue.shift();
8196
7352
  if (!nextAdUrl) return [
8197
7353
  3,
8198
- 6
7354
+ 1
8199
7355
  ];
8200
7356
  if (this.timing.failedVastUrls.has(nextAdUrl)) {
8201
7357
  if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping permanently-failed URL, trying next...");
8202
7358
  return [
8203
7359
  3,
8204
- 6
7360
+ 1
8205
7361
  ];
8206
7362
  }
8207
7363
  if (this.timing.isUrlInCooldown(nextAdUrl)) {
8208
7364
  if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping URL in cooldown (recent no-fill), trying next...");
8209
7365
  return [
8210
7366
  3,
8211
- 6
7367
+ 1
8212
7368
  ];
8213
7369
  }
8214
7370
  if (this.debug) {
8215
7371
  console.log("[CONTINUOUS-FETCH] Requesting next ad via HLS ad player (".concat(this.timing.currentAdIndex + 1, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
8216
7372
  }
8217
- _state.label = 7;
8218
- case 7:
7373
+ _state.label = 2;
7374
+ case 2:
8219
7375
  _state.trys.push([
8220
- 7,
8221
- 9,
7376
+ 2,
7377
+ 4,
8222
7378
  ,
8223
- 13
7379
+ 8
8224
7380
  ]);
8225
7381
  return [
8226
7382
  4,
8227
7383
  this.playSingleAd(nextAdUrl)
8228
7384
  ];
8229
- case 8:
7385
+ case 3:
8230
7386
  _state.sent();
8231
7387
  this.timing.consecutiveFailures = 0;
8232
7388
  return [
8233
7389
  3,
8234
- 13
7390
+ 8
8235
7391
  ];
8236
- case 9:
8237
- error1 = _state.sent();
8238
- errorMessage = error1.message;
7392
+ case 4:
7393
+ error = _state.sent();
7394
+ errorMessage = error.message;
8239
7395
  if (this.debug) console.log("[CONTINUOUS-FETCH] Ad request failed:", errorMessage);
8240
7396
  if (!errorMessage.includes("ad_duration_exceeds_budget")) return [
8241
7397
  3,
8242
- 11
7398
+ 6
8243
7399
  ];
8244
7400
  return [
8245
7401
  4,
8246
7402
  this.tryNextAvailableAdWithRateLimit()
8247
7403
  ];
8248
- case 10:
7404
+ case 5:
8249
7405
  _state.sent();
8250
7406
  return [
8251
7407
  2
8252
7408
  ];
8253
- case 11:
7409
+ case 6:
8254
7410
  if (!errorMessage.includes("permanently failed") && !errorMessage.includes("in cooldown")) {
8255
7411
  this.timing.consecutiveFailures++;
8256
7412
  }
@@ -8258,21 +7414,21 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8258
7414
  4,
8259
7415
  this.tryNextAvailableAdWithRateLimit()
8260
7416
  ];
8261
- case 12:
7417
+ case 7:
8262
7418
  _state.sent();
8263
7419
  return [
8264
7420
  3,
8265
- 13
7421
+ 8
8266
7422
  ];
8267
- case 13:
7423
+ case 8:
8268
7424
  return [
8269
7425
  2
8270
7426
  ];
8271
- case 14:
7427
+ case 9:
8272
7428
  maxRetries = 3;
8273
7429
  if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
8274
7430
  3,
8275
- 17
7431
+ 12
8276
7432
  ];
8277
7433
  if (this.debug) {
8278
7434
  console.log("[CONTINUOUS-FETCH] Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
@@ -8283,18 +7439,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8283
7439
  return setTimeout(resolve, 500);
8284
7440
  })
8285
7441
  ];
8286
- case 15:
7442
+ case 10:
8287
7443
  _state.sent();
8288
7444
  return [
8289
7445
  4,
8290
7446
  this.tryNextAvailableAd(retryCount + 1)
8291
7447
  ];
8292
- case 16:
7448
+ case 11:
8293
7449
  _state.sent();
8294
7450
  return [
8295
7451
  2
8296
7452
  ];
8297
- case 17:
7453
+ case 12:
8298
7454
  if (!this.isShowingPlaceholder && remaining > 1e3) {
8299
7455
  this.showPlaceholderAndWaitForAds();
8300
7456
  } else {
@@ -8316,7 +7472,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8316
7472
  // ───────────────────────────────────────────────────────────────
8317
7473
  function playSingleAd(vastTagUrl) {
8318
7474
  return _async_to_generator(function() {
8319
- var adPlayer, requestToken, ap, playError, preloadedFallback, fbAp, fallbackError, error, errorMessage, preloadedFallback1, fbAp1, fallbackError1;
7475
+ var adPlayer, requestToken, ap, playError, error, errorMessage;
8320
7476
  return _ts_generator(this, function(_state) {
8321
7477
  switch(_state.label){
8322
7478
  case 0:
@@ -8348,9 +7504,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8348
7504
  case 1:
8349
7505
  _state.trys.push([
8350
7506
  1,
8351
- 12,
7507
+ 8,
8352
7508
  ,
8353
- 17
7509
+ 9
8354
7510
  ]);
8355
7511
  return [
8356
7512
  4,
@@ -8386,7 +7542,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8386
7542
  4,
8387
7543
  6,
8388
7544
  ,
8389
- 11
7545
+ 7
8390
7546
  ]);
8391
7547
  this.timing.startAdFailsafeTimer(requestToken);
8392
7548
  return [
@@ -8404,55 +7560,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8404
7560
  this.timing.temporaryFailureUrls.delete(vastTagUrl);
8405
7561
  return [
8406
7562
  3,
8407
- 11
7563
+ 7
8408
7564
  ];
8409
7565
  case 6:
8410
7566
  playError = _state.sent();
8411
7567
  if (this.debug) console.error("[AD-ERROR] Failed to play ad:", playError);
8412
- preloadedFallback = this.preloadPool.getPreloadedAd();
8413
- if (!preloadedFallback) return [
8414
- 3,
8415
- 10
8416
- ];
8417
- if (this.debug) console.log("[AD-ERROR] Play failed, trying preloaded fallback ad");
8418
- _state.label = 7;
8419
- case 7:
8420
- _state.trys.push([
8421
- 7,
8422
- 9,
8423
- ,
8424
- 10
8425
- ]);
8426
- if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback.adController)) {
8427
- this.timing.rejectLoadedAdForDuration(preloadedFallback.adController);
8428
- throw playError;
8429
- }
8430
- this.timing.clearAdFailsafeTimer();
8431
- this.swapToPreloadedAdPlayer(preloadedFallback.adController);
8432
- this.timing.consecutiveFailures = 0;
8433
- fbAp = this.host.getAdPlayer();
8434
- return [
8435
- 4,
8436
- fbAp.play()
8437
- ];
8438
- case 8:
8439
- _state.sent();
8440
- this.timing.markAdStarted();
8441
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
8442
- this.timing.scheduleAdStopAtBreakBoundary();
8443
- }
8444
- fbAp.setAdVolume(getAdAudioVolume(fbAp));
8445
- return [
8446
- 2
8447
- ];
8448
- case 9:
8449
- fallbackError = _state.sent();
8450
- if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError);
8451
- return [
8452
- 3,
8453
- 10
8454
- ];
8455
- case 10:
8456
7568
  if (this.timing.isTemporaryAdError(playError)) {
8457
7569
  this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
8458
7570
  if (this.debug) console.log("[AD-ERROR] Temporary play error - URL can be retried after cooldown");
@@ -8465,57 +7577,15 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8465
7577
  this.timing.activeAdRequestToken = null;
8466
7578
  }
8467
7579
  throw playError;
8468
- case 11:
7580
+ case 7:
8469
7581
  return [
8470
7582
  3,
8471
- 17
7583
+ 9
8472
7584
  ];
8473
- case 12:
7585
+ case 8:
8474
7586
  error = _state.sent();
8475
7587
  errorMessage = (error === null || error === void 0 ? void 0 : error.message) || "";
8476
7588
  if (this.debug) console.error("[AD-ERROR] Ad request failed:", errorMessage);
8477
- preloadedFallback1 = this.preloadPool.getPreloadedAd();
8478
- if (!preloadedFallback1) return [
8479
- 3,
8480
- 16
8481
- ];
8482
- if (this.debug) console.log("[AD-ERROR] Request failed, trying preloaded fallback ad");
8483
- _state.label = 13;
8484
- case 13:
8485
- _state.trys.push([
8486
- 13,
8487
- 15,
8488
- ,
8489
- 16
8490
- ]);
8491
- if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback1.adController)) {
8492
- this.timing.rejectLoadedAdForDuration(preloadedFallback1.adController);
8493
- throw error;
8494
- }
8495
- this.timing.clearAdRequestWatchdog();
8496
- this.timing.clearAdFailsafeTimer();
8497
- this.swapToPreloadedAdPlayer(preloadedFallback1.adController);
8498
- this.timing.consecutiveFailures = 0;
8499
- fbAp1 = this.host.getAdPlayer();
8500
- return [
8501
- 4,
8502
- fbAp1.play()
8503
- ];
8504
- case 14:
8505
- _state.sent();
8506
- this.timing.markAdStarted();
8507
- fbAp1.setAdVolume(getAdAudioVolume(fbAp1));
8508
- return [
8509
- 2
8510
- ];
8511
- case 15:
8512
- fallbackError1 = _state.sent();
8513
- if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError1);
8514
- return [
8515
- 3,
8516
- 16
8517
- ];
8518
- case 16:
8519
7589
  if (this.timing.isTemporaryAdError(error)) {
8520
7590
  this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
8521
7591
  if (this.debug) console.log("[AD-ERROR] Temporary error (no-fill/timeout) - URL can be retried after cooldown");
@@ -8529,7 +7599,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8529
7599
  this.timing.activeAdRequestToken = null;
8530
7600
  }
8531
7601
  throw error;
8532
- case 17:
7602
+ case 9:
8533
7603
  return [
8534
7604
  2
8535
7605
  ];
@@ -8719,7 +7789,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8719
7789
  }
8720
7790
  this.timing.resetForBreakEnd();
8721
7791
  this.stopContinuousFetching();
8722
- this.preloadPool.stop();
8723
7792
  this.clearPendingAdBreak();
8724
7793
  if (this.isShowingPlaceholder) {
8725
7794
  this.host.getAdPlayer().hidePlaceholder();
@@ -8830,25 +7899,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8830
7899
  return _this.adBreak.handleAdFailure();
8831
7900
  }
8832
7901
  });
8833
- this.preloadPool = new AdPreloadPool({
8834
- debug: !!this.config.debugAdTiming,
8835
- createAdPlayer: function createAdPlayer(c) {
8836
- return _this.createAdPlayer(c);
8837
- },
8838
- shouldContinueLiveStreamDuringAds: function shouldContinueLiveStreamDuringAds() {
8839
- return _this.shouldContinueLiveStreamDuringAds();
8840
- },
8841
- timing: this.timing,
8842
- generateVastUrlsWithCorrelators: function generateVastUrlsWithCorrelators(base, count) {
8843
- return _this.generateVastUrls(base, count);
8844
- },
8845
- isInAdBreak: function isInAdBreak() {
8846
- return _this.adBreak.inAdBreak;
8847
- },
8848
- getPendingAdBreak: function getPendingAdBreak() {
8849
- return _this.adBreak.pendingAdBreak;
8850
- }
8851
- });
8852
7902
  this.placeholder = new PlaceholderLayer(this.video, !!this.config.debugAdTiming);
8853
7903
  this.hlsEngine = new HlsEngine(this.config, this.video, this.cueManager, this.timing, {
8854
7904
  onManifestParsed: function onManifestParsed(isLive) {
@@ -8895,13 +7945,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8895
7945
  getLiveSyncPosition: function getLiveSyncPosition() {
8896
7946
  return _this.hlsEngine.getLiveSyncPosition();
8897
7947
  },
8898
- generateVastUrls: function generateVastUrls(base, count) {
8899
- return _this.generateVastUrls(base, count);
8900
- },
8901
7948
  generatePodVastUrl: function generatePodVastUrl(base, breakDurationMs) {
8902
7949
  return _this.generatePodVastUrl(base, breakDurationMs);
8903
7950
  }
8904
- }, this.timing, this.preloadPool, this.adConfig, this.cueManager, this.placeholder);
7951
+ }, this.timing, this.adConfig, this.cueManager, this.placeholder);
8905
7952
  }
8906
7953
  _create_class(StormcloudVideoPlayer, [
8907
7954
  {
@@ -8926,12 +7973,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8926
7973
  } : {}));
8927
7974
  }
8928
7975
  },
8929
- {
8930
- key: "generateVastUrls",
8931
- value: function generateVastUrls(baseUrl, count) {
8932
- return this.adConfig.generateVastUrlsWithCorrelators(baseUrl, count, this.adPlayer, this.palNonce, this.adBreak.inAdBreak);
8933
- }
8934
- },
8935
7976
  {
8936
7977
  key: "generatePodVastUrl",
8937
7978
  value: function generatePodVastUrl(baseUrl, breakDurationMs) {
@@ -9327,11 +8368,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9327
8368
  }
9328
8369
  this.adConfig.beginNewAdPod();
9329
8370
  this.adConfig.podAssignedByPrefetch = true;
9330
- var optimizedPods = this.config.optimizedPods !== false;
9331
8371
  var breakDurationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : void 0;
9332
- var generatedUrls = optimizedPods ? [
8372
+ var generatedUrls = [
9333
8373
  this.generatePodVastUrl(baseVastUrl, breakDurationMs)
9334
- ] : this.generateVastUrls(baseVastUrl, 1);
8374
+ ];
9335
8375
  this.adBreak.pendingAdBreak = _object_spread_props(_object_spread({
9336
8376
  marker: marker
9337
8377
  }, fragmentSn !== void 0 ? {
@@ -9353,15 +8393,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9353
8393
  }, detectPayload), buildAnalyticsContext(this.config)).catch(function() {});
9354
8394
  if (this.debug) {
9355
8395
  console.log("[PREFETCH] Starting ad prefetch for upcoming ad break");
9356
- console.log("[PREFETCH] Pre-generated ".concat(generatedUrls.length, " ").concat(optimizedPods ? "pod" : "VAST", " URL(s)"));
9357
- }
9358
- if (optimizedPods) {
9359
- if (this.debug) {
9360
- console.log("[PREFETCH] Optimized pods enabled - skipping single-ad preload pool");
9361
- }
9362
- return;
8396
+ console.log("[PREFETCH] Pre-generated pod request URL");
9363
8397
  }
9364
- this.preloadPool.startPreloadPool(baseVastUrl, generatedUrls.slice(0, 1), false);
9365
8398
  }
9366
8399
  },
9367
8400
  {
@@ -9600,7 +8633,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9600
8633
  value: function destroy() {
9601
8634
  var _this_adPlayer;
9602
8635
  this.adBreak.stopContinuousFetching();
9603
- this.preloadPool.stop();
9604
8636
  this.timing.destroy();
9605
8637
  this.adBreak.clearPendingAdBreak();
9606
8638
  this.placeholder.destroy();