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
@@ -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,23 +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;
7103
- }
7104
- },
7105
- {
7106
- key: "nextAdRequestUrl",
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",
7107
6608
  value: function nextAdRequestUrl(baseVastUrl) {
7108
- if (this.optimizedPodsEnabled) {
7109
- var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
7110
- var breakDurationMs = remaining > 0 ? remaining : void 0;
7111
- return this.host.generatePodVastUrl(baseVastUrl, breakDurationMs);
7112
- }
7113
- return this.host.generateVastUrls(baseVastUrl, 1)[0];
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);
7114
6612
  }
7115
6613
  },
7116
6614
  {
@@ -7282,7 +6780,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7282
6780
  // ───────────────────────────────────────────────────────────────
7283
6781
  function handleAdStart(_marker) {
7284
6782
  return _async_to_generator(function() {
7285
- var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, podPlayed, firstAdUrl, usePreloadedAd, preloadedController, preloaded, adPlayer, preservedMuted, preservedVolume, adVolume, adPlayer1, adVolume1, error, fallbackPreloaded, ap, adVolume2, fallbackError;
6783
+ var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, podPlayed;
7286
6784
  return _ts_generator(this, function(_state) {
7287
6785
  switch(_state.label){
7288
6786
  case 0:
@@ -7329,293 +6827,29 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7329
6827
  if (this.timing.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
7330
6828
  this.timing.expectedAdBreakDurationMs = adBreakDurationMs;
7331
6829
  }
7332
- if (!this.optimizedPodsEnabled) return [
7333
- 3,
7334
- 2
7335
- ];
7336
6830
  return [
7337
6831
  4,
7338
6832
  this.startOptimizedPod(baseVastUrl, adBreakDurationMs, currentMuted, currentVolume)
7339
6833
  ];
7340
6834
  case 1:
7341
6835
  podPlayed = _state.sent();
7342
- if (podPlayed) {
7343
- return [
7344
- 2
7345
- ];
7346
- }
6836
+ if (!!podPlayed) return [
6837
+ 3,
6838
+ 3
6839
+ ];
7347
6840
  if (this.debug) {
7348
- 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");
7349
6842
  }
7350
- _state.label = 2;
6843
+ this.continuousFetchingActive = true;
6844
+ this.startContinuousFetching(baseVastUrl);
6845
+ return [
6846
+ 4,
6847
+ this.tryNextAvailableAdWithRateLimit()
6848
+ ];
7351
6849
  case 2:
7352
- usePreloadedAd = false;
7353
- preloaded = this.preloadPool.getPreloadedAd();
7354
- if (preloaded) {
7355
- firstAdUrl = preloaded.vastUrl;
7356
- preloadedController = preloaded.adController;
7357
- usePreloadedAd = true;
7358
- sendAdLoadedTracking(this.host.config.licenseKey, {
7359
- source: "hls",
7360
- vastUrl: firstAdUrl,
7361
- timestamp: /* @__PURE__ */ new Date().toISOString()
7362
- }, this.analyticsContext).catch(function() {});
7363
- if (this.debug) {
7364
- console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool (preloaded in advance, ready immediately!)");
7365
- }
7366
- } else if (this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0) {
7367
- this.adRequestQueue = _to_consumable_array(this.pendingAdBreak.vastUrls);
7368
- firstAdUrl = this.adRequestQueue.shift();
7369
- if (this.debug) {
7370
- console.log("[CONTINUOUS-FETCH] Pool empty, using prefetched URLs (".concat(this.adRequestQueue.length + 1, " available)"));
7371
- }
7372
- this.clearPendingAdBreak();
7373
- } else {
7374
- if (this.debug) {
7375
- console.log("[CONTINUOUS-FETCH] Generating new ad URLs...");
7376
- }
7377
- firstAdUrl = this.nextAdRequestUrl(baseVastUrl);
7378
- this.adRequestQueue = [];
7379
- }
7380
- if (!firstAdUrl) {
7381
- if (this.debug) {
7382
- console.warn("[CONTINUOUS-FETCH] Failed to get first ad URL");
7383
- }
7384
- this.handleAdPodComplete();
7385
- return [
7386
- 2
7387
- ];
7388
- }
7389
- if (this.debug) {
7390
- console.log("[CONTINUOUS-FETCH] First VAST URL:", firstAdUrl);
7391
- }
6850
+ _state.sent();
7392
6851
  _state.label = 3;
7393
6852
  case 3:
7394
- _state.trys.push([
7395
- 3,
7396
- 14,
7397
- ,
7398
- 22
7399
- ]);
7400
- if (!(usePreloadedAd && preloadedController)) return [
7401
- 3,
7402
- 7
7403
- ];
7404
- if (!!this.timing.ensureLoadedAdFitsBudget(preloadedController)) return [
7405
- 3,
7406
- 5
7407
- ];
7408
- this.timing.rejectLoadedAdForDuration(preloadedController);
7409
- this.startContinuousFetching(baseVastUrl);
7410
- return [
7411
- 4,
7412
- this.tryNextAvailableAdWithRateLimit()
7413
- ];
7414
- case 4:
7415
- _state.sent();
7416
- return [
7417
- 2
7418
- ];
7419
- case 5:
7420
- adPlayer = this.host.getAdPlayer();
7421
- preservedMuted = adPlayer.getOriginalMutedState();
7422
- preservedVolume = adPlayer.getOriginalVolume();
7423
- adPlayer.destroy();
7424
- this.host.video.muted = true;
7425
- this.host.setAdPlayer(preloadedController);
7426
- preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
7427
- this.attachImaEventListeners();
7428
- if (this.debug) {
7429
- console.log("[CONTINUOUS-FETCH] Using preloaded ad, resuming and starting playback immediately (no request delay!)");
7430
- }
7431
- preloadedController.resume();
7432
- this.timing.consecutiveFailures = 0;
7433
- this.startContinuousFetching(baseVastUrl);
7434
- if (!this.optimizedPodsEnabled) {
7435
- if (!this.preloadPool.active) {
7436
- this.preloadPool.active = true;
7437
- }
7438
- if (!this.preloadPool.isLoopRunning) {
7439
- this.preloadPool.preloadPoolLoop(baseVastUrl);
7440
- }
7441
- }
7442
- return [
7443
- 4,
7444
- preloadedController.play()
7445
- ];
7446
- case 6:
7447
- _state.sent();
7448
- this.timing.markAdStarted();
7449
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7450
- this.timing.scheduleAdStopAtBreakBoundary();
7451
- }
7452
- adVolume = currentMuted ? 0 : currentVolume;
7453
- preloadedController.setAdVolume(adVolume);
7454
- return [
7455
- 3,
7456
- 13
7457
- ];
7458
- case 7:
7459
- adPlayer1 = this.host.getAdPlayer();
7460
- return [
7461
- 4,
7462
- this.timing.enforceGlobalRateLimit()
7463
- ];
7464
- case 8:
7465
- _state.sent();
7466
- this.timing.lastAdRequestTime = Date.now();
7467
- return [
7468
- 4,
7469
- adPlayer1.requestAds(firstAdUrl)
7470
- ];
7471
- case 9:
7472
- _state.sent();
7473
- sendAdLoadedTracking(this.host.config.licenseKey, {
7474
- source: "hls",
7475
- vastUrl: firstAdUrl,
7476
- timestamp: /* @__PURE__ */ new Date().toISOString()
7477
- }, this.analyticsContext).catch(function() {});
7478
- if (this.debug) {
7479
- console.log("[CONTINUOUS-FETCH] First ad request successful, starting playback");
7480
- }
7481
- if (!!this.timing.ensureLoadedAdFitsBudget(adPlayer1)) return [
7482
- 3,
7483
- 11
7484
- ];
7485
- this.timing.rejectLoadedAdForDuration(adPlayer1);
7486
- this.recreateAdController();
7487
- this.startContinuousFetching(baseVastUrl);
7488
- return [
7489
- 4,
7490
- this.tryNextAvailableAdWithRateLimit()
7491
- ];
7492
- case 10:
7493
- _state.sent();
7494
- return [
7495
- 2
7496
- ];
7497
- case 11:
7498
- this.timing.consecutiveFailures = 0;
7499
- this.startContinuousFetching(baseVastUrl);
7500
- if (!this.optimizedPodsEnabled && !this.preloadPool.active) {
7501
- this.preloadPool.startPreloadPool(baseVastUrl, []);
7502
- }
7503
- return [
7504
- 4,
7505
- adPlayer1.play()
7506
- ];
7507
- case 12:
7508
- _state.sent();
7509
- this.timing.markAdStarted();
7510
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7511
- this.timing.scheduleAdStopAtBreakBoundary();
7512
- }
7513
- adVolume1 = currentMuted ? 0 : currentVolume;
7514
- adPlayer1.setAdVolume(adVolume1);
7515
- _state.label = 13;
7516
- case 13:
7517
- return [
7518
- 3,
7519
- 22
7520
- ];
7521
- case 14:
7522
- error = _state.sent();
7523
- if (this.debug) {
7524
- console.warn("[CONTINUOUS-FETCH] First ad request failed:", error);
7525
- }
7526
- if (!!usePreloadedAd) return [
7527
- 3,
7528
- 20
7529
- ];
7530
- fallbackPreloaded = this.preloadPool.getPreloadedAd();
7531
- if (!fallbackPreloaded) return [
7532
- 3,
7533
- 20
7534
- ];
7535
- if (this.debug) {
7536
- console.log("[CONTINUOUS-FETCH] First ad failed, using preloaded fallback");
7537
- }
7538
- _state.label = 15;
7539
- case 15:
7540
- _state.trys.push([
7541
- 15,
7542
- 19,
7543
- ,
7544
- 20
7545
- ]);
7546
- if (!!this.timing.ensureLoadedAdFitsBudget(fallbackPreloaded.adController)) return [
7547
- 3,
7548
- 17
7549
- ];
7550
- this.timing.rejectLoadedAdForDuration(fallbackPreloaded.adController);
7551
- this.startContinuousFetching(baseVastUrl);
7552
- return [
7553
- 4,
7554
- this.tryNextAvailableAdWithRateLimit()
7555
- ];
7556
- case 16:
7557
- _state.sent();
7558
- return [
7559
- 2
7560
- ];
7561
- case 17:
7562
- this.swapToPreloadedAdPlayer(fallbackPreloaded.adController);
7563
- this.timing.consecutiveFailures = 0;
7564
- this.startContinuousFetching(baseVastUrl);
7565
- if (!this.optimizedPodsEnabled && !this.preloadPool.active) {
7566
- this.preloadPool.active = true;
7567
- this.preloadPool.preloadPoolLoop(baseVastUrl);
7568
- }
7569
- ap = this.host.getAdPlayer();
7570
- return [
7571
- 4,
7572
- ap.play()
7573
- ];
7574
- case 18:
7575
- _state.sent();
7576
- this.timing.markAdStarted();
7577
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7578
- this.timing.scheduleAdStopAtBreakBoundary();
7579
- }
7580
- adVolume2 = currentMuted ? 0 : currentVolume;
7581
- ap.setAdVolume(adVolume2);
7582
- return [
7583
- 2
7584
- ];
7585
- case 19:
7586
- fallbackError = _state.sent();
7587
- if (this.debug) {
7588
- console.warn("[CONTINUOUS-FETCH] Preloaded fallback also failed:", fallbackError);
7589
- }
7590
- return [
7591
- 3,
7592
- 20
7593
- ];
7594
- case 20:
7595
- if (this.timing.isTemporaryAdError(error)) {
7596
- this.timing.temporaryFailureUrls.set(firstAdUrl, Date.now());
7597
- if (this.debug) {
7598
- console.log("[CONTINUOUS-FETCH] First ad had temporary error (no-fill) - will try alternatives");
7599
- }
7600
- } else {
7601
- this.timing.failedVastUrls.add(firstAdUrl);
7602
- if (this.debug) {
7603
- console.log("[CONTINUOUS-FETCH] First ad had permanent error - URL blacklisted");
7604
- }
7605
- }
7606
- this.timing.consecutiveFailures++;
7607
- this.startContinuousFetching(baseVastUrl);
7608
- return [
7609
- 4,
7610
- this.tryNextAvailableAdWithRateLimit()
7611
- ];
7612
- case 21:
7613
- _state.sent();
7614
- return [
7615
- 3,
7616
- 22
7617
- ];
7618
- case 22:
7619
6853
  return [
7620
6854
  2
7621
6855
  ];
@@ -7689,7 +6923,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7689
6923
  ];
7690
6924
  }
7691
6925
  if (this.debug) {
7692
- 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"));
7693
6927
  }
7694
6928
  sendAdLoadedTracking(this.host.config.licenseKey, {
7695
6929
  source: "hls",
@@ -7709,10 +6943,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7709
6943
  }
7710
6944
  adPlayer.setAdVolume(currentMuted ? 0 : currentVolume);
7711
6945
  this.timing.consecutiveFailures = 0;
7712
- if (podCount === 1) {
7713
- this.continuousFetchingActive = true;
7714
- this.startContinuousFetching(baseVastUrl);
7715
- }
6946
+ this.continuousFetchingActive = true;
6947
+ this.startContinuousFetching(baseVastUrl);
7716
6948
  return [
7717
6949
  2,
7718
6950
  true
@@ -7745,20 +6977,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7745
6977
  }).call(this);
7746
6978
  }
7747
6979
  },
