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
@@ -3453,21 +3453,16 @@ function applyVastMacros(baseUrl, ctx) {
3453
3453
  if (ctx.pod != null) {
3454
3454
  params.set("pod", String(ctx.pod));
3455
3455
  }
3456
- var optimizedPodMode = ctx.podMaxAds != null || ctx.podMinDurationMs != null || ctx.podMaxDurationMs != null;
3457
- if (optimizedPodMode) {
3458
- params.delete("ppos");
3459
- params.delete("lip");
3460
- if (ctx.podMinDurationMs != null) {
3461
- params.set("pmnd", String(Math.max(0, Math.round(ctx.podMinDurationMs))));
3462
- }
3463
- if (ctx.podMaxDurationMs != null) {
3464
- params.set("pmxd", String(Math.max(0, Math.round(ctx.podMaxDurationMs))));
3465
- }
3466
- if (ctx.podMaxAds != null) {
3467
- params.set("pmad", String(Math.max(1, Math.round(ctx.podMaxAds))));
3468
- }
3469
- } else if (ctx.adPosition != null) {
3470
- params.set("ppos", String(ctx.adPosition));
3456
+ params.delete("ppos");
3457
+ params.delete("lip");
3458
+ if (ctx.podMinDurationMs != null) {
3459
+ params.set("pmnd", String(Math.max(0, Math.round(ctx.podMinDurationMs))));
3460
+ }
3461
+ if (ctx.podMaxDurationMs != null) {
3462
+ params.set("pmxd", String(Math.max(0, Math.round(ctx.podMaxDurationMs))));
3463
+ }
3464
+ if (ctx.podMaxAds != null) {
3465
+ params.set("pmad", String(Math.max(1, Math.round(ctx.podMaxAds))));
3471
3466
  }
3472
3467
  var requestUrl = ctx.contentUrl || ctx.pageUrl;
3473
3468
  if (requestUrl) {
@@ -4807,9 +4802,9 @@ var AdConfigManager = /*#__PURE__*/ function() {
4807
4802
  this.consentSignals = {};
4808
4803
  this.podCounter = 0;
4809
4804
  this.podAssignedByPrefetch = false;
4810
- this.adRequestPositionInBreak = 0;
4811
4805
  this.lastHeartbeatTime = 0;
4812
4806
  this.defaultPodMaxAds = 6;
4807
+ this.defaultPodMaxDurationMs = 12e4;
4813
4808
  this.config = config;
4814
4809
  this.video = video;
4815
4810
  }
@@ -5227,48 +5222,12 @@ var AdConfigManager = /*#__PURE__*/ function() {
5227
5222
  key: "beginNewAdPod",
5228
5223
  value: function beginNewAdPod() {
5229
5224
  this.podCounter++;
5230
- this.adRequestPositionInBreak = 0;
5231
- }
5232
- },
5233
- {
5234
- key: "generateVastUrlsWithCorrelators",
5235
- value: function generateVastUrlsWithCorrelators(baseUrl, count, adPlayer, palNonce, inAdBreak) {
5236
- var urls = [];
5237
- for(var i = 0; i < count; i++){
5238
- this.adRequestPositionInBreak++;
5239
- var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
5240
- var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest);
5241
- var urlWithMacros = applyVastMacros(baseUrl, {
5242
- correlator: this.viewCorrelator,
5243
- streamCorrelator: this.streamCorrelator,
5244
- pod: this.podCounter > 0 ? this.podCounter : void 0,
5245
- adPosition: this.adRequestPositionInBreak,
5246
- isCtv: envSignals.isCtv,
5247
- contentUrl: envSignals.contentUrl,
5248
- pageUrl: !envSignals.isCtv && typeof window !== "undefined" ? window.location.href : void 0,
5249
- adWillPlayMuted: adWillPlayMuted,
5250
- adWillAutoPlay: !!this.config.autoplay,
5251
- appId: envSignals.appId,
5252
- appName: envSignals.appName,
5253
- sessionId: envSignals.sessionId,
5254
- deviceId: envSignals.deviceId,
5255
- deviceIdType: envSignals.deviceIdType,
5256
- limitAdTracking: envSignals.limitAdTracking,
5257
- deviceTypeHint: envSignals.deviceTypeHint,
5258
- adTest: this.config.adTest,
5259
- consent: this.consentSignals
5260
- });
5261
- var finalUrl = palNonce.injectNonce(urlWithMacros);
5262
- console.log("[StormcloudVideoPlayer] Resolved ad request URL (pod=".concat(this.podCounter, ", pos=").concat(this.adRequestPositionInBreak, "):"), finalUrl);
5263
- urls.push(finalUrl);
5264
- }
5265
- return urls;
5266
5225
  }
5267
5226
  },
5268
5227
  {
5269
5228
  key: "resolvePodParams",
5270
5229
  value: function resolvePodParams(breakDurationMs) {
5271
- var maxDurationMs = breakDurationMs != null && breakDurationMs > 0 ? breakDurationMs : this.config.podMaxDurationMs;
5230
+ var maxDurationMs = breakDurationMs != null && breakDurationMs > 0 ? breakDurationMs : this.config.podMaxDurationMs != null && this.config.podMaxDurationMs > 0 ? this.config.podMaxDurationMs : this.defaultPodMaxDurationMs;
5272
5231
  var maxAds = this.config.podMaxAds && this.config.podMaxAds > 0 ? this.config.podMaxAds : this.apiNumberAds && this.apiNumberAds > 0 ? this.apiNumberAds : this.defaultPodMaxAds;
5273
5232
  var minDurationMs = this.config.podExactDuration && maxDurationMs != null ? maxDurationMs : 0;
5274
5233
  return {
@@ -5921,462 +5880,6 @@ var AdTimingService = /*#__PURE__*/ function() {
5921
5880
  ]);
5922
5881
  return AdTimingService;
5923
5882
  }();
5924
- // src/player/AdPreloadPool.ts
5925
- var AdPreloadPool = /*#__PURE__*/ function() {
5926
- function AdPreloadPool(deps) {
5927
- _class_call_check(this, AdPreloadPool);
5928
- this.pool = [];
5929
- this.maxPoolSize = 2;
5930
- this.poolActive = false;
5931
- this.loopRunning = false;
5932
- this.deps = deps;
5933
- }
5934
- _create_class(AdPreloadPool, [
5935
- {
5936
- key: "active",
5937
- get: function get() {
5938
- return this.poolActive;
5939
- },
5940
- set: function set(value) {
5941
- this.poolActive = value;
5942
- }
5943
- },
5944
- {
5945
- key: "isLoopRunning",
5946
- get: function get() {
5947
- return this.loopRunning;
5948
- }
5949
- },
5950
- {
5951
- key: "startPreloadPool",
5952
- value: function startPreloadPool(baseVastUrl, initialUrls) {
5953
- var startLoopImmediately = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
5954
- if (this.poolActive) {
5955
- if (this.deps.debug) {
5956
- console.log("[PRELOAD-POOL] Already active, skipping duplicate start");
5957
- }
5958
- return;
5959
- }
5960
- this.poolActive = true;
5961
- if (this.deps.debug) {
5962
- console.log("[PRELOAD-POOL] Starting preload pool EARLY (target size: ".concat(this.maxPoolSize, ")"));
5963
- console.log("[PRELOAD-POOL] Ad break hasn't started yet, but preloading ads in advance");
5964
- }
5965
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
5966
- try {
5967
- for(var _iterator = initialUrls[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
5968
- var url = _step.value;
5969
- if (this.pool.length < this.maxPoolSize) {
5970
- this.preloadAdIntoPool(url);
5971
- }
5972
- }
5973
- } catch (err) {
5974
- _didIteratorError = true;
5975
- _iteratorError = err;
5976
- } finally{
5977
- try {
5978
- if (!_iteratorNormalCompletion && _iterator.return != null) {
5979
- _iterator.return();
5980
- }
5981
- } finally{
5982
- if (_didIteratorError) {
5983
- throw _iteratorError;
5984
- }
5985
- }
5986
- }
5987
- if (startLoopImmediately) {
5988
- this.preloadPoolLoop(baseVastUrl);
5989
- } else if (this.deps.debug) {
5990
- console.log("[PRELOAD-POOL] Pre-break mode: preloaded once, waiting for SCTE start to continue fetching");
5991
- }
5992
- }
5993
- },
5994
- {
5995
- key: "preloadAdIntoPool",
5996
- value: function preloadAdIntoPool(vastUrl) {
5997
- return _async_to_generator(function() {
5998
- var _this, timing, epoch, loadPromise;
5999
- return _ts_generator(this, function(_state) {
6000
- _this = this;
6001
- timing = this.deps.timing;
6002
- if (timing.isGamInCooldown()) {
6003
- if (this.deps.debug) {
6004
- console.log("[CIRCUIT-BREAKER] GAM in cooldown, skipping preload");
6005
- }
6006
- return [
6007
- 2
6008
- ];
6009
- }
6010
- if (this.pool.some(function(entry) {
6011
- return entry.vastUrl === vastUrl;
6012
- }) || timing.failedVastUrls.has(vastUrl) || timing.isUrlInCooldown(vastUrl)) {
6013
- return [
6014
- 2
6015
- ];
6016
- }
6017
- if (this.pool.length >= this.maxPoolSize) {
6018
- return [
6019
- 2
6020
- ];
6021
- }
6022
- if (this.deps.debug) {
6023
- console.log("[PRELOAD-POOL] Preloading ad into pool: ".concat(vastUrl));
6024
- }
6025
- epoch = timing.adBreakEpoch;
6026
- loadPromise = function() {
6027
- return _async_to_generator(function() {
6028
- var _this, hasAdError, adErrorPayload, errorListenerCleanup, _preloadAd_getLoadedAdDuration, continueLiveStreamDuringAds, preloadAd, errorListener, isNoFill, poolEntry, loadedDuration, lateErrorListener, _poolEntry_durationSeconds, error;
6029
- return _ts_generator(this, function(_state) {
6030
- switch(_state.label){
6031
- case 0:
6032
- _this = this;
6033
- hasAdError = false;
6034
- adErrorPayload = null;
6035
- errorListenerCleanup = null;
6036
- _state.label = 1;
6037
- case 1:
6038
- _state.trys.push([
6039
- 1,
6040
- 5,
6041
- ,
6042
- 6
6043
- ]);
6044
- continueLiveStreamDuringAds = this.deps.shouldContinueLiveStreamDuringAds();
6045
- preloadAd = this.deps.createAdPlayer(continueLiveStreamDuringAds);
6046
- preloadAd.initialize();
6047
- errorListener = function errorListener(payload) {
6048
- hasAdError = true;
6049
- adErrorPayload = payload;
6050
- };
6051
- preloadAd.on("ad_error", errorListener);
6052
- errorListenerCleanup = function errorListenerCleanup() {
6053
- return preloadAd.off("ad_error", errorListener);
6054
- };
6055
- return [
6056
- 4,
6057
- timing.enforceGlobalRateLimit()
6058
- ];
6059
- case 2:
6060
- _state.sent();
6061
- return [
6062
- 4,
6063
- preloadAd.requestAds(vastUrl)
6064
- ];
6065
- case 3:
6066
- _state.sent();
6067
- preloadAd.pause();
6068
- return [
6069
- 4,
6070
- new Promise(function(resolve) {
6071
- return setTimeout(resolve, 1500);
6072
- })
6073
- ];
6074
- case 4:
6075
- _state.sent();
6076
- preloadAd.pause();
6077
- if (hasAdError) {
6078
- 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;
6079
- if (errorListenerCleanup) {
6080
- errorListenerCleanup();
6081
- }
6082
- preloadAd.destroy();
6083
- timing.recordGamNoFill();
6084
- if (isNoFill) {
6085
- if (this.deps.debug) {
6086
- console.log("[PRELOAD-POOL] Ad preload returned no-fill: ".concat(vastUrl));
6087
- }
6088
- timing.temporaryFailureUrls.set(vastUrl, Date.now());
6089
- } else {
6090
- if (this.deps.debug) {
6091
- console.log("[PRELOAD-POOL] Ad preload failed with error: ".concat(vastUrl), adErrorPayload);
6092
- }
6093
- if (adErrorPayload && !timing.isTemporaryAdError(adErrorPayload)) {
6094
- timing.failedVastUrls.add(vastUrl);
6095
- } else {
6096
- timing.temporaryFailureUrls.set(vastUrl, Date.now());
6097
- }
6098
- }
6099
- return [
6100
- 2
6101
- ];
6102
- }
6103
- if (!this.poolActive || epoch !== timing.adBreakEpoch) {
6104
- if (this.deps.debug) {
6105
- console.log("[PRELOAD-POOL] Discarding preloaded ad - break ended during fetch");
6106
- }
6107
- if (errorListenerCleanup) {
6108
- errorListenerCleanup();
6109
- }
6110
- try {
6111
- preloadAd.destroy();
6112
- } catch (unused) {}
6113
- return [
6114
- 2
6115
- ];
6116
- }
6117
- poolEntry = {
6118
- vastUrl: vastUrl,
6119
- adController: preloadAd,
6120
- loadedAt: Date.now(),
6121
- isReady: true,
6122
- loadPromise: Promise.resolve()
6123
- };
6124
- loadedDuration = (_preloadAd_getLoadedAdDuration = preloadAd.getLoadedAdDuration) === null || _preloadAd_getLoadedAdDuration === void 0 ? void 0 : _preloadAd_getLoadedAdDuration.call(preloadAd);
6125
- if (loadedDuration != null && loadedDuration > 0) {
6126
- poolEntry.durationSeconds = loadedDuration;
6127
- }
6128
- lateErrorListener = function lateErrorListener(payload) {
6129
- var index = _this.pool.findIndex(function(entry) {
6130
- return entry.vastUrl === vastUrl;
6131
- });
6132
- if (index >= 0) {
6133
- _this.pool.splice(index, 1);
6134
- if (_this.deps.debug) {
6135
- console.log("[PRELOAD-POOL] Late error detected, removed from pool: ".concat(vastUrl), payload);
6136
- }
6137
- try {
6138
- preloadAd.destroy();
6139
- } catch (unused) {}
6140
- }
6141
- };
6142
- preloadAd.on("ad_error", lateErrorListener);
6143
- this.pool.push(poolEntry);
6144
- if (this.deps.debug) {
6145
- ;
6146
- 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)"));
6147
- }
6148
- if (errorListenerCleanup) {
6149
- errorListenerCleanup();
6150
- }
6151
- return [
6152
- 3,
6153
- 6
6154
- ];
6155
- case 5:
6156
- error = _state.sent();
6157
- if (errorListenerCleanup) {
6158
- errorListenerCleanup();
6159
- }
6160
- timing.recordGamNoFill();
6161
- if (this.deps.debug) {
6162
- console.warn("[PRELOAD-POOL] Failed to preload ad: ".concat(vastUrl), error);
6163
- }
6164
- if (_instanceof(error, Error) && !timing.isTemporaryAdError(error)) {
6165
- timing.failedVastUrls.add(vastUrl);
6166
- } else if (_instanceof(error, Error) && timing.isTemporaryAdError(error)) {
6167
- timing.temporaryFailureUrls.set(vastUrl, Date.now());
6168
- }
6169
- return [
6170
- 3,
6171
- 6
6172
- ];
6173
- case 6:
6174
- return [
6175
- 2
6176
- ];
6177
- }
6178
- });
6179
- }).call(_this);
6180
- }();
6181
- loadPromise.catch(function() {});
6182
- return [
6183
- 2
6184
- ];
6185
- });
6186
- }).call(this);
6187
- }
6188
- },
6189
- {
6190
- key: "preloadPoolLoop",
6191
- value: function preloadPoolLoop(baseVastUrl) {
6192
- return _async_to_generator(function() {
6193
- var epoch, newUrls, newUrl;
6194
- return _ts_generator(this, function(_state) {
6195
- switch(_state.label){
6196
- case 0:
6197
- if (this.loopRunning) {
6198
- return [
6199
- 2
6200
- ];
6201
- }
6202
- this.loopRunning = true;
6203
- epoch = this.deps.timing.adBreakEpoch;
6204
- if (this.deps.debug) {
6205
- console.log("[PRELOAD-POOL] Starting continuous preload loop");
6206
- }
6207
- _state.label = 1;
6208
- case 1:
6209
- if (!(this.poolActive && epoch === this.deps.timing.adBreakEpoch)) return [
6210
- 3,
6211
- 10
6212
- ];
6213
- if (this.deps.timing.isGamInCooldown()) {
6214
- if (this.deps.debug) {
6215
- console.log("[CIRCUIT-BREAKER] GAM in cooldown, stopping preload pool loop");
6216
- }
6217
- return [
6218
- 3,
6219
- 10
6220
- ];
6221
- }
6222
- if (!(!this.deps.isInAdBreak() && this.pool.length >= this.maxPoolSize)) return [
6223
- 3,
6224
- 3
6225
- ];
6226
- return [
6227
- 4,
6228
- new Promise(function(resolve) {
6229
- return setTimeout(resolve, 2e3);
6230
- })
6231
- ];
6232
- case 2:
6233
- _state.sent();
6234
- return [
6235
- 3,
6236
- 1
6237
- ];
6238
- case 3:
6239
- if (!this.deps.isInAdBreak() && this.deps.getPendingAdBreak() === null) {
6240
- if (this.deps.debug) {
6241
- console.log("[PRELOAD-POOL] Ad break cancelled, stopping preload pool");
6242
- }
6243
- return [
6244
- 3,
6245
- 10
6246
- ];
6247
- }
6248
- _state.label = 4;
6249
- case 4:
6250
- if (!(this.pool.length < this.maxPoolSize)) return [
6251
- 3,
6252
- 8
6253
- ];
6254
- if (!this.poolActive || epoch !== this.deps.timing.adBreakEpoch || this.deps.timing.isGamInCooldown()) {
6255
- return [
6256
- 3,
6257
- 8
6258
- ];
6259
- }
6260
- if (this.deps.isInAdBreak() && !this.deps.timing.hasTimeToStartAnotherAd()) {
6261
- if (this.deps.debug) {
6262
- console.log("[PRELOAD-POOL] Not enough ad break time left, stopping preload");
6263
- }
6264
- return [
6265
- 3,
6266
- 8
6267
- ];
6268
- }
6269
- newUrls = this.deps.generateVastUrlsWithCorrelators(baseVastUrl, 1);
6270
- newUrl = newUrls[0];
6271
- if (!(newUrl && !this.deps.timing.failedVastUrls.has(newUrl) && !this.deps.timing.isUrlInCooldown(newUrl))) return [
6272
- 3,
6273
- 6
6274
- ];
6275
- return [
6276
- 4,
6277
- this.preloadAdIntoPool(newUrl)
6278
- ];
6279
- case 5:
6280
- _state.sent();
6281
- _state.label = 6;
6282
- case 6:
6283
- return [
6284
- 4,
6285
- new Promise(function(resolve) {
6286
- return setTimeout(resolve, 1e3);
6287
- })
6288
- ];
6289
- case 7:
6290
- _state.sent();
6291
- return [
6292
- 3,
6293
- 4
6294
- ];
6295
- case 8:
6296
- return [
6297
- 4,
6298
- new Promise(function(resolve) {
6299
- return setTimeout(resolve, 2e3);
6300
- })
6301
- ];
6302
- case 9:
6303
- _state.sent();
6304
- return [
6305
- 3,
6306
- 1
6307
- ];
6308
- case 10:
6309
- this.loopRunning = false;
6310
- if (this.deps.debug) {
6311
- console.log("[PRELOAD-POOL] Preload loop ended");
6312
- }
6313
- return [
6314
- 2
6315
- ];
6316
- }
6317
- });
6318
- }).call(this);
6319
- }
6320
- },
6321
- {
6322
- key: "getPreloadedAd",
6323
- value: function getPreloadedAd() {
6324
- if (this.pool.length === 0) {
6325
- return null;
6326
- }
6327
- var entry = this.pool.shift();
6328
- if (!entry || !entry.isReady) {
6329
- return null;
6330
- }
6331
- if (this.deps.debug) {
6332
- console.log("[PRELOAD-POOL] Using preloaded ad from pool (".concat(this.pool.length, " remaining)"));
6333
- }
6334
- return {
6335
- vastUrl: entry.vastUrl,
6336
- adController: entry.adController
6337
- };
6338
- }
6339
- },
6340
- {
6341
- key: "stop",
6342
- value: function stop() {
6343
- this.poolActive = false;
6344
- this.loopRunning = false;
6345
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6346
- try {
6347
- for(var _iterator = this.pool[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6348
- var entry = _step.value;
6349
- try {
6350
- entry.adController.destroy();
6351
- } catch (error) {
6352
- if (this.deps.debug) {
6353
- console.warn("[PRELOAD-POOL] Error destroying preloaded controller:", error);
6354
- }
6355
- }
6356
- }
6357
- } catch (err) {
6358
- _didIteratorError = true;
6359
- _iteratorError = err;
6360
- } finally{
6361
- try {
6362
- if (!_iteratorNormalCompletion && _iterator.return != null) {
6363
- _iterator.return();
6364
- }
6365
- } finally{
6366
- if (_didIteratorError) {
6367
- throw _iteratorError;
6368
- }
6369
- }
6370
- }
6371
- this.pool = [];
6372
- if (this.deps.debug) {
6373
- console.log("[PRELOAD-POOL] Preload pool stopped and cleaned up");
6374
- }
6375
- }
6376
- }
6377
- ]);
6378
- return AdPreloadPool;
6379
- }();
6380
5883
  // src/player/PlaceholderLayer.ts
6381
5884
  var PlaceholderLayer = /*#__PURE__*/ function() {
6382
5885
  function PlaceholderLayer(video, debug) {
@@ -7098,7 +6601,7 @@ function resizePlayer(video, adPlayer, debug) {
7098
6601
  }
7099
6602
  // src/player/AdBreakOrchestrator.ts
7100
6603
  var AdBreakOrchestrator = /*#__PURE__*/ function() {
7101
- function AdBreakOrchestrator(host, timing, preloadPool, adConfig, cueManager, placeholder) {
6604
+ function AdBreakOrchestrator(host, timing, adConfig, cueManager, placeholder) {
7102
6605
  _class_call_check(this, AdBreakOrchestrator);
7103
6606
  this.inAdBreak = false;
7104
6607
  this.showAds = false;
@@ -7112,7 +6615,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7112
6615
  this.pendingAdBreak = null;
7113
6616
  this.host = host;
7114
6617
  this.timing = timing;
7115
- this.preloadPool = preloadPool;
7116
6618
  this.adConfig = adConfig;
7117
6619
  this.cueManager = cueManager;
7118
6620
  this.placeholder = placeholder;
@@ -7131,23 +6633,19 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7131
6633
  }
7132
6634
  },
7133
6635
  {
7134
- key: "optimizedPodsEnabled",
7135
- get: // ───────────────────────────────────────────────────────────────
6636
+ // ───────────────────────────────────────────────────────────────
7136
6637
  // IMA event listeners
7137
6638
  // ───────────────────────────────────────────────────────────────
7138
- function get() {
7139
- return this.host.config.optimizedPods !== false;
7140
- }
7141
- },
7142
- {
7143
- key: "nextAdRequestUrl",
6639
+ /**
6640
+ * Produces the next pod ad-request URL for the current break. Every request
6641
+ * (initial and continuous-fetch top-up) carries pod macros (pmad/pmnd/pmxd,
6642
+ * no ppos); pmxd tracks the remaining break time so top-up pods only ask for
6643
+ * what still fits.
6644
+ */ key: "nextAdRequestUrl",
7144
6645
  value: function nextAdRequestUrl(baseVastUrl) {
7145
- if (this.optimizedPodsEnabled) {
7146
- var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
7147
- var breakDurationMs = remaining > 0 ? remaining : void 0;
7148
- return this.host.generatePodVastUrl(baseVastUrl, breakDurationMs);
7149
- }
7150
- return this.host.generateVastUrls(baseVastUrl, 1)[0];
6646
+ var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
6647
+ var breakDurationMs = remaining > 0 ? remaining : void 0;
6648
+ return this.host.generatePodVastUrl(baseVastUrl, breakDurationMs);
7151
6649
  }
7152
6650
  },
7153
6651
  {
@@ -7319,7 +6817,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7319
6817
  // ───────────────────────────────────────────────────────────────
7320
6818
  function handleAdStart(_marker) {
7321
6819
  return _async_to_generator(function() {
7322
- var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, podPlayed, firstAdUrl, usePreloadedAd, preloadedController, preloaded, adPlayer, preservedMuted, preservedVolume, adVolume, adPlayer1, adVolume1, error, fallbackPreloaded, ap, adVolume2, fallbackError;
6820
+ var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, podPlayed;
7323
6821
  return _ts_generator(this, function(_state) {
7324
6822
  switch(_state.label){
7325
6823
  case 0:
@@ -7366,293 +6864,29 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7366
6864
  if (this.timing.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
7367
6865
  this.timing.expectedAdBreakDurationMs = adBreakDurationMs;
7368
6866
  }
7369
- if (!this.optimizedPodsEnabled) return [
7370
- 3,
7371
- 2
7372
- ];
7373
6867
  return [
7374
6868
  4,
7375
6869
  this.startOptimizedPod(baseVastUrl, adBreakDurationMs, currentMuted, currentVolume)
7376
6870
  ];
7377
6871
  case 1:
7378
6872
  podPlayed = _state.sent();
7379
- if (podPlayed) {
7380
- return [
7381
- 2
7382
- ];
7383
- }
6873
+ if (!!podPlayed) return [
6874
+ 3,
6875
+ 3
6876
+ ];
7384
6877
  if (this.debug) {
7385
- console.log("[POD] Optimized pod unavailable, falling back to sequential single-ad path");
6878
+ console.log("[POD] Initial pod request did not fill; attempting top-up pod request");
7386
6879
  }
7387
- _state.label = 2;
6880
+ this.continuousFetchingActive = true;
6881
+ this.startContinuousFetching(baseVastUrl);
6882
+ return [
6883
+ 4,
6884
+ this.tryNextAvailableAdWithRateLimit()
6885
+ ];
7388
6886
  case 2:
7389
- usePreloadedAd = false;
7390
- preloaded = this.preloadPool.getPreloadedAd();
7391
- if (preloaded) {
7392
- firstAdUrl = preloaded.vastUrl;
7393
- preloadedController = preloaded.adController;
7394
- usePreloadedAd = true;
7395
- sendAdLoadedTracking(this.host.config.licenseKey, {
7396
- source: "hls",
7397
- vastUrl: firstAdUrl,
7398
- timestamp: /* @__PURE__ */ new Date().toISOString()
7399
- }, this.analyticsContext).catch(function() {});
7400
- if (this.debug) {
7401
- console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool (preloaded in advance, ready immediately!)");
7402
- }
7403
- } else if (this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0) {
7404
- this.adRequestQueue = _to_consumable_array(this.pendingAdBreak.vastUrls);
7405
- firstAdUrl = this.adRequestQueue.shift();
7406
- if (this.debug) {
7407
- console.log("[CONTINUOUS-FETCH] Pool empty, using prefetched URLs (".concat(this.adRequestQueue.length + 1, " available)"));
7408
- }
7409
- this.clearPendingAdBreak();
7410
- } else {
7411
- if (this.debug) {
7412
- console.log("[CONTINUOUS-FETCH] Generating new ad URLs...");
7413
- }
7414
- firstAdUrl = this.nextAdRequestUrl(baseVastUrl);
7415
- this.adRequestQueue = [];
7416
- }
7417
- if (!firstAdUrl) {
7418
- if (this.debug) {
7419
- console.warn("[CONTINUOUS-FETCH] Failed to get first ad URL");
7420
- }
7421
- this.handleAdPodComplete();
7422
- return [
7423
- 2
7424
- ];
7425
- }
7426
- if (this.debug) {
7427
- console.log("[CONTINUOUS-FETCH] First VAST URL:", firstAdUrl);
7428
- }
6887
+ _state.sent();
7429
6888
  _state.label = 3;
7430
6889
  case 3:
7431
- _state.trys.push([
7432
- 3,
7433
- 14,
7434
- ,
7435
- 22
7436
- ]);
7437
- if (!(usePreloadedAd && preloadedController)) return [
7438
- 3,
7439
- 7
7440
- ];
7441
- if (!!this.timing.ensureLoadedAdFitsBudget(preloadedController)) return [
7442
- 3,
7443
- 5
7444
- ];
7445
- this.timing.rejectLoadedAdForDuration(preloadedController);
7446
- this.startContinuousFetching(baseVastUrl);
7447
- return [
7448
- 4,
7449
- this.tryNextAvailableAdWithRateLimit()
7450
- ];
7451
- case 4:
7452
- _state.sent();
7453
- return [
7454
- 2
7455
- ];
7456
- case 5:
7457
- adPlayer = this.host.getAdPlayer();
7458
- preservedMuted = adPlayer.getOriginalMutedState();
7459
- preservedVolume = adPlayer.getOriginalVolume();
7460
- adPlayer.destroy();
7461
- this.host.video.muted = true;
7462
- this.host.setAdPlayer(preloadedController);
7463
- preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
7464
- this.attachImaEventListeners();
7465
- if (this.debug) {
7466
- console.log("[CONTINUOUS-FETCH] Using preloaded ad, resuming and starting playback immediately (no request delay!)");
7467
- }
7468
- preloadedController.resume();
7469
- this.timing.consecutiveFailures = 0;
7470
- this.startContinuousFetching(baseVastUrl);
7471
- if (!this.optimizedPodsEnabled) {
7472
- if (!this.preloadPool.active) {
7473
- this.preloadPool.active = true;
7474
- }
7475
- if (!this.preloadPool.isLoopRunning) {
7476
- this.preloadPool.preloadPoolLoop(baseVastUrl);
7477
- }
7478
- }
7479
- return [
7480
- 4,
7481
- preloadedController.play()
7482
- ];
7483
- case 6:
7484
- _state.sent();
7485
- this.timing.markAdStarted();
7486
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7487
- this.timing.scheduleAdStopAtBreakBoundary();
7488
- }
7489
- adVolume = currentMuted ? 0 : currentVolume;
7490
- preloadedController.setAdVolume(adVolume);
7491
- return [
7492
- 3,
7493
- 13
7494
- ];
7495
- case 7:
7496
- adPlayer1 = this.host.getAdPlayer();
7497
- return [
7498
- 4,
7499
- this.timing.enforceGlobalRateLimit()
7500
- ];
7501
- case 8:
7502
- _state.sent();
7503
- this.timing.lastAdRequestTime = Date.now();
7504
- return [
7505
- 4,
7506
- adPlayer1.requestAds(firstAdUrl)
7507
- ];
7508
- case 9:
7509
- _state.sent();
7510
- sendAdLoadedTracking(this.host.config.licenseKey, {
7511
- source: "hls",
7512
- vastUrl: firstAdUrl,
7513
- timestamp: /* @__PURE__ */ new Date().toISOString()
7514
- }, this.analyticsContext).catch(function() {});
7515
- if (this.debug) {
7516
- console.log("[CONTINUOUS-FETCH] First ad request successful, starting playback");
7517
- }
7518
- if (!!this.timing.ensureLoadedAdFitsBudget(adPlayer1)) return [
7519
- 3,
7520
- 11
7521
- ];
7522
- this.timing.rejectLoadedAdForDuration(adPlayer1);
7523
- this.recreateAdController();
7524
- this.startContinuousFetching(baseVastUrl);
7525
- return [
7526
- 4,
7527
- this.tryNextAvailableAdWithRateLimit()
7528
- ];
7529
- case 10:
7530
- _state.sent();
7531
- return [
7532
- 2
7533
- ];
7534
- case 11:
7535
- this.timing.consecutiveFailures = 0;
7536
- this.startContinuousFetching(baseVastUrl);
7537
- if (!this.optimizedPodsEnabled && !this.preloadPool.active) {
7538
- this.preloadPool.startPreloadPool(baseVastUrl, []);
7539
- }
7540
- return [
7541
- 4,
7542
- adPlayer1.play()
7543
- ];
7544
- case 12:
7545
- _state.sent();
7546
- this.timing.markAdStarted();
7547
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7548
- this.timing.scheduleAdStopAtBreakBoundary();
7549
- }
7550
- adVolume1 = currentMuted ? 0 : currentVolume;
7551
- adPlayer1.setAdVolume(adVolume1);
7552
- _state.label = 13;
7553
- case 13:
7554
- return [
7555
- 3,
7556
- 22
7557
- ];
7558
- case 14:
7559
- error = _state.sent();
7560
- if (this.debug) {
7561
- console.warn("[CONTINUOUS-FETCH] First ad request failed:", error);
7562
- }
7563
- if (!!usePreloadedAd) return [
7564
- 3,
7565
- 20
7566
- ];
7567
- fallbackPreloaded = this.preloadPool.getPreloadedAd();
7568
- if (!fallbackPreloaded) return [
7569
- 3,
7570
- 20
7571
- ];
7572
- if (this.debug) {
7573
- console.log("[CONTINUOUS-FETCH] First ad failed, using preloaded fallback");
7574
- }
7575
- _state.label = 15;
7576
- case 15:
7577
- _state.trys.push([
7578
- 15,
7579
- 19,
7580
- ,
7581
- 20
7582
- ]);
7583
- if (!!this.timing.ensureLoadedAdFitsBudget(fallbackPreloaded.adController)) return [
7584
- 3,
7585
- 17
7586
- ];
7587
- this.timing.rejectLoadedAdForDuration(fallbackPreloaded.adController);
7588
- this.startContinuousFetching(baseVastUrl);
7589
- return [
7590
- 4,
7591
- this.tryNextAvailableAdWithRateLimit()
7592
- ];
7593
- case 16:
7594
- _state.sent();
7595
- return [
7596
- 2
7597
- ];
7598
- case 17:
7599
- this.swapToPreloadedAdPlayer(fallbackPreloaded.adController);
7600
- this.timing.consecutiveFailures = 0;
7601
- this.startContinuousFetching(baseVastUrl);
7602
- if (!this.optimizedPodsEnabled && !this.preloadPool.active) {
7603
- this.preloadPool.active = true;
7604
- this.preloadPool.preloadPoolLoop(baseVastUrl);
7605
- }
7606
- ap = this.host.getAdPlayer();
7607
- return [
7608
- 4,
7609
- ap.play()
7610
- ];
7611
- case 18:
7612
- _state.sent();
7613
- this.timing.markAdStarted();
7614
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7615
- this.timing.scheduleAdStopAtBreakBoundary();
7616
- }
7617
- adVolume2 = currentMuted ? 0 : currentVolume;
7618
- ap.setAdVolume(adVolume2);
7619
- return [
7620
- 2
7621
- ];
7622
- case 19:
7623
- fallbackError = _state.sent();
7624
- if (this.debug) {
7625
- console.warn("[CONTINUOUS-FETCH] Preloaded fallback also failed:", fallbackError);
7626
- }
7627
- return [
7628
- 3,
7629
- 20
7630
- ];
7631
- case 20:
7632
- if (this.timing.isTemporaryAdError(error)) {
7633
- this.timing.temporaryFailureUrls.set(firstAdUrl, Date.now());
7634
- if (this.debug) {
7635
- console.log("[CONTINUOUS-FETCH] First ad had temporary error (no-fill) - will try alternatives");
7636
- }
7637
- } else {
7638
- this.timing.failedVastUrls.add(firstAdUrl);
7639
- if (this.debug) {
7640
- console.log("[CONTINUOUS-FETCH] First ad had permanent error - URL blacklisted");
7641
- }
7642
- }
7643
- this.timing.consecutiveFailures++;
7644
- this.startContinuousFetching(baseVastUrl);
7645
- return [
7646
- 4,
7647
- this.tryNextAvailableAdWithRateLimit()
7648
- ];
7649
- case 21:
7650
- _state.sent();
7651
- return [
7652
- 3,
7653
- 22
7654
- ];
7655
- case 22:
7656
6890
  return [
7657
6891
  2
7658
6892
  ];
@@ -7726,7 +6960,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7726
6960
  ];
7727
6961
  }
7728
6962
  if (this.debug) {
7729
- 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"));
6963
+ 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"));
7730
6964
  }
7731
6965
  sendAdLoadedTracking(this.host.config.licenseKey, {
7732
6966
  source: "hls",
@@ -7746,10 +6980,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7746
6980
  }
7747
6981
  adPlayer.setAdVolume(currentMuted ? 0 : currentVolume);
7748
6982
  this.timing.consecutiveFailures = 0;
7749
- if (podCount === 1) {
7750
- this.continuousFetchingActive = true;
7751
- this.startContinuousFetching(baseVastUrl);
7752
- }
6983
+ this.continuousFetchingActive = true;
6984
+ this.startContinuousFetching(baseVastUrl);
7753
6985
  return [
7754
6986
  2,
7755
6987
  true
@@ -7782,20 +7014,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7782
7014
  }).call(this);
7783
7015
  }
7784
7016
  },
7785
- {
7786
- key: "swapToPreloadedAdPlayer",
7787
- value: function swapToPreloadedAdPlayer(preloadedController) {
7788
- var adPlayer = this.host.getAdPlayer();
7789
- var preservedMuted = adPlayer.getOriginalMutedState();
7790
- var preservedVolume = adPlayer.getOriginalVolume();
7791
- adPlayer.destroy();
7792
- this.host.video.muted = true;
7793
- this.host.setAdPlayer(preloadedController);
7794
- this.attachImaEventListeners();
7795
- preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
7796
- preloadedController.resume();
7797
- }
7798
- },
7799
7017
  {
7800
7018
  // ───────────────────────────────────────────────────────────────
7801
7019
  // Continuous fetching
@@ -8046,7 +7264,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8046
7264
  value: function tryNextAvailableAd() {
8047
7265
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
8048
7266
  return _async_to_generator(function() {
8049
- var remaining, preloaded, ap, error, nextAdUrl, error1, errorMessage, maxRetries;
7267
+ var remaining, nextAdUrl, error, errorMessage, maxRetries;
8050
7268
  return _ts_generator(this, function(_state) {
8051
7269
  switch(_state.label){
8052
7270
  case 0:
@@ -8084,132 +7302,71 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8084
7302
  ];
8085
7303
  }
8086
7304
  this.timing.cleanupTemporaryFailures();
8087
- preloaded = this.preloadPool.getPreloadedAd();
8088
- if (!preloaded) return [
8089
- 3,
8090
- 6
8091
- ];
8092
- if (this.debug) {
8093
- console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool");
8094
- }
8095
- sendAdLoadedTracking(this.host.config.licenseKey, {
8096
- source: "hls",
8097
- vastUrl: preloaded.vastUrl,
8098
- timestamp: /* @__PURE__ */ new Date().toISOString()
8099
- }, this.analyticsContext).catch(function() {});
8100
7305
  _state.label = 1;
8101
7306
  case 1:
8102
- _state.trys.push([
8103
- 1,
8104
- 5,
8105
- ,
8106
- 6
8107
- ]);
8108
- if (!!this.timing.ensureLoadedAdFitsBudget(preloaded.adController)) return [
8109
- 3,
8110
- 3
8111
- ];
8112
- this.timing.rejectLoadedAdForDuration(preloaded.adController);
8113
- return [
8114
- 4,
8115
- this.tryNextAvailableAdWithRateLimit()
8116
- ];
8117
- case 2:
8118
- _state.sent();
8119
- return [
8120
- 2
8121
- ];
8122
- case 3:
8123
- this.swapToPreloadedAdPlayer(preloaded.adController);
8124
- ap = this.host.getAdPlayer();
8125
- return [
8126
- 4,
8127
- ap.play()
8128
- ];
8129
- case 4:
8130
- _state.sent();
8131
- this.timing.markAdStarted();
8132
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
8133
- this.timing.scheduleAdStopAtBreakBoundary();
8134
- }
8135
- ap.setAdVolume(getAdAudioVolume(ap));
8136
- this.timing.consecutiveFailures = 0;
8137
- return [
8138
- 2
8139
- ];
8140
- case 5:
8141
- error = _state.sent();
8142
- if (this.debug) {
8143
- console.warn("[CONTINUOUS-FETCH] Preloaded ad failed to play:", error);
8144
- }
8145
- return [
8146
- 3,
8147
- 6
8148
- ];
8149
- case 6:
8150
7307
  if (!(this.adRequestQueue.length > 0)) return [
8151
7308
  3,
8152
- 14
7309
+ 9
8153
7310
  ];
8154
7311
  nextAdUrl = this.adRequestQueue.shift();
8155
7312
  if (!nextAdUrl) return [
8156
7313
  3,
8157
- 6
7314
+ 1
8158
7315
  ];
8159
7316
  if (this.timing.failedVastUrls.has(nextAdUrl)) {
8160
7317
  if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping permanently-failed URL, trying next...");
8161
7318
  return [
8162
7319
  3,
8163
- 6
7320
+ 1
8164
7321
  ];
8165
7322
  }
8166
7323
  if (this.timing.isUrlInCooldown(nextAdUrl)) {
8167
7324
  if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping URL in cooldown (recent no-fill), trying next...");
8168
7325
  return [
8169
7326
  3,
8170
- 6
7327
+ 1
8171
7328
  ];
8172
7329
  }
8173
7330
  if (this.debug) {
8174
7331
  console.log("[CONTINUOUS-FETCH] Requesting next ad via HLS ad player (".concat(this.timing.currentAdIndex + 1, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
8175
7332
  }
8176
- _state.label = 7;
8177
- case 7:
7333
+ _state.label = 2;
7334
+ case 2:
8178
7335
  _state.trys.push([
8179
- 7,
8180
- 9,
7336
+ 2,
7337
+ 4,
8181
7338
  ,
8182
- 13
7339
+ 8
8183
7340
  ]);
8184
7341
  return [
8185
7342
  4,
8186
7343
  this.playSingleAd(nextAdUrl)
8187
7344
  ];
8188
- case 8:
7345
+ case 3:
8189
7346
  _state.sent();
8190
7347
  this.timing.consecutiveFailures = 0;
8191
7348
  return [
8192
7349
  3,
8193
- 13
7350
+ 8
8194
7351
  ];
8195
- case 9:
8196
- error1 = _state.sent();
8197
- errorMessage = error1.message;
7352
+ case 4:
7353
+ error = _state.sent();
7354
+ errorMessage = error.message;
8198
7355
  if (this.debug) console.log("[CONTINUOUS-FETCH] Ad request failed:", errorMessage);
8199
7356
  if (!errorMessage.includes("ad_duration_exceeds_budget")) return [
8200
7357
  3,
8201
- 11
7358
+ 6
8202
7359
  ];
8203
7360
  return [
8204
7361
  4,
8205
7362
  this.tryNextAvailableAdWithRateLimit()
8206
7363
  ];
8207
- case 10:
7364
+ case 5:
8208
7365
  _state.sent();
8209
7366
  return [
8210
7367
  2
8211
7368
  ];
8212
- case 11:
7369
+ case 6:
8213
7370
  if (!errorMessage.includes("permanently failed") && !errorMessage.includes("in cooldown")) {
8214
7371
  this.timing.consecutiveFailures++;
8215
7372
  }
@@ -8217,21 +7374,21 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8217
7374
  4,
8218
7375
  this.tryNextAvailableAdWithRateLimit()
8219
7376
  ];
8220
- case 12:
7377
+ case 7:
8221
7378
  _state.sent();
8222
7379
  return [
8223
7380
  3,
8224
- 13
7381
+ 8
8225
7382
  ];
8226
- case 13:
7383
+ case 8:
8227
7384
  return [
8228
7385
  2
8229
7386
  ];
8230
- case 14:
7387
+ case 9:
8231
7388
  maxRetries = 3;
8232
7389
  if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
8233
7390
  3,
8234
- 17
7391
+ 12
8235
7392
  ];
8236
7393
  if (this.debug) {
8237
7394
  console.log("[CONTINUOUS-FETCH] Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
@@ -8242,18 +7399,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8242
7399
  return setTimeout(resolve, 500);
8243
7400
  })
8244
7401
  ];
8245
- case 15:
7402
+ case 10:
8246
7403
  _state.sent();
8247
7404
  return [
8248
7405
  4,
8249
7406
  this.tryNextAvailableAd(retryCount + 1)
8250
7407
  ];
8251
- case 16:
7408
+ case 11:
8252
7409
  _state.sent();
8253
7410
  return [
8254
7411
  2
8255
7412
  ];
8256
- case 17:
7413
+ case 12:
8257
7414
  if (!this.isShowingPlaceholder && remaining > 1e3) {
8258
7415
  this.showPlaceholderAndWaitForAds();
8259
7416
  } else {
@@ -8275,7 +7432,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8275
7432
  // ───────────────────────────────────────────────────────────────
8276
7433
  function playSingleAd(vastTagUrl) {
8277
7434
  return _async_to_generator(function() {
8278
- var adPlayer, requestToken, ap, playError, preloadedFallback, fbAp, fallbackError, error, errorMessage, preloadedFallback1, fbAp1, fallbackError1;
7435
+ var adPlayer, requestToken, ap, playError, error, errorMessage;
8279
7436
  return _ts_generator(this, function(_state) {
8280
7437
  switch(_state.label){
8281
7438
  case 0:
@@ -8307,9 +7464,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8307
7464
  case 1:
8308
7465
  _state.trys.push([
8309
7466
  1,
8310
- 12,
7467
+ 8,
8311
7468
  ,
8312
- 17
7469
+ 9
8313
7470
  ]);
8314
7471
  return [
8315
7472
  4,
@@ -8345,7 +7502,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8345
7502
  4,
8346
7503
  6,
8347
7504
  ,
8348
- 11
7505
+ 7
8349
7506
  ]);
8350
7507
  this.timing.startAdFailsafeTimer(requestToken);
8351
7508
  return [
@@ -8363,55 +7520,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8363
7520
  this.timing.temporaryFailureUrls.delete(vastTagUrl);
8364
7521
  return [
8365
7522
  3,
8366
- 11
7523
+ 7
8367
7524
  ];
8368
7525
  case 6:
8369
7526
  playError = _state.sent();
8370
7527
  if (this.debug) console.error("[AD-ERROR] Failed to play ad:", playError);
8371
- preloadedFallback = this.preloadPool.getPreloadedAd();
8372
- if (!preloadedFallback) return [
8373
- 3,
8374
- 10
8375
- ];
8376
- if (this.debug) console.log("[AD-ERROR] Play failed, trying preloaded fallback ad");
8377
- _state.label = 7;
8378
- case 7:
8379
- _state.trys.push([
8380
- 7,
8381
- 9,
8382
- ,
8383
- 10
8384
- ]);
8385
- if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback.adController)) {
8386
- this.timing.rejectLoadedAdForDuration(preloadedFallback.adController);
8387
- throw playError;
8388
- }
8389
- this.timing.clearAdFailsafeTimer();
8390
- this.swapToPreloadedAdPlayer(preloadedFallback.adController);
8391
- this.timing.consecutiveFailures = 0;
8392
- fbAp = this.host.getAdPlayer();
8393
- return [
8394
- 4,
8395
- fbAp.play()
8396
- ];
8397
- case 8:
8398
- _state.sent();
8399
- this.timing.markAdStarted();
8400
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
8401
- this.timing.scheduleAdStopAtBreakBoundary();
8402
- }
8403
- fbAp.setAdVolume(getAdAudioVolume(fbAp));
8404
- return [
8405
- 2
8406
- ];
8407
- case 9:
8408
- fallbackError = _state.sent();
8409
- if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError);
8410
- return [
8411
- 3,
8412
- 10
8413
- ];
8414
- case 10:
8415
7528
  if (this.timing.isTemporaryAdError(playError)) {
8416
7529
  this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
8417
7530
  if (this.debug) console.log("[AD-ERROR] Temporary play error - URL can be retried after cooldown");
@@ -8424,57 +7537,15 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8424
7537
  this.timing.activeAdRequestToken = null;
8425
7538
  }
8426
7539
  throw playError;
8427
- case 11:
7540
+ case 7:
8428
7541
  return [
8429
7542
  3,
8430
- 17
7543
+ 9
8431
7544
  ];
8432
- case 12:
7545
+ case 8:
8433
7546
  error = _state.sent();
8434
7547
  errorMessage = (error === null || error === void 0 ? void 0 : error.message) || "";
8435
7548
  if (this.debug) console.error("[AD-ERROR] Ad request failed:", errorMessage);
8436
- preloadedFallback1 = this.preloadPool.getPreloadedAd();
8437
- if (!preloadedFallback1) return [
8438
- 3,
8439
- 16
8440
- ];
8441
- if (this.debug) console.log("[AD-ERROR] Request failed, trying preloaded fallback ad");
8442
- _state.label = 13;
8443
- case 13:
8444
- _state.trys.push([
8445
- 13,
8446
- 15,
8447
- ,
8448
- 16
8449
- ]);
8450
- if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback1.adController)) {
8451
- this.timing.rejectLoadedAdForDuration(preloadedFallback1.adController);
8452
- throw error;
8453
- }
8454
- this.timing.clearAdRequestWatchdog();
8455
- this.timing.clearAdFailsafeTimer();
8456
- this.swapToPreloadedAdPlayer(preloadedFallback1.adController);
8457
- this.timing.consecutiveFailures = 0;
8458
- fbAp1 = this.host.getAdPlayer();
8459
- return [
8460
- 4,
8461
- fbAp1.play()
8462
- ];
8463
- case 14:
8464
- _state.sent();
8465
- this.timing.markAdStarted();
8466
- fbAp1.setAdVolume(getAdAudioVolume(fbAp1));
8467
- return [
8468
- 2
8469
- ];
8470
- case 15:
8471
- fallbackError1 = _state.sent();
8472
- if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError1);
8473
- return [
8474
- 3,
8475
- 16
8476
- ];
8477
- case 16:
8478
7549
  if (this.timing.isTemporaryAdError(error)) {
8479
7550
  this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
8480
7551
  if (this.debug) console.log("[AD-ERROR] Temporary error (no-fill/timeout) - URL can be retried after cooldown");
@@ -8488,7 +7559,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8488
7559
  this.timing.activeAdRequestToken = null;
8489
7560
  }
8490
7561
  throw error;
8491
- case 17:
7562
+ case 9:
8492
7563
  return [
8493
7564
  2
8494
7565
  ];
@@ -8678,7 +7749,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8678
7749
  }
8679
7750
  this.timing.resetForBreakEnd();
8680
7751
  this.stopContinuousFetching();
8681
- this.preloadPool.stop();
8682
7752
  this.clearPendingAdBreak();
8683
7753
  if (this.isShowingPlaceholder) {
8684
7754
  this.host.getAdPlayer().hidePlaceholder();
@@ -8788,25 +7858,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8788
7858
  return _this.adBreak.handleAdFailure();
8789
7859
  }
8790
7860
  });
8791
- this.preloadPool = new AdPreloadPool({
8792
- debug: !!this.config.debugAdTiming,
8793
- createAdPlayer: function createAdPlayer(c) {
8794
- return _this.createAdPlayer(c);
8795
- },
8796
- shouldContinueLiveStreamDuringAds: function shouldContinueLiveStreamDuringAds() {
8797
- return _this.shouldContinueLiveStreamDuringAds();
8798
- },
8799
- timing: this.timing,
8800
- generateVastUrlsWithCorrelators: function generateVastUrlsWithCorrelators(base, count) {
8801
- return _this.generateVastUrls(base, count);
8802
- },
8803
- isInAdBreak: function isInAdBreak() {
8804
- return _this.adBreak.inAdBreak;
8805
- },
8806
- getPendingAdBreak: function getPendingAdBreak() {
8807
- return _this.adBreak.pendingAdBreak;
8808
- }
8809
- });
8810
7861
  this.placeholder = new PlaceholderLayer(this.video, !!this.config.debugAdTiming);
8811
7862
  this.hlsEngine = new HlsEngine(this.config, this.video, this.cueManager, this.timing, {
8812
7863
  onManifestParsed: function onManifestParsed(isLive) {
@@ -8853,13 +7904,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8853
7904
  getLiveSyncPosition: function getLiveSyncPosition() {
8854
7905
  return _this.hlsEngine.getLiveSyncPosition();
8855
7906
  },
8856
- generateVastUrls: function generateVastUrls(base, count) {
8857
- return _this.generateVastUrls(base, count);
8858
- },
8859
7907
  generatePodVastUrl: function generatePodVastUrl(base, breakDurationMs) {
8860
7908
  return _this.generatePodVastUrl(base, breakDurationMs);
8861
7909
  }
8862
- }, this.timing, this.preloadPool, this.adConfig, this.cueManager, this.placeholder);
7910
+ }, this.timing, this.adConfig, this.cueManager, this.placeholder);
8863
7911
  }
8864
7912
  _create_class(StormcloudVideoPlayer, [
8865
7913
  {
@@ -8884,12 +7932,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8884
7932
  } : {}));
8885
7933
  }
8886
7934
  },
8887
- {
8888
- key: "generateVastUrls",
8889
- value: function generateVastUrls(baseUrl, count) {
8890
- return this.adConfig.generateVastUrlsWithCorrelators(baseUrl, count, this.adPlayer, this.palNonce, this.adBreak.inAdBreak);
8891
- }
8892
- },
8893
7935
  {
8894
7936
  key: "generatePodVastUrl",
8895
7937
  value: function generatePodVastUrl(baseUrl, breakDurationMs) {
@@ -9285,11 +8327,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9285
8327
  }
9286
8328
  this.adConfig.beginNewAdPod();
9287
8329
  this.adConfig.podAssignedByPrefetch = true;
9288
- var optimizedPods = this.config.optimizedPods !== false;
9289
8330
  var breakDurationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : void 0;
9290
- var generatedUrls = optimizedPods ? [
8331
+ var generatedUrls = [
9291
8332
  this.generatePodVastUrl(baseVastUrl, breakDurationMs)
9292
- ] : this.generateVastUrls(baseVastUrl, 1);
8333
+ ];
9293
8334
  this.adBreak.pendingAdBreak = _object_spread_props(_object_spread({
9294
8335
  marker: marker
9295
8336
  }, fragmentSn !== void 0 ? {
@@ -9311,15 +8352,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9311
8352
  }, detectPayload), buildAnalyticsContext(this.config)).catch(function() {});
9312
8353
  if (this.debug) {
9313
8354
  console.log("[PREFETCH] Starting ad prefetch for upcoming ad break");
9314
- console.log("[PREFETCH] Pre-generated ".concat(generatedUrls.length, " ").concat(optimizedPods ? "pod" : "VAST", " URL(s)"));
9315
- }
9316
- if (optimizedPods) {
9317
- if (this.debug) {
9318
- console.log("[PREFETCH] Optimized pods enabled - skipping single-ad preload pool");
9319
- }
9320
- return;
8355
+ console.log("[PREFETCH] Pre-generated pod request URL");
9321
8356
  }
9322
- this.preloadPool.startPreloadPool(baseVastUrl, generatedUrls.slice(0, 1), false);
9323
8357
  }
9324
8358
  },
9325
8359
  {
@@ -9558,7 +8592,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9558
8592
  value: function destroy() {
9559
8593
  var _this_adPlayer;
9560
8594
  this.adBreak.stopContinuousFetching();
9561
- this.preloadPool.stop();
9562
8595
  this.timing.destroy();
9563
8596
  this.adBreak.clearPendingAdBreak();
9564
8597
  this.placeholder.destroy();