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
@@ -3416,21 +3416,16 @@ function applyVastMacros(baseUrl, ctx) {
3416
3416
  if (ctx.pod != null) {
3417
3417
  params.set("pod", String(ctx.pod));
3418
3418
  }
3419
- var optimizedPodMode = ctx.podMaxAds != null || ctx.podMinDurationMs != null || ctx.podMaxDurationMs != null;
3420
- if (optimizedPodMode) {
3421
- params.delete("ppos");
3422
- params.delete("lip");
3423
- if (ctx.podMinDurationMs != null) {
3424
- params.set("pmnd", String(Math.max(0, Math.round(ctx.podMinDurationMs))));
3425
- }
3426
- if (ctx.podMaxDurationMs != null) {
3427
- params.set("pmxd", String(Math.max(0, Math.round(ctx.podMaxDurationMs))));
3428
- }
3429
- if (ctx.podMaxAds != null) {
3430
- params.set("pmad", String(Math.max(1, Math.round(ctx.podMaxAds))));
3431
- }
3432
- } else if (ctx.adPosition != null) {
3433
- params.set("ppos", String(ctx.adPosition));
3419
+ params.delete("ppos");
3420
+ params.delete("lip");
3421
+ if (ctx.podMinDurationMs != null) {
3422
+ params.set("pmnd", String(Math.max(0, Math.round(ctx.podMinDurationMs))));
3423
+ }
3424
+ if (ctx.podMaxDurationMs != null) {
3425
+ params.set("pmxd", String(Math.max(0, Math.round(ctx.podMaxDurationMs))));
3426
+ }
3427
+ if (ctx.podMaxAds != null) {
3428
+ params.set("pmad", String(Math.max(1, Math.round(ctx.podMaxAds))));
3434
3429
  }
3435
3430
  var requestUrl = ctx.contentUrl || ctx.pageUrl;
3436
3431
  if (requestUrl) {
@@ -4770,9 +4765,9 @@ var AdConfigManager = /*#__PURE__*/ function() {
4770
4765
  this.consentSignals = {};
4771
4766
  this.podCounter = 0;
4772
4767
  this.podAssignedByPrefetch = false;
4773
- this.adRequestPositionInBreak = 0;
4774
4768
  this.lastHeartbeatTime = 0;
4775
4769
  this.defaultPodMaxAds = 6;
4770
+ this.defaultPodMaxDurationMs = 12e4;
4776
4771
  this.config = config;
4777
4772
  this.video = video;
4778
4773
  }
@@ -5190,48 +5185,12 @@ var AdConfigManager = /*#__PURE__*/ function() {
5190
5185
  key: "beginNewAdPod",
5191
5186
  value: function beginNewAdPod() {
5192
5187
  this.podCounter++;
5193
- this.adRequestPositionInBreak = 0;
5194
- }
5195
- },
5196
- {
5197
- key: "generateVastUrlsWithCorrelators",
5198
- value: function generateVastUrlsWithCorrelators(baseUrl, count, adPlayer, palNonce, inAdBreak) {
5199
- var urls = [];
5200
- for(var i = 0; i < count; i++){
5201
- this.adRequestPositionInBreak++;
5202
- var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
5203
- var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest);
5204
- var urlWithMacros = applyVastMacros(baseUrl, {
5205
- correlator: this.viewCorrelator,
5206
- streamCorrelator: this.streamCorrelator,
5207
- pod: this.podCounter > 0 ? this.podCounter : void 0,
5208
- adPosition: this.adRequestPositionInBreak,
5209
- isCtv: envSignals.isCtv,
5210
- contentUrl: envSignals.contentUrl,
5211
- pageUrl: !envSignals.isCtv && typeof window !== "undefined" ? window.location.href : void 0,
5212
- adWillPlayMuted: adWillPlayMuted,
5213
- adWillAutoPlay: !!this.config.autoplay,
5214
- appId: envSignals.appId,
5215
- appName: envSignals.appName,
5216
- sessionId: envSignals.sessionId,
5217
- deviceId: envSignals.deviceId,
5218
- deviceIdType: envSignals.deviceIdType,
5219
- limitAdTracking: envSignals.limitAdTracking,
5220
- deviceTypeHint: envSignals.deviceTypeHint,
5221
- adTest: this.config.adTest,
5222
- consent: this.consentSignals
5223
- });
5224
- var finalUrl = palNonce.injectNonce(urlWithMacros);
5225
- console.log("[StormcloudVideoPlayer] Resolved ad request URL (pod=".concat(this.podCounter, ", pos=").concat(this.adRequestPositionInBreak, "):"), finalUrl);
5226
- urls.push(finalUrl);
5227
- }
5228
- return urls;
5229
5188
  }
5230
5189
  },
5231
5190
  {
5232
5191
  key: "resolvePodParams",
5233
5192
  value: function resolvePodParams(breakDurationMs) {
5234
- var maxDurationMs = breakDurationMs != null && breakDurationMs > 0 ? breakDurationMs : this.config.podMaxDurationMs;
5193
+ var maxDurationMs = breakDurationMs != null && breakDurationMs > 0 ? breakDurationMs : this.config.podMaxDurationMs != null && this.config.podMaxDurationMs > 0 ? this.config.podMaxDurationMs : this.defaultPodMaxDurationMs;
5235
5194
  var maxAds = this.config.podMaxAds && this.config.podMaxAds > 0 ? this.config.podMaxAds : this.apiNumberAds && this.apiNumberAds > 0 ? this.apiNumberAds : this.defaultPodMaxAds;
5236
5195
  var minDurationMs = this.config.podExactDuration && maxDurationMs != null ? maxDurationMs : 0;
5237
5196
  return {
@@ -5884,462 +5843,6 @@ var AdTimingService = /*#__PURE__*/ function() {
5884
5843
  ]);
5885
5844
  return AdTimingService;
5886
5845
  }();
5887
- // src/player/AdPreloadPool.ts
5888
- var AdPreloadPool = /*#__PURE__*/ function() {
5889
- function AdPreloadPool(deps) {
5890
- _class_call_check(this, AdPreloadPool);
5891
- this.pool = [];
5892
- this.maxPoolSize = 2;
5893
- this.poolActive = false;
5894
- this.loopRunning = false;
5895
- this.deps = deps;
5896
- }
5897
- _create_class(AdPreloadPool, [
5898
- {
5899
- key: "active",
5900
- get: function get() {
5901
- return this.poolActive;
5902
- },
5903
- set: function set(value) {
5904
- this.poolActive = value;
5905
- }
5906
- },
5907
- {
5908
- key: "isLoopRunning",
5909
- get: function get() {
5910
- return this.loopRunning;
5911
- }
5912
- },
5913
- {
5914
- key: "startPreloadPool",
5915
- value: function startPreloadPool(baseVastUrl, initialUrls) {
5916
- var startLoopImmediately = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
5917
- if (this.poolActive) {
5918
- if (this.deps.debug) {
5919
- console.log("[PRELOAD-POOL] Already active, skipping duplicate start");
5920
- }
5921
- return;
5922
- }
5923
- this.poolActive = true;
5924
- if (this.deps.debug) {
5925
- console.log("[PRELOAD-POOL] Starting preload pool EARLY (target size: ".concat(this.maxPoolSize, ")"));
5926
- console.log("[PRELOAD-POOL] Ad break hasn't started yet, but preloading ads in advance");
5927
- }
5928
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
5929
- try {
5930
- for(var _iterator = initialUrls[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
5931
- var url = _step.value;
5932
- if (this.pool.length < this.maxPoolSize) {
5933
- this.preloadAdIntoPool(url);
5934
- }
5935
- }
5936
- } catch (err) {
5937
- _didIteratorError = true;
5938
- _iteratorError = err;
5939
- } finally{
5940
- try {
5941
- if (!_iteratorNormalCompletion && _iterator.return != null) {
5942
- _iterator.return();
5943
- }
5944
- } finally{
5945
- if (_didIteratorError) {
5946
- throw _iteratorError;
5947
- }
5948
- }
5949
- }
5950
- if (startLoopImmediately) {
5951
- this.preloadPoolLoop(baseVastUrl);
5952
- } else if (this.deps.debug) {
5953
- console.log("[PRELOAD-POOL] Pre-break mode: preloaded once, waiting for SCTE start to continue fetching");
5954
- }
5955
- }
5956
- },
5957
- {
5958
- key: "preloadAdIntoPool",
5959
- value: function preloadAdIntoPool(vastUrl) {
5960
- return _async_to_generator(function() {
5961
- var _this, timing, epoch, loadPromise;
5962
- return _ts_generator(this, function(_state) {
5963
- _this = this;
5964
- timing = this.deps.timing;
5965
- if (timing.isGamInCooldown()) {
5966
- if (this.deps.debug) {
5967
- console.log("[CIRCUIT-BREAKER] GAM in cooldown, skipping preload");
5968
- }
5969
- return [
5970
- 2
5971
- ];
5972
- }
5973
- if (this.pool.some(function(entry) {
5974
- return entry.vastUrl === vastUrl;
5975
- }) || timing.failedVastUrls.has(vastUrl) || timing.isUrlInCooldown(vastUrl)) {
5976
- return [
5977
- 2
5978
- ];
5979
- }
5980
- if (this.pool.length >= this.maxPoolSize) {
5981
- return [
5982
- 2
5983
- ];
5984
- }
5985
- if (this.deps.debug) {
5986
- console.log("[PRELOAD-POOL] Preloading ad into pool: ".concat(vastUrl));
5987
- }
5988
- epoch = timing.adBreakEpoch;
5989
- loadPromise = function() {
5990
- return _async_to_generator(function() {
5991
- var _this, hasAdError, adErrorPayload, errorListenerCleanup, _preloadAd_getLoadedAdDuration, continueLiveStreamDuringAds, preloadAd, errorListener, isNoFill, poolEntry, loadedDuration, lateErrorListener, _poolEntry_durationSeconds, error;
5992
- return _ts_generator(this, function(_state) {
5993
- switch(_state.label){
5994
- case 0:
5995
- _this = this;
5996
- hasAdError = false;
5997
- adErrorPayload = null;
5998
- errorListenerCleanup = null;
5999
- _state.label = 1;
6000
- case 1:
6001
- _state.trys.push([
6002
- 1,
6003
- 5,
6004
- ,
6005
- 6
6006
- ]);
6007
- continueLiveStreamDuringAds = this.deps.shouldContinueLiveStreamDuringAds();
6008
- preloadAd = this.deps.createAdPlayer(continueLiveStreamDuringAds);
6009
- preloadAd.initialize();
6010
- errorListener = function errorListener(payload) {
6011
- hasAdError = true;
6012
- adErrorPayload = payload;
6013
- };
6014
- preloadAd.on("ad_error", errorListener);
6015
- errorListenerCleanup = function errorListenerCleanup() {
6016
- return preloadAd.off("ad_error", errorListener);
6017
- };
6018
- return [
6019
- 4,
6020
- timing.enforceGlobalRateLimit()
6021
- ];
6022
- case 2:
6023
- _state.sent();
6024
- return [
6025
- 4,
6026
- preloadAd.requestAds(vastUrl)
6027
- ];
6028
- case 3:
6029
- _state.sent();
6030
- preloadAd.pause();
6031
- return [
6032
- 4,
6033
- new Promise(function(resolve) {
6034
- return setTimeout(resolve, 1500);
6035
- })
6036
- ];
6037
- case 4:
6038
- _state.sent();
6039
- preloadAd.pause();
6040
- if (hasAdError) {
6041
- 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;
6042
- if (errorListenerCleanup) {
6043
- errorListenerCleanup();
6044
- }
6045
- preloadAd.destroy();
6046
- timing.recordGamNoFill();
6047
- if (isNoFill) {
6048
- if (this.deps.debug) {
6049
- console.log("[PRELOAD-POOL] Ad preload returned no-fill: ".concat(vastUrl));
6050
- }
6051
- timing.temporaryFailureUrls.set(vastUrl, Date.now());
6052
- } else {
6053
- if (this.deps.debug) {
6054
- console.log("[PRELOAD-POOL] Ad preload failed with error: ".concat(vastUrl), adErrorPayload);
6055
- }
6056
- if (adErrorPayload && !timing.isTemporaryAdError(adErrorPayload)) {
6057
- timing.failedVastUrls.add(vastUrl);
6058
- } else {
6059
- timing.temporaryFailureUrls.set(vastUrl, Date.now());
6060
- }
6061
- }
6062
- return [
6063
- 2
6064
- ];
6065
- }
6066
- if (!this.poolActive || epoch !== timing.adBreakEpoch) {
6067
- if (this.deps.debug) {
6068
- console.log("[PRELOAD-POOL] Discarding preloaded ad - break ended during fetch");
6069
- }
6070
- if (errorListenerCleanup) {
6071
- errorListenerCleanup();
6072
- }
6073
- try {
6074
- preloadAd.destroy();
6075
- } catch (unused) {}
6076
- return [
6077
- 2
6078
- ];
6079
- }
6080
- poolEntry = {
6081
- vastUrl: vastUrl,
6082
- adController: preloadAd,
6083
- loadedAt: Date.now(),
6084
- isReady: true,
6085
- loadPromise: Promise.resolve()
6086
- };
6087
- loadedDuration = (_preloadAd_getLoadedAdDuration = preloadAd.getLoadedAdDuration) === null || _preloadAd_getLoadedAdDuration === void 0 ? void 0 : _preloadAd_getLoadedAdDuration.call(preloadAd);
6088
- if (loadedDuration != null && loadedDuration > 0) {
6089
- poolEntry.durationSeconds = loadedDuration;
6090
- }
6091
- lateErrorListener = function lateErrorListener(payload) {
6092
- var index = _this.pool.findIndex(function(entry) {
6093
- return entry.vastUrl === vastUrl;
6094
- });
6095
- if (index >= 0) {
6096
- _this.pool.splice(index, 1);
6097
- if (_this.deps.debug) {
6098
- console.log("[PRELOAD-POOL] Late error detected, removed from pool: ".concat(vastUrl), payload);
6099
- }
6100
- try {
6101
- preloadAd.destroy();
6102
- } catch (unused) {}
6103
- }
6104
- };
6105
- preloadAd.on("ad_error", lateErrorListener);
6106
- this.pool.push(poolEntry);
6107
- if (this.deps.debug) {
6108
- ;
6109
- 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)"));
6110
- }
6111
- if (errorListenerCleanup) {
6112
- errorListenerCleanup();
6113
- }
6114
- return [
6115
- 3,
6116
- 6
6117
- ];
6118
- case 5:
6119
- error = _state.sent();
6120
- if (errorListenerCleanup) {
6121
- errorListenerCleanup();
6122
- }
6123
- timing.recordGamNoFill();
6124
- if (this.deps.debug) {
6125
- console.warn("[PRELOAD-POOL] Failed to preload ad: ".concat(vastUrl), error);
6126
- }
6127
- if (_instanceof(error, Error) && !timing.isTemporaryAdError(error)) {
6128
- timing.failedVastUrls.add(vastUrl);
6129
- } else if (_instanceof(error, Error) && timing.isTemporaryAdError(error)) {
6130
- timing.temporaryFailureUrls.set(vastUrl, Date.now());
6131
- }
6132
- return [
6133
- 3,
6134
- 6
6135
- ];
6136
- case 6:
6137
- return [
6138
- 2
6139
- ];
6140
- }
6141
- });
6142
- }).call(_this);
6143
- }();
6144
- loadPromise.catch(function() {});
6145
- return [
6146
- 2
6147
- ];
6148
- });
6149
- }).call(this);
6150
- }
6151
- },
6152
- {
6153
- key: "preloadPoolLoop",
6154
- value: function preloadPoolLoop(baseVastUrl) {
6155
- return _async_to_generator(function() {
6156
- var epoch, newUrls, newUrl;
6157
- return _ts_generator(this, function(_state) {
6158
- switch(_state.label){
6159
- case 0:
6160
- if (this.loopRunning) {
6161
- return [
6162
- 2
6163
- ];
6164
- }
6165
- this.loopRunning = true;
6166
- epoch = this.deps.timing.adBreakEpoch;
6167
- if (this.deps.debug) {
6168
- console.log("[PRELOAD-POOL] Starting continuous preload loop");
6169
- }
6170
- _state.label = 1;
6171
- case 1:
6172
- if (!(this.poolActive && epoch === this.deps.timing.adBreakEpoch)) return [
6173
- 3,
6174
- 10
6175
- ];
6176
- if (this.deps.timing.isGamInCooldown()) {
6177
- if (this.deps.debug) {
6178
- console.log("[CIRCUIT-BREAKER] GAM in cooldown, stopping preload pool loop");
6179
- }
6180
- return [
6181
- 3,
6182
- 10
6183
- ];
6184
- }
6185
- if (!(!this.deps.isInAdBreak() && this.pool.length >= this.maxPoolSize)) return [
6186
- 3,
6187
- 3
6188
- ];
6189
- return [
6190
- 4,
6191
- new Promise(function(resolve) {
6192
- return setTimeout(resolve, 2e3);
6193
- })
6194
- ];
6195
- case 2:
6196
- _state.sent();
6197
- return [
6198
- 3,
6199
- 1
6200
- ];
6201
- case 3:
6202
- if (!this.deps.isInAdBreak() && this.deps.getPendingAdBreak() === null) {
6203
- if (this.deps.debug) {
6204
- console.log("[PRELOAD-POOL] Ad break cancelled, stopping preload pool");
6205
- }
6206
- return [
6207
- 3,
6208
- 10
6209
- ];
6210
- }
6211
- _state.label = 4;
6212
- case 4:
6213
- if (!(this.pool.length < this.maxPoolSize)) return [
6214
- 3,
6215
- 8
6216
- ];
6217
- if (!this.poolActive || epoch !== this.deps.timing.adBreakEpoch || this.deps.timing.isGamInCooldown()) {
6218
- return [
6219
- 3,
6220
- 8
6221
- ];
6222
- }
6223
- if (this.deps.isInAdBreak() && !this.deps.timing.hasTimeToStartAnotherAd()) {
6224
- if (this.deps.debug) {
6225
- console.log("[PRELOAD-POOL] Not enough ad break time left, stopping preload");
6226
- }
6227
- return [
6228
- 3,
6229
- 8
6230
- ];
6231
- }
6232
- newUrls = this.deps.generateVastUrlsWithCorrelators(baseVastUrl, 1);
6233
- newUrl = newUrls[0];
6234
- if (!(newUrl && !this.deps.timing.failedVastUrls.has(newUrl) && !this.deps.timing.isUrlInCooldown(newUrl))) return [
6235
- 3,
6236
- 6
6237
- ];
6238
- return [
6239
- 4,
6240
- this.preloadAdIntoPool(newUrl)
6241
- ];
6242
- case 5:
6243
- _state.sent();
6244
- _state.label = 6;
6245
- case 6:
6246
- return [
6247
- 4,
6248
- new Promise(function(resolve) {
6249
- return setTimeout(resolve, 1e3);
6250
- })
6251
- ];
6252
- case 7:
6253
- _state.sent();
6254
- return [
6255
- 3,
6256
- 4
6257
- ];
6258
- case 8:
6259
- return [
6260
- 4,
6261
- new Promise(function(resolve) {
6262
- return setTimeout(resolve, 2e3);
6263
- })
6264
- ];
6265
- case 9:
6266
- _state.sent();
6267
- return [
6268
- 3,
6269
- 1
6270
- ];
6271
- case 10:
6272
- this.loopRunning = false;
6273
- if (this.deps.debug) {
6274
- console.log("[PRELOAD-POOL] Preload loop ended");
6275
- }
6276
- return [
6277
- 2
6278
- ];
6279
- }
6280
- });
6281
- }).call(this);
6282
- }
6283
- },
6284
- {
6285
- key: "getPreloadedAd",
6286
- value: function getPreloadedAd() {
6287
- if (this.pool.length === 0) {
6288
- return null;
6289
- }
6290
- var entry = this.pool.shift();
6291
- if (!entry || !entry.isReady) {
6292
- return null;
6293
- }
6294
- if (this.deps.debug) {
6295
- console.log("[PRELOAD-POOL] Using preloaded ad from pool (".concat(this.pool.length, " remaining)"));
6296
- }
6297
- return {
6298
- vastUrl: entry.vastUrl,
6299
- adController: entry.adController
6300
- };
6301
- }
6302
- },
6303
- {
6304
- key: "stop",
6305
- value: function stop() {
6306
- this.poolActive = false;
6307
- this.loopRunning = false;
6308
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6309
- try {
6310
- for(var _iterator = this.pool[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6311
- var entry = _step.value;
6312
- try {
6313
- entry.adController.destroy();
6314
- } catch (error) {
6315
- if (this.deps.debug) {
6316
- console.warn("[PRELOAD-POOL] Error destroying preloaded controller:", error);
6317
- }
6318
- }
6319
- }
6320
- } catch (err) {
6321
- _didIteratorError = true;
6322
- _iteratorError = err;
6323
- } finally{
6324
- try {
6325
- if (!_iteratorNormalCompletion && _iterator.return != null) {
6326
- _iterator.return();
6327
- }
6328
- } finally{
6329
- if (_didIteratorError) {
6330
- throw _iteratorError;
6331
- }
6332
- }
6333
- }
6334
- this.pool = [];
6335
- if (this.deps.debug) {
6336
- console.log("[PRELOAD-POOL] Preload pool stopped and cleaned up");
6337
- }
6338
- }
6339
- }
6340
- ]);
6341
- return AdPreloadPool;
6342
- }();
6343
5846
  // src/player/PlaceholderLayer.ts
6344
5847
  var PlaceholderLayer = /*#__PURE__*/ function() {
6345
5848
  function PlaceholderLayer(video, debug) {
@@ -7061,7 +6564,7 @@ function resizePlayer(video, adPlayer, debug) {
7061
6564
  }
7062
6565
  // src/player/AdBreakOrchestrator.ts
7063
6566
  var AdBreakOrchestrator = /*#__PURE__*/ function() {
7064
- function AdBreakOrchestrator(host, timing, preloadPool, adConfig, cueManager, placeholder) {
6567
+ function AdBreakOrchestrator(host, timing, adConfig, cueManager, placeholder) {
7065
6568
  _class_call_check(this, AdBreakOrchestrator);
7066
6569
  this.inAdBreak = false;
7067
6570
  this.showAds = false;
@@ -7075,7 +6578,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7075
6578
  this.pendingAdBreak = null;
7076
6579
  this.host = host;
7077
6580
  this.timing = timing;
7078
- this.preloadPool = preloadPool;
7079
6581
  this.adConfig = adConfig;
7080
6582
  this.cueManager = cueManager;
7081
6583
  this.placeholder = placeholder;
@@ -7094,12 +6596,19 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7094
6596
  }
7095
6597
  },
7096
6598
  {
7097
- key: "optimizedPodsEnabled",
7098
- get: // ───────────────────────────────────────────────────────────────
6599
+ // ───────────────────────────────────────────────────────────────
7099
6600
  // IMA event listeners
7100
6601
  // ───────────────────────────────────────────────────────────────
7101
- function get() {
7102
- return this.host.config.optimizedPods !== false;
6602
+ /**
6603
+ * Produces the next pod ad-request URL for the current break. Every request
6604
+ * (initial and continuous-fetch top-up) carries pod macros (pmad/pmnd/pmxd,
6605
+ * no ppos); pmxd tracks the remaining break time so top-up pods only ask for
6606
+ * what still fits.
6607
+ */ key: "nextAdRequestUrl",
6608
+ value: function nextAdRequestUrl(baseVastUrl) {
6609
+ var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
6610
+ var breakDurationMs = remaining > 0 ? remaining : void 0;
6611
+ return this.host.generatePodVastUrl(baseVastUrl, breakDurationMs);
7103
6612
  }
7104
6613
  },
7105
6614
  {
@@ -7271,7 +6780,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7271
6780
  // ───────────────────────────────────────────────────────────────
7272
6781
  function handleAdStart(_marker) {
7273
6782
  return _async_to_generator(function() {
7274
- 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;
6783
+ var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, podPlayed;
7275
6784
  return _ts_generator(this, function(_state) {
7276
6785
  switch(_state.label){
7277
6786
  case 0:
@@ -7318,292 +6827,29 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7318
6827
  if (this.timing.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
7319
6828
  this.timing.expectedAdBreakDurationMs = adBreakDurationMs;
7320
6829
  }
7321
- if (!this.optimizedPodsEnabled) return [
7322
- 3,
7323
- 2
7324
- ];
7325
6830
  return [
7326
6831
  4,
7327
6832
  this.startOptimizedPod(baseVastUrl, adBreakDurationMs, currentMuted, currentVolume)
7328
6833
  ];
7329
6834
  case 1:
7330
6835
  podPlayed = _state.sent();
7331
- if (podPlayed) {
7332
- return [
7333
- 2
7334
- ];
7335
- }
6836
+ if (!!podPlayed) return [
6837
+ 3,
6838
+ 3
6839
+ ];
7336
6840
  if (this.debug) {
7337
- console.log("[POD] Optimized pod unavailable, falling back to sequential single-ad path");
6841
+ console.log("[POD] Initial pod request did not fill; attempting top-up pod request");
7338
6842
  }
7339
- _state.label = 2;
6843
+ this.continuousFetchingActive = true;
6844
+ this.startContinuousFetching(baseVastUrl);
6845
+ return [
6846
+ 4,
6847
+ this.tryNextAvailableAdWithRateLimit()
6848
+ ];
7340
6849
  case 2:
7341
- usePreloadedAd = false;
7342
- preloaded = this.preloadPool.getPreloadedAd();
7343
- if (preloaded) {
7344
- firstAdUrl = preloaded.vastUrl;
7345
- preloadedController = preloaded.adController;
7346
- usePreloadedAd = true;
7347
- sendAdLoadedTracking(this.host.config.licenseKey, {
7348
- source: "hls",
7349
- vastUrl: firstAdUrl,
7350
- timestamp: /* @__PURE__ */ new Date().toISOString()
7351
- }, this.analyticsContext).catch(function() {});
7352
- if (this.debug) {
7353
- console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool (preloaded in advance, ready immediately!)");
7354
- }
7355
- } else if (this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0) {
7356
- this.adRequestQueue = _to_consumable_array(this.pendingAdBreak.vastUrls);
7357
- firstAdUrl = this.adRequestQueue.shift();
7358
- if (this.debug) {
7359
- console.log("[CONTINUOUS-FETCH] Pool empty, using prefetched URLs (".concat(this.adRequestQueue.length + 1, " available)"));
7360
- }
7361
- this.clearPendingAdBreak();
7362
- } else {
7363
- if (this.debug) {
7364
- console.log("[CONTINUOUS-FETCH] Generating new ad URLs...");
7365
- }
7366
- firstAdUrlArray = this.host.generateVastUrls(baseVastUrl, 1);
7367
- firstAdUrl = firstAdUrlArray[0];
7368
- this.adRequestQueue = [];
7369
- }
7370
- if (!firstAdUrl) {
7371
- if (this.debug) {
7372
- console.warn("[CONTINUOUS-FETCH] Failed to get first ad URL");
7373
- }
7374
- this.handleAdPodComplete();
7375
- return [
7376
- 2
7377
- ];
7378
- }
7379
- if (this.debug) {
7380
- console.log("[CONTINUOUS-FETCH] First VAST URL:", firstAdUrl);
7381
- }
6850
+ _state.sent();
7382
6851
  _state.label = 3;
7383
6852
  case 3:
7384
- _state.trys.push([
7385
- 3,
7386
- 14,
7387
- ,
7388
- 22
7389
- ]);
7390
- if (!(usePreloadedAd && preloadedController)) return [
7391
- 3,
7392
- 7
7393
- ];
7394
- if (!!this.timing.ensureLoadedAdFitsBudget(preloadedController)) return [
7395
- 3,
7396
- 5
7397
- ];
7398
- this.timing.rejectLoadedAdForDuration(preloadedController);
7399
- this.startContinuousFetching(baseVastUrl);
7400
- return [
7401
- 4,
7402
- this.tryNextAvailableAdWithRateLimit()
7403
- ];
7404
- case 4:
7405
- _state.sent();
7406
- return [
7407
- 2
7408
- ];
7409
- case 5:
7410
- adPlayer = this.host.getAdPlayer();
7411
- preservedMuted = adPlayer.getOriginalMutedState();
7412
- preservedVolume = adPlayer.getOriginalVolume();
7413
- adPlayer.destroy();
7414
- this.host.video.muted = true;
7415
- this.host.setAdPlayer(preloadedController);
7416
- preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
7417
- this.attachImaEventListeners();
7418
- if (this.debug) {
7419
- console.log("[CONTINUOUS-FETCH] Using preloaded ad, resuming and starting playback immediately (no request delay!)");
7420
- }
7421
- preloadedController.resume();
7422
- this.timing.consecutiveFailures = 0;
7423
- this.startContinuousFetching(baseVastUrl);
7424
- if (!this.preloadPool.active) {
7425
- this.preloadPool.active = true;
7426
- }
7427
- if (!this.preloadPool.isLoopRunning) {
7428
- this.preloadPool.preloadPoolLoop(baseVastUrl);
7429
- }
7430
- return [
7431
- 4,
7432
- preloadedController.play()
7433
- ];
7434
- case 6:
7435
- _state.sent();
7436
- this.timing.markAdStarted();
7437
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7438
- this.timing.scheduleAdStopAtBreakBoundary();
7439
- }
7440
- adVolume = currentMuted ? 0 : currentVolume;
7441
- preloadedController.setAdVolume(adVolume);
7442
- return [
7443
- 3,
7444
- 13
7445
- ];
7446
- case 7:
7447
- adPlayer1 = this.host.getAdPlayer();
7448
- return [
7449
- 4,
7450
- this.timing.enforceGlobalRateLimit()
7451
- ];
7452
- case 8:
7453
- _state.sent();
7454
- this.timing.lastAdRequestTime = Date.now();
7455
- return [
7456
- 4,
7457
- adPlayer1.requestAds(firstAdUrl)
7458
- ];
7459
- case 9:
7460
- _state.sent();
7461
- sendAdLoadedTracking(this.host.config.licenseKey, {
7462
- source: "hls",
7463
- vastUrl: firstAdUrl,
7464
- timestamp: /* @__PURE__ */ new Date().toISOString()
7465
- }, this.analyticsContext).catch(function() {});
7466
- if (this.debug) {
7467
- console.log("[CONTINUOUS-FETCH] First ad request successful, starting playback");
7468
- }
7469
- if (!!this.timing.ensureLoadedAdFitsBudget(adPlayer1)) return [
7470
- 3,
7471
- 11
7472
- ];
7473
- this.timing.rejectLoadedAdForDuration(adPlayer1);
7474
- this.recreateAdController();
7475
- this.startContinuousFetching(baseVastUrl);
7476
- return [
7477
- 4,
7478
- this.tryNextAvailableAdWithRateLimit()
7479
- ];
7480
- case 10:
7481
- _state.sent();
7482
- return [
7483
- 2
7484
- ];
7485
- case 11:
7486
- this.timing.consecutiveFailures = 0;
7487
- this.startContinuousFetching(baseVastUrl);
7488
- if (!this.preloadPool.active) {
7489
- this.preloadPool.startPreloadPool(baseVastUrl, []);
7490
- }
7491
- return [
7492
- 4,
7493
- adPlayer1.play()
7494
- ];
7495
- case 12:
7496
- _state.sent();
7497
- this.timing.markAdStarted();
7498
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7499
- this.timing.scheduleAdStopAtBreakBoundary();
7500
- }
7501
- adVolume1 = currentMuted ? 0 : currentVolume;
7502
- adPlayer1.setAdVolume(adVolume1);
7503
- _state.label = 13;
7504
- case 13:
7505
- return [
7506
- 3,
7507
- 22
7508
- ];
7509
- case 14:
7510
- error = _state.sent();
7511
- if (this.debug) {
7512
- console.warn("[CONTINUOUS-FETCH] First ad request failed:", error);
7513
- }
7514
- if (!!usePreloadedAd) return [
7515
- 3,
7516
- 20
7517
- ];
7518
- fallbackPreloaded = this.preloadPool.getPreloadedAd();
7519
- if (!fallbackPreloaded) return [
7520
- 3,
7521
- 20
7522
- ];
7523
- if (this.debug) {
7524
- console.log("[CONTINUOUS-FETCH] First ad failed, using preloaded fallback");
7525
- }
7526
- _state.label = 15;
7527
- case 15:
7528
- _state.trys.push([
7529
- 15,
7530
- 19,
7531
- ,
7532
- 20
7533
- ]);
7534
- if (!!this.timing.ensureLoadedAdFitsBudget(fallbackPreloaded.adController)) return [
7535
- 3,
7536
- 17
7537
- ];
7538
- this.timing.rejectLoadedAdForDuration(fallbackPreloaded.adController);
7539
- this.startContinuousFetching(baseVastUrl);
7540
- return [
7541
- 4,
7542
- this.tryNextAvailableAdWithRateLimit()
7543
- ];
7544
- case 16:
7545
- _state.sent();
7546
- return [
7547
- 2
7548
- ];
7549
- case 17:
7550
- this.swapToPreloadedAdPlayer(fallbackPreloaded.adController);
7551
- this.timing.consecutiveFailures = 0;
7552
- this.startContinuousFetching(baseVastUrl);
7553
- if (!this.preloadPool.active) {
7554
- this.preloadPool.active = true;
7555
- this.preloadPool.preloadPoolLoop(baseVastUrl);
7556
- }
7557
- ap = this.host.getAdPlayer();
7558
- return [
7559
- 4,
7560
- ap.play()
7561
- ];
7562
- case 18:
7563
- _state.sent();
7564
- this.timing.markAdStarted();
7565
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7566
- this.timing.scheduleAdStopAtBreakBoundary();
7567
- }
7568
- adVolume2 = currentMuted ? 0 : currentVolume;
7569
- ap.setAdVolume(adVolume2);
7570
- return [
7571
- 2
7572
- ];
7573
- case 19:
7574
- fallbackError = _state.sent();
7575
- if (this.debug) {
7576
- console.warn("[CONTINUOUS-FETCH] Preloaded fallback also failed:", fallbackError);
7577
- }
7578
- return [
7579
- 3,
7580
- 20
7581
- ];
7582
- case 20:
7583
- if (this.timing.isTemporaryAdError(error)) {
7584
- this.timing.temporaryFailureUrls.set(firstAdUrl, Date.now());
7585
- if (this.debug) {
7586
- console.log("[CONTINUOUS-FETCH] First ad had temporary error (no-fill) - will try alternatives");
7587
- }
7588
- } else {
7589
- this.timing.failedVastUrls.add(firstAdUrl);
7590
- if (this.debug) {
7591
- console.log("[CONTINUOUS-FETCH] First ad had permanent error - URL blacklisted");
7592
- }
7593
- }
7594
- this.timing.consecutiveFailures++;
7595
- this.startContinuousFetching(baseVastUrl);
7596
- return [
7597
- 4,
7598
- this.tryNextAvailableAdWithRateLimit()
7599
- ];
7600
- case 21:
7601
- _state.sent();
7602
- return [
7603
- 3,
7604
- 22
7605
- ];
7606
- case 22:
7607
6853
  return [
7608
6854
  2
7609
6855
  ];
@@ -7677,7 +6923,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7677
6923
  ];
7678
6924
  }
7679
6925
  if (this.debug) {
7680
- 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"));
6926
+ 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"));
7681
6927
  }
7682
6928
  sendAdLoadedTracking(this.host.config.licenseKey, {
7683
6929
  source: "hls",
@@ -7697,13 +6943,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7697
6943
  }
7698
6944
  adPlayer.setAdVolume(currentMuted ? 0 : currentVolume);
7699
6945
  this.timing.consecutiveFailures = 0;
7700
- if (podCount === 1) {
7701
- this.continuousFetchingActive = true;
7702
- this.startContinuousFetching(baseVastUrl);
7703
- if (!this.preloadPool.active) {
7704
- this.preloadPool.startPreloadPool(baseVastUrl, []);
7705
- }
7706
- }
6946
+ this.continuousFetchingActive = true;
6947
+ this.startContinuousFetching(baseVastUrl);
7707
6948
  return [
7708
6949
  2,
7709
6950
  true
@@ -7736,20 +6977,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7736
6977
  }).call(this);
7737
6978
  }
7738
6979
  },
7739
- {
7740
- key: "swapToPreloadedAdPlayer",
7741
- value: function swapToPreloadedAdPlayer(preloadedController) {
7742
- var adPlayer = this.host.getAdPlayer();
7743
- var preservedMuted = adPlayer.getOriginalMutedState();
7744
- var preservedVolume = adPlayer.getOriginalVolume();
7745
- adPlayer.destroy();
7746
- this.host.video.muted = true;
7747
- this.host.setAdPlayer(preloadedController);
7748
- this.attachImaEventListeners();
7749
- preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
7750
- preloadedController.resume();
7751
- }
7752
- },
7753
6980
  {
7754
6981
  // ───────────────────────────────────────────────────────────────
7755
6982
  // Continuous fetching
@@ -7843,7 +7070,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7843
7070
  "continue"
7844
7071
  ];
7845
7072
  case 2:
7846
- newAdUrl = _this.host.generateVastUrls(baseVastUrl, 1)[0];
7073
+ newAdUrl = _this.nextAdRequestUrl(baseVastUrl);
7847
7074
  if (!(!newAdUrl || _this.timing.failedVastUrls.has(newAdUrl) || _this.timing.isUrlInCooldown(newAdUrl))) return [
7848
7075
  3,
7849
7076
  4
@@ -8000,7 +7227,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8000
7227
  value: function tryNextAvailableAd() {
8001
7228
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
8002
7229
  return _async_to_generator(function() {
8003
- var remaining, preloaded, ap, error, nextAdUrl, error1, errorMessage, maxRetries;
7230
+ var remaining, nextAdUrl, error, errorMessage, maxRetries;
8004
7231
  return _ts_generator(this, function(_state) {
8005
7232
  switch(_state.label){
8006
7233
  case 0:
@@ -8038,132 +7265,71 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8038
7265
  ];
8039
7266
  }
8040
7267
  this.timing.cleanupTemporaryFailures();
8041
- preloaded = this.preloadPool.getPreloadedAd();
8042
- if (!preloaded) return [
8043
- 3,
8044
- 6
8045
- ];
8046
- if (this.debug) {
8047
- console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool");
8048
- }
8049
- sendAdLoadedTracking(this.host.config.licenseKey, {
8050
- source: "hls",
8051
- vastUrl: preloaded.vastUrl,
8052
- timestamp: /* @__PURE__ */ new Date().toISOString()
8053
- }, this.analyticsContext).catch(function() {});
8054
7268
  _state.label = 1;
8055
7269
  case 1:
8056
- _state.trys.push([
8057
- 1,
8058
- 5,
8059
- ,
8060
- 6
8061
- ]);
8062
- if (!!this.timing.ensureLoadedAdFitsBudget(preloaded.adController)) return [
8063
- 3,
8064
- 3
8065
- ];
8066
- this.timing.rejectLoadedAdForDuration(preloaded.adController);
8067
- return [
8068
- 4,
8069
- this.tryNextAvailableAdWithRateLimit()
8070
- ];
8071
- case 2:
8072
- _state.sent();
8073
- return [
8074
- 2
8075
- ];
8076
- case 3:
8077
- this.swapToPreloadedAdPlayer(preloaded.adController);
8078
- ap = this.host.getAdPlayer();
8079
- return [
8080
- 4,
8081
- ap.play()
8082
- ];
8083
- case 4:
8084
- _state.sent();
8085
- this.timing.markAdStarted();
8086
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
8087
- this.timing.scheduleAdStopAtBreakBoundary();
8088
- }
8089
- ap.setAdVolume(getAdAudioVolume(ap));
8090
- this.timing.consecutiveFailures = 0;
8091
- return [
8092
- 2
8093
- ];
8094
- case 5:
8095
- error = _state.sent();
8096
- if (this.debug) {
8097
- console.warn("[CONTINUOUS-FETCH] Preloaded ad failed to play:", error);
8098
- }
8099
- return [
8100
- 3,
8101
- 6
8102
- ];
8103
- case 6:
8104
7270
  if (!(this.adRequestQueue.length > 0)) return [
8105
7271
  3,
8106
- 14
7272
+ 9
8107
7273
  ];
8108
7274
  nextAdUrl = this.adRequestQueue.shift();
8109
7275
  if (!nextAdUrl) return [
8110
7276
  3,
8111
- 6
7277
+ 1
8112
7278
  ];
8113
7279
  if (this.timing.failedVastUrls.has(nextAdUrl)) {
8114
7280
  if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping permanently-failed URL, trying next...");
8115
7281
  return [
8116
7282
  3,
8117
- 6
7283
+ 1
8118
7284
  ];
8119
7285
  }
8120
7286
  if (this.timing.isUrlInCooldown(nextAdUrl)) {
8121
7287
  if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping URL in cooldown (recent no-fill), trying next...");
8122
7288
  return [
8123
7289
  3,
8124
- 6
7290
+ 1
8125
7291
  ];
8126
7292
  }
8127
7293
  if (this.debug) {
8128
7294
  console.log("[CONTINUOUS-FETCH] Requesting next ad via HLS ad player (".concat(this.timing.currentAdIndex + 1, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
8129
7295
  }
8130
- _state.label = 7;
8131
- case 7:
7296
+ _state.label = 2;
7297
+ case 2:
8132
7298
  _state.trys.push([
8133
- 7,
8134
- 9,
7299
+ 2,
7300
+ 4,
8135
7301
  ,
8136
- 13
7302
+ 8
8137
7303
  ]);
8138
7304
  return [
8139
7305
  4,
8140
7306
  this.playSingleAd(nextAdUrl)
8141
7307
  ];
8142
- case 8:
7308
+ case 3:
8143
7309
  _state.sent();
8144
7310
  this.timing.consecutiveFailures = 0;
8145
7311
  return [
8146
7312
  3,
8147
- 13
7313
+ 8
8148
7314
  ];
8149
- case 9:
8150
- error1 = _state.sent();
8151
- errorMessage = error1.message;
7315
+ case 4:
7316
+ error = _state.sent();
7317
+ errorMessage = error.message;
8152
7318
  if (this.debug) console.log("[CONTINUOUS-FETCH] Ad request failed:", errorMessage);
8153
7319
  if (!errorMessage.includes("ad_duration_exceeds_budget")) return [
8154
7320
  3,
8155
- 11
7321
+ 6
8156
7322
  ];
8157
7323
  return [
8158
7324
  4,
8159
7325
  this.tryNextAvailableAdWithRateLimit()
8160
7326
  ];
8161
- case 10:
7327
+ case 5:
8162
7328
  _state.sent();
8163
7329
  return [
8164
7330
  2
8165
7331
  ];
8166
- case 11:
7332
+ case 6:
8167
7333
  if (!errorMessage.includes("permanently failed") && !errorMessage.includes("in cooldown")) {
8168
7334
  this.timing.consecutiveFailures++;
8169
7335
  }
@@ -8171,21 +7337,21 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8171
7337
  4,
8172
7338
  this.tryNextAvailableAdWithRateLimit()
8173
7339
  ];
8174
- case 12:
7340
+ case 7:
8175
7341
  _state.sent();
8176
7342
  return [
8177
7343
  3,
8178
- 13
7344
+ 8
8179
7345
  ];
8180
- case 13:
7346
+ case 8:
8181
7347
  return [
8182
7348
  2
8183
7349
  ];
8184
- case 14:
7350
+ case 9:
8185
7351
  maxRetries = 3;
8186
7352
  if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
8187
7353
  3,
8188
- 17
7354
+ 12
8189
7355
  ];
8190
7356
  if (this.debug) {
8191
7357
  console.log("[CONTINUOUS-FETCH] Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
@@ -8196,18 +7362,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8196
7362
  return setTimeout(resolve, 500);
8197
7363
  })
8198
7364
  ];
8199
- case 15:
7365
+ case 10:
8200
7366
  _state.sent();
8201
7367
  return [
8202
7368
  4,
8203
7369
  this.tryNextAvailableAd(retryCount + 1)
8204
7370
  ];
8205
- case 16:
7371
+ case 11:
8206
7372
  _state.sent();
8207
7373
  return [
8208
7374
  2
8209
7375
  ];
8210
- case 17:
7376
+ case 12:
8211
7377
  if (!this.isShowingPlaceholder && remaining > 1e3) {
8212
7378
  this.showPlaceholderAndWaitForAds();
8213
7379
  } else {
@@ -8229,7 +7395,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8229
7395
  // ───────────────────────────────────────────────────────────────
8230
7396
  function playSingleAd(vastTagUrl) {
8231
7397
  return _async_to_generator(function() {
8232
- var adPlayer, requestToken, ap, playError, preloadedFallback, fbAp, fallbackError, error, errorMessage, preloadedFallback1, fbAp1, fallbackError1;
7398
+ var adPlayer, requestToken, ap, playError, error, errorMessage;
8233
7399
  return _ts_generator(this, function(_state) {
8234
7400
  switch(_state.label){
8235
7401
  case 0:
@@ -8261,9 +7427,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8261
7427
  case 1:
8262
7428
  _state.trys.push([
8263
7429
  1,
8264
- 12,
7430
+ 8,
8265
7431
  ,
8266
- 17
7432
+ 9
8267
7433
  ]);
8268
7434
  return [
8269
7435
  4,
@@ -8299,7 +7465,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8299
7465
  4,
8300
7466
  6,
8301
7467
  ,
8302
- 11
7468
+ 7
8303
7469
  ]);
8304
7470
  this.timing.startAdFailsafeTimer(requestToken);
8305
7471
  return [
@@ -8317,55 +7483,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8317
7483
  this.timing.temporaryFailureUrls.delete(vastTagUrl);
8318
7484
  return [
8319
7485
  3,
8320
- 11
7486
+ 7
8321
7487
  ];
8322
7488
  case 6:
8323
7489
  playError = _state.sent();
8324
7490
  if (this.debug) console.error("[AD-ERROR] Failed to play ad:", playError);
8325
- preloadedFallback = this.preloadPool.getPreloadedAd();
8326
- if (!preloadedFallback) return [
8327
- 3,
8328
- 10
8329
- ];
8330
- if (this.debug) console.log("[AD-ERROR] Play failed, trying preloaded fallback ad");
8331
- _state.label = 7;
8332
- case 7:
8333
- _state.trys.push([
8334
- 7,
8335
- 9,
8336
- ,
8337
- 10
8338
- ]);
8339
- if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback.adController)) {
8340
- this.timing.rejectLoadedAdForDuration(preloadedFallback.adController);
8341
- throw playError;
8342
- }
8343
- this.timing.clearAdFailsafeTimer();
8344
- this.swapToPreloadedAdPlayer(preloadedFallback.adController);
8345
- this.timing.consecutiveFailures = 0;
8346
- fbAp = this.host.getAdPlayer();
8347
- return [
8348
- 4,
8349
- fbAp.play()
8350
- ];
8351
- case 8:
8352
- _state.sent();
8353
- this.timing.markAdStarted();
8354
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
8355
- this.timing.scheduleAdStopAtBreakBoundary();
8356
- }
8357
- fbAp.setAdVolume(getAdAudioVolume(fbAp));
8358
- return [
8359
- 2
8360
- ];
8361
- case 9:
8362
- fallbackError = _state.sent();
8363
- if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError);
8364
- return [
8365
- 3,
8366
- 10
8367
- ];
8368
- case 10:
8369
7491
  if (this.timing.isTemporaryAdError(playError)) {
8370
7492
  this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
8371
7493
  if (this.debug) console.log("[AD-ERROR] Temporary play error - URL can be retried after cooldown");
@@ -8378,57 +7500,15 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8378
7500
  this.timing.activeAdRequestToken = null;
8379
7501
  }
8380
7502
  throw playError;
8381
- case 11:
7503
+ case 7:
8382
7504
  return [
8383
7505
  3,
8384
- 17
7506
+ 9
8385
7507
  ];
8386
- case 12:
7508
+ case 8:
8387
7509
  error = _state.sent();
8388
7510
  errorMessage = (error === null || error === void 0 ? void 0 : error.message) || "";
8389
7511
  if (this.debug) console.error("[AD-ERROR] Ad request failed:", errorMessage);
8390
- preloadedFallback1 = this.preloadPool.getPreloadedAd();
8391
- if (!preloadedFallback1) return [
8392
- 3,
8393
- 16
8394
- ];
8395
- if (this.debug) console.log("[AD-ERROR] Request failed, trying preloaded fallback ad");
8396
- _state.label = 13;
8397
- case 13:
8398
- _state.trys.push([
8399
- 13,
8400
- 15,
8401
- ,
8402
- 16
8403
- ]);
8404
- if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback1.adController)) {
8405
- this.timing.rejectLoadedAdForDuration(preloadedFallback1.adController);
8406
- throw error;
8407
- }
8408
- this.timing.clearAdRequestWatchdog();
8409
- this.timing.clearAdFailsafeTimer();
8410
- this.swapToPreloadedAdPlayer(preloadedFallback1.adController);
8411
- this.timing.consecutiveFailures = 0;
8412
- fbAp1 = this.host.getAdPlayer();
8413
- return [
8414
- 4,
8415
- fbAp1.play()
8416
- ];
8417
- case 14:
8418
- _state.sent();
8419
- this.timing.markAdStarted();
8420
- fbAp1.setAdVolume(getAdAudioVolume(fbAp1));
8421
- return [
8422
- 2
8423
- ];
8424
- case 15:
8425
- fallbackError1 = _state.sent();
8426
- if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError1);
8427
- return [
8428
- 3,
8429
- 16
8430
- ];
8431
- case 16:
8432
7512
  if (this.timing.isTemporaryAdError(error)) {
8433
7513
  this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
8434
7514
  if (this.debug) console.log("[AD-ERROR] Temporary error (no-fill/timeout) - URL can be retried after cooldown");
@@ -8442,7 +7522,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8442
7522
  this.timing.activeAdRequestToken = null;
8443
7523
  }
8444
7524
  throw error;
8445
- case 17:
7525
+ case 9:
8446
7526
  return [
8447
7527
  2
8448
7528
  ];
@@ -8632,7 +7712,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8632
7712
  }
8633
7713
  this.timing.resetForBreakEnd();
8634
7714
  this.stopContinuousFetching();
8635
- this.preloadPool.stop();
8636
7715
  this.clearPendingAdBreak();
8637
7716
  if (this.isShowingPlaceholder) {
8638
7717
  this.host.getAdPlayer().hidePlaceholder();
@@ -8742,25 +7821,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8742
7821
  return _this.adBreak.handleAdFailure();
8743
7822
  }
8744
7823
  });
8745
- this.preloadPool = new AdPreloadPool({
8746
- debug: !!this.config.debugAdTiming,
8747
- createAdPlayer: function createAdPlayer(c) {
8748
- return _this.createAdPlayer(c);
8749
- },
8750
- shouldContinueLiveStreamDuringAds: function shouldContinueLiveStreamDuringAds() {
8751
- return _this.shouldContinueLiveStreamDuringAds();
8752
- },
8753
- timing: this.timing,
8754
- generateVastUrlsWithCorrelators: function generateVastUrlsWithCorrelators(base, count) {
8755
- return _this.generateVastUrls(base, count);
8756
- },
8757
- isInAdBreak: function isInAdBreak() {
8758
- return _this.adBreak.inAdBreak;
8759
- },
8760
- getPendingAdBreak: function getPendingAdBreak() {
8761
- return _this.adBreak.pendingAdBreak;
8762
- }
8763
- });
8764
7824
  this.placeholder = new PlaceholderLayer(this.video, !!this.config.debugAdTiming);
8765
7825
  this.hlsEngine = new HlsEngine(this.config, this.video, this.cueManager, this.timing, {
8766
7826
  onManifestParsed: function onManifestParsed(isLive) {
@@ -8807,13 +7867,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8807
7867
  getLiveSyncPosition: function getLiveSyncPosition() {
8808
7868
  return _this.hlsEngine.getLiveSyncPosition();
8809
7869
  },
8810
- generateVastUrls: function generateVastUrls(base, count) {
8811
- return _this.generateVastUrls(base, count);
8812
- },
8813
7870
  generatePodVastUrl: function generatePodVastUrl(base, breakDurationMs) {
8814
7871
  return _this.generatePodVastUrl(base, breakDurationMs);
8815
7872
  }
8816
- }, this.timing, this.preloadPool, this.adConfig, this.cueManager, this.placeholder);
7873
+ }, this.timing, this.adConfig, this.cueManager, this.placeholder);
8817
7874
  }
8818
7875
  _create_class(StormcloudVideoPlayer, [
8819
7876
  {
@@ -8838,12 +7895,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8838
7895
  } : {}));
8839
7896
  }
8840
7897
  },
8841
- {
8842
- key: "generateVastUrls",
8843
- value: function generateVastUrls(baseUrl, count) {
8844
- return this.adConfig.generateVastUrlsWithCorrelators(baseUrl, count, this.adPlayer, this.palNonce, this.adBreak.inAdBreak);
8845
- }
8846
- },
8847
7898
  {
8848
7899
  key: "generatePodVastUrl",
8849
7900
  value: function generatePodVastUrl(baseUrl, breakDurationMs) {
@@ -9239,11 +8290,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9239
8290
  }
9240
8291
  this.adConfig.beginNewAdPod();
9241
8292
  this.adConfig.podAssignedByPrefetch = true;
9242
- var optimizedPods = this.config.optimizedPods !== false;
9243
8293
  var breakDurationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : void 0;
9244
- var generatedUrls = optimizedPods ? [
8294
+ var generatedUrls = [
9245
8295
  this.generatePodVastUrl(baseVastUrl, breakDurationMs)
9246
- ] : this.generateVastUrls(baseVastUrl, 1);
8296
+ ];
9247
8297
  this.adBreak.pendingAdBreak = _object_spread_props(_object_spread({
9248
8298
  marker: marker
9249
8299
  }, fragmentSn !== void 0 ? {
@@ -9265,15 +8315,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9265
8315
  }, detectPayload), buildAnalyticsContext(this.config)).catch(function() {});
9266
8316
  if (this.debug) {
9267
8317
  console.log("[PREFETCH] Starting ad prefetch for upcoming ad break");
9268
- console.log("[PREFETCH] Pre-generated ".concat(generatedUrls.length, " ").concat(optimizedPods ? "pod" : "VAST", " URL(s)"));
9269
- }
9270
- if (optimizedPods) {
9271
- if (this.debug) {
9272
- console.log("[PREFETCH] Optimized pods enabled - skipping single-ad preload pool");
9273
- }
9274
- return;
8318
+ console.log("[PREFETCH] Pre-generated pod request URL");
9275
8319
  }
9276
- this.preloadPool.startPreloadPool(baseVastUrl, generatedUrls.slice(0, 1), false);
9277
8320
  }
9278
8321
  },
9279
8322
  {
@@ -9512,7 +8555,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9512
8555
  value: function destroy() {
9513
8556
  var _this_adPlayer;
9514
8557
  this.adBreak.stopContinuousFetching();
9515
- this.preloadPool.stop();
9516
8558
  this.timing.destroy();
9517
8559
  this.adBreak.clearPendingAdBreak();
9518
8560
  this.placeholder.destroy();