7748
- {
7749
- key: "swapToPreloadedAdPlayer",
7750
- value: function swapToPreloadedAdPlayer(preloadedController) {
7751
- var adPlayer = this.host.getAdPlayer();
7752
- var preservedMuted = adPlayer.getOriginalMutedState();
7753
- var preservedVolume = adPlayer.getOriginalVolume();
7754
- adPlayer.destroy();
7755
- this.host.video.muted = true;
7756
- this.host.setAdPlayer(preloadedController);
7757
- this.attachImaEventListeners();
7758
- preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
7759
- preloadedController.resume();
7760
- }
7761
- },
7762
6980
  {
7763
6981
  // ───────────────────────────────────────────────────────────────
7764
6982
  // Continuous fetching
@@ -8009,7 +7227,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8009
7227
  value: function tryNextAvailableAd() {
8010
7228
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
8011
7229
  return _async_to_generator(function() {
8012
- var remaining, preloaded, ap, error, nextAdUrl, error1, errorMessage, maxRetries;
7230
+ var remaining, nextAdUrl, error, errorMessage, maxRetries;
8013
7231
  return _ts_generator(this, function(_state) {
8014
7232
  switch(_state.label){
8015
7233
  case 0:
@@ -8047,132 +7265,71 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8047
7265
  ];
8048
7266
  }
8049
7267
  this.timing.cleanupTemporaryFailures();
8050
- preloaded = this.preloadPool.getPreloadedAd();
8051
- if (!preloaded) return [
8052
- 3,
8053
- 6
8054
- ];
8055
- if (this.debug) {
8056
- console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool");
8057
- }
8058
- sendAdLoadedTracking(this.host.config.licenseKey, {
8059
- source: "hls",
8060
- vastUrl: preloaded.vastUrl,
8061
- timestamp: /* @__PURE__ */ new Date().toISOString()
8062
- }, this.analyticsContext).catch(function() {});
8063
7268
  _state.label = 1;
8064
7269
  case 1:
8065
- _state.trys.push([
8066
- 1,
8067
- 5,
8068
- ,
8069
- 6
8070
- ]);
8071
- if (!!this.timing.ensureLoadedAdFitsBudget(preloaded.adController)) return [
8072
- 3,
8073
- 3
8074
- ];
8075
- this.timing.rejectLoadedAdForDuration(preloaded.adController);
8076
- return [
8077
- 4,
8078
- this.tryNextAvailableAdWithRateLimit()
8079
- ];
8080
- case 2:
8081
- _state.sent();
8082
- return [
8083
- 2
8084
- ];
8085
- case 3:
8086
- this.swapToPreloadedAdPlayer(preloaded.adController);
8087
- ap = this.host.getAdPlayer();
8088
- return [
8089
- 4,
8090
- ap.play()
8091
- ];
8092
- case 4:
8093
- _state.sent();
8094
- this.timing.markAdStarted();
8095
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
8096
- this.timing.scheduleAdStopAtBreakBoundary();
8097
- }
8098
- ap.setAdVolume(getAdAudioVolume(ap));
8099
- this.timing.consecutiveFailures = 0;
8100
- return [
8101
- 2
8102
- ];
8103
- case 5:
8104
- error = _state.sent();
8105
- if (this.debug) {
8106
- console.warn("[CONTINUOUS-FETCH] Preloaded ad failed to play:", error);
8107
- }
8108
- return [
8109
- 3,
8110
- 6
8111
- ];
8112
- case 6:
8113
7270
  if (!(this.adRequestQueue.length > 0)) return [
8114
7271
  3,
8115
- 14
7272
+ 9
8116
7273
  ];
8117
7274
  nextAdUrl = this.adRequestQueue.shift();
8118
7275
  if (!nextAdUrl) return [
8119
7276
  3,
8120
- 6
7277
+ 1
8121
7278
  ];
8122
7279
  if (this.timing.failedVastUrls.has(nextAdUrl)) {
8123
7280
  if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping permanently-failed URL, trying next...");
8124
7281
  return [
8125
7282
  3,
8126
- 6
7283
+ 1
8127
7284
  ];
8128
7285
  }
8129
7286
  if (this.timing.isUrlInCooldown(nextAdUrl)) {
8130
7287
  if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping URL in cooldown (recent no-fill), trying next...");
8131
7288
  return [
8132
7289
  3,
8133
- 6
7290
+ 1
8134
7291
  ];
8135
7292
  }
8136
7293
  if (this.debug) {
8137
7294
  console.log("[CONTINUOUS-FETCH] Requesting next ad via HLS ad player (".concat(this.timing.currentAdIndex + 1, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
8138
7295
  }
8139
- _state.label = 7;
8140
- case 7:
7296
+ _state.label = 2;
7297
+ case 2:
8141
7298
  _state.trys.push([
8142
- 7,
8143
- 9,
7299
+ 2,
7300
+ 4,
8144
7301
  ,
8145
- 13
7302
+ 8
8146
7303
  ]);
8147
7304
  return [
8148
7305
  4,
8149
7306
  this.playSingleAd(nextAdUrl)
8150
7307
  ];
8151
- case 8:
7308
+ case 3:
8152
7309
  _state.sent();
8153
7310
  this.timing.consecutiveFailures = 0;
8154
7311
  return [
8155
7312
  3,
8156
- 13
7313
+ 8
8157
7314
  ];
8158
- case 9:
8159
- error1 = _state.sent();
8160
- errorMessage = error1.message;
7315
+ case 4:
7316
+ error = _state.sent();
7317
+ errorMessage = error.message;
8161
7318
  if (this.debug) console.log("[CONTINUOUS-FETCH] Ad request failed:", errorMessage);
8162
7319
  if (!errorMessage.includes("ad_duration_exceeds_budget")) return [
8163
7320
  3,
8164
- 11
7321
+ 6
8165
7322
  ];
8166
7323
  return [
8167
7324
  4,
8168
7325
  this.tryNextAvailableAdWithRateLimit()
8169
7326
  ];
8170
- case 10:
7327
+ case 5:
8171
7328
  _state.sent();
8172
7329
  return [
8173
7330
  2
8174
7331
  ];
8175
- case 11:
7332
+ case 6:
8176
7333
  if (!errorMessage.includes("permanently failed") && !errorMessage.includes("in cooldown")) {
8177
7334
  this.timing.consecutiveFailures++;
8178
7335
  }
@@ -8180,21 +7337,21 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8180
7337
  4,
8181
7338
  this.tryNextAvailableAdWithRateLimit()
8182
7339
  ];
8183
- case 12:
7340
+ case 7:
8184
7341
  _state.sent();
8185
7342
  return [
8186
7343
  3,
8187
- 13
7344
+ 8
8188
7345
  ];
8189
- case 13:
7346
+ case 8:
8190
7347
  return [
8191
7348
  2
8192
7349
  ];
8193
- case 14:
7350
+ case 9:
8194
7351
  maxRetries = 3;
8195
7352
  if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
8196
7353
  3,
8197
- 17
7354
+ 12
8198
7355
  ];
8199
7356
  if (this.debug) {
8200
7357
  console.log("[CONTINUOUS-FETCH] Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
@@ -8205,18 +7362,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8205
7362
  return setTimeout(resolve, 500);
8206
7363
  })
8207
7364
  ];
8208
- case 15:
7365
+ case 10:
8209
7366
  _state.sent();
8210
7367
  return [
8211
7368
  4,
8212
7369
  this.tryNextAvailableAd(retryCount + 1)
8213
7370
  ];
8214
- case 16:
7371
+ case 11:
8215
7372
  _state.sent();
8216
7373
  return [
8217
7374
  2
8218
7375
  ];
8219
- case 17:
7376
+ case 12:
8220
7377
  if (!this.isShowingPlaceholder && remaining > 1e3) {
8221
7378
  this.showPlaceholderAndWaitForAds();
8222
7379
  } else {
@@ -8238,7 +7395,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8238
7395
  // ───────────────────────────────────────────────────────────────
8239
7396
  function playSingleAd(vastTagUrl) {
8240
7397
  return _async_to_generator(function() {
8241
- var adPlayer, requestToken, ap, playError, preloadedFallback, fbAp, fallbackError, error, errorMessage, preloadedFallback1, fbAp1, fallbackError1;
7398
+ var adPlayer, requestToken, ap, playError, error, errorMessage;
8242
7399
  return _ts_generator(this, function(_state) {
8243
7400
  switch(_state.label){
8244
7401
  case 0:
@@ -8270,9 +7427,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8270
7427
  case 1:
8271
7428
  _state.trys.push([
8272
7429
  1,
8273
- 12,
7430
+ 8,
8274
7431
  ,
8275
- 17
7432
+ 9
8276
7433
  ]);
8277
7434
  return [
8278
7435
  4,
@@ -8308,7 +7465,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8308
7465
  4,
8309
7466
  6,
8310
7467
  ,
8311
- 11
7468
+ 7
8312
7469
  ]);
8313
7470
  this.timing.startAdFailsafeTimer(requestToken);
8314
7471
  return [
@@ -8326,55 +7483,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8326
7483
  this.timing.temporaryFailureUrls.delete(vastTagUrl);
8327
7484
  return [
8328
7485
  3,
8329
- 11
7486
+ 7
8330
7487
  ];
8331
7488
  case 6:
8332
7489
  playError = _state.sent();
8333
7490
  if (this.debug) console.error("[AD-ERROR] Failed to play ad:", playError);
8334
- preloadedFallback = this.preloadPool.getPreloadedAd();
8335
- if (!preloadedFallback) return [
8336
- 3,
8337
- 10
8338
- ];
8339
- if (this.debug) console.log("[AD-ERROR] Play failed, trying preloaded fallback ad");
8340
- _state.label = 7;
8341
- case 7:
8342
- _state.trys.push([
8343
- 7,
8344
- 9,
8345
- ,
8346
- 10
8347
- ]);
8348
- if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback.adController)) {
8349
- this.timing.rejectLoadedAdForDuration(preloadedFallback.adController);
8350
- throw playError;
8351
- }
8352
- this.timing.clearAdFailsafeTimer();
8353
- this.swapToPreloadedAdPlayer(preloadedFallback.adController);
8354
- this.timing.consecutiveFailures = 0;
8355
- fbAp = this.host.getAdPlayer();
8356
- return [
8357
- 4,
8358
- fbAp.play()
8359
- ];
8360
- case 8:
8361
- _state.sent();
8362
- this.timing.markAdStarted();
8363
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
8364
- this.timing.scheduleAdStopAtBreakBoundary();
8365
- }
8366
- fbAp.setAdVolume(getAdAudioVolume(fbAp));
8367
- return [
8368
- 2
8369
- ];
8370
- case 9:
8371
- fallbackError = _state.sent();
8372
- if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError);
8373
- return [
8374
- 3,
8375
- 10
8376
- ];
8377
- case 10:
8378
7491
  if (this.timing.isTemporaryAdError(playError)) {
8379
7492
  this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
8380
7493
  if (this.debug) console.log("[AD-ERROR] Temporary play error - URL can be retried after cooldown");
@@ -8387,57 +7500,15 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8387
7500
  this.timing.activeAdRequestToken = null;
8388
7501
  }
8389
7502
  throw playError;
8390
- case 11:
7503
+ case 7:
8391
7504
  return [
8392
7505
  3,
8393
- 17
7506
+ 9
8394
7507
  ];
8395
- case 12:
7508
+ case 8:
8396
7509
  error = _state.sent();
8397
7510
  errorMessage = (error === null || error === void 0 ? void 0 : error.message) || "";
8398
7511
  if (this.debug) console.error("[AD-ERROR] Ad request failed:", errorMessage);
8399
- preloadedFallback1 = this.preloadPool.getPreloadedAd();
8400
- if (!preloadedFallback1) return [
8401
- 3,
8402
- 16
8403
- ];
8404
- if (this.debug) console.log("[AD-ERROR] Request failed, trying preloaded fallback ad");
8405
- _state.label = 13;
8406
- case 13:
8407
- _state.trys.push([
8408
- 13,
8409
- 15,
8410
- ,
8411
- 16
8412
- ]);
8413
- if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback1.adController)) {
8414
- this.timing.rejectLoadedAdForDuration(preloadedFallback1.adController);
8415
- throw error;
8416
- }
8417
- this.timing.clearAdRequestWatchdog();
8418
- this.timing.clearAdFailsafeTimer();
8419
- this.swapToPreloadedAdPlayer(preloadedFallback1.adController);
8420
- this.timing.consecutiveFailures = 0;
8421
- fbAp1 = this.host.getAdPlayer();
8422
- return [
8423
- 4,
8424
- fbAp1.play()
8425
- ];
8426
- case 14:
8427
- _state.sent();
8428
- this.timing.markAdStarted();
8429
- fbAp1.setAdVolume(getAdAudioVolume(fbAp1));
8430
- return [
8431
- 2
8432
- ];
8433
- case 15:
8434
- fallbackError1 = _state.sent();
8435
- if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError1);
8436
- return [
8437
- 3,
8438
- 16
8439
- ];
8440
- case 16:
8441
7512
  if (this.timing.isTemporaryAdError(error)) {
8442
7513
  this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
8443
7514
  if (this.debug) console.log("[AD-ERROR] Temporary error (no-fill/timeout) - URL can be retried after cooldown");
@@ -8451,7 +7522,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8451
7522
  this.timing.activeAdRequestToken = null;
8452
7523
  }
8453
7524
  throw error;
8454
- case 17:
7525
+ case 9:
8455
7526
  return [
8456
7527
  2
8457
7528
  ];
@@ -8641,7 +7712,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8641
7712
  }
8642
7713
  this.timing.resetForBreakEnd();
8643
7714
  this.stopContinuousFetching();
8644
- this.preloadPool.stop();
8645
7715
  this.clearPendingAdBreak();
8646
7716
  if (this.isShowingPlaceholder) {
8647
7717
  this.host.getAdPlayer().hidePlaceholder();
@@ -8751,25 +7821,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8751
7821
  return _this.adBreak.handleAdFailure();
8752
7822
  }
8753
7823
  });
8754
- this.preloadPool = new AdPreloadPool({
8755
- debug: !!this.config.debugAdTiming,
8756
- createAdPlayer: function createAdPlayer(c) {
8757
- return _this.createAdPlayer(c);
8758
- },
8759
- shouldContinueLiveStreamDuringAds: function shouldContinueLiveStreamDuringAds() {
8760
- return _this.shouldContinueLiveStreamDuringAds();
8761
- },
8762
- timing: this.timing,
8763
- generateVastUrlsWithCorrelators: function generateVastUrlsWithCorrelators(base, count) {
8764
- return _this.generateVastUrls(base, count);
8765
- },
8766
- isInAdBreak: function isInAdBreak() {
8767
- return _this.adBreak.inAdBreak;
8768
- },
8769
- getPendingAdBreak: function getPendingAdBreak() {
8770
- return _this.adBreak.pendingAdBreak;
8771
- }
8772
- });
8773
7824
  this.placeholder = new PlaceholderLayer(this.video, !!this.config.debugAdTiming);
8774
7825
  this.hlsEngine = new HlsEngine(this.config, this.video, this.cueManager, this.timing, {
8775
7826
  onManifestParsed: function onManifestParsed(isLive) {
@@ -8816,13 +7867,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8816
7867
  getLiveSyncPosition: function getLiveSyncPosition() {
8817
7868
  return _this.hlsEngine.getLiveSyncPosition();
8818
7869
  },
8819
- generateVastUrls: function generateVastUrls(base, count) {
8820
- return _this.generateVastUrls(base, count);
8821
- },
8822
7870
  generatePodVastUrl: function generatePodVastUrl(base, breakDurationMs) {
8823
7871
  return _this.generatePodVastUrl(base, breakDurationMs);
8824
7872
  }
8825
- }, this.timing, this.preloadPool, this.adConfig, this.cueManager, this.placeholder);
7873
+ }, this.timing, this.adConfig, this.cueManager, this.placeholder);
8826
7874
  }
8827
7875
  _create_class(StormcloudVideoPlayer, [
8828
7876
  {
@@ -8847,12 +7895,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8847
7895
  } : {}));
8848
7896
  }
8849
7897
  },
8850
- {
8851
- key: "generateVastUrls",
8852
- value: function generateVastUrls(baseUrl, count) {
8853
- return this.adConfig.generateVastUrlsWithCorrelators(baseUrl, count, this.adPlayer, this.palNonce, this.adBreak.inAdBreak);
8854
- }
8855
- },
8856
7898
  {
8857
7899
  key: "generatePodVastUrl",
8858
7900
  value: function generatePodVastUrl(baseUrl, breakDurationMs) {
@@ -9248,11 +8290,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9248
8290
  }
9249
8291
  this.adConfig.beginNewAdPod();
9250
8292
  this.adConfig.podAssignedByPrefetch = true;
9251
- var optimizedPods = this.config.optimizedPods !== false;
9252
8293
  var breakDurationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : void 0;
9253
- var generatedUrls = optimizedPods ? [
8294
+ var generatedUrls = [
9254
8295
  this.generatePodVastUrl(baseVastUrl, breakDurationMs)
9255
- ] : this.generateVastUrls(baseVastUrl, 1);
8296
+ ];
9256
8297
  this.adBreak.pendingAdBreak = _object_spread_props(_object_spread({
9257
8298
  marker: marker
9258
8299
  }, fragmentSn !== void 0 ? {
@@ -9274,15 +8315,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9274
8315
  }, detectPayload), buildAnalyticsContext(this.config)).catch(function() {});
9275
8316
  if (this.debug) {
9276
8317
  console.log("[PREFETCH] Starting ad prefetch for upcoming ad break");
9277
- console.log("[PREFETCH] Pre-generated ".concat(generatedUrls.length, " ").concat(optimizedPods ? "pod" : "VAST", " URL(s)"));
9278
- }
9279
- if (optimizedPods) {
9280
- if (this.debug) {
9281
- console.log("[PREFETCH] Optimized pods enabled - skipping single-ad preload pool");
9282
- }
9283
- return;
8318
+ console.log("[PREFETCH] Pre-generated pod request URL");
9284
8319
  }
9285
- this.preloadPool.startPreloadPool(baseVastUrl, generatedUrls.slice(0, 1), false);
9286
8320
  }
9287
8321
  },
9288
8322
  {
@@ -9521,7 +8555,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9521
8555
  value: function destroy() {
9522
8556
  var _this_adPlayer;
9523
8557
  this.adBreak.stopContinuousFetching();
9524
- this.preloadPool.stop();
9525
8558
  this.timing.destroy();
9526
8559
  this.adBreak.clearPendingAdBreak();
9527
8560
  this.placeholder.destroy();