stormcloud-video-player 0.8.28 → 0.8.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/stormcloud-vp.min.js +2 -2
  2. package/lib/index.cjs +80 -1038
  3. package/lib/index.cjs.map +1 -1
  4. package/lib/index.d.cts +0 -3
  5. package/lib/index.d.ts +0 -3
  6. package/lib/index.js +80 -1039
  7. package/lib/index.js.map +1 -1
  8. package/lib/player/AdBreakOrchestrator.cjs +59 -483
  9. package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
  10. package/lib/player/AdBreakOrchestrator.d.cts +9 -7
  11. package/lib/player/AdConfigManager.cjs +12 -53
  12. package/lib/player/AdConfigManager.cjs.map +1 -1
  13. package/lib/player/AdConfigManager.d.cts +4 -5
  14. package/lib/player/AdTimingService.d.cts +1 -1
  15. package/lib/player/HlsEngine.d.cts +1 -1
  16. package/lib/player/PlayerControls.d.cts +1 -1
  17. package/lib/player/Scte35CueManager.d.cts +1 -1
  18. package/lib/player/Scte35Parser.d.cts +1 -1
  19. package/lib/player/StormcloudVideoPlayer.cjs +80 -1038
  20. package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
  21. package/lib/player/StormcloudVideoPlayer.d.cts +1 -3
  22. package/lib/player/playerTypes.d.cts +1 -1
  23. package/lib/players/HlsPlayer.cjs +80 -1038
  24. package/lib/players/HlsPlayer.cjs.map +1 -1
  25. package/lib/players/HlsPlayer.d.cts +1 -1
  26. package/lib/players/index.cjs +80 -1038
  27. package/lib/players/index.cjs.map +1 -1
  28. package/lib/sdk/hlsAdPlayer.d.cts +1 -1
  29. package/lib/{types-Xgz2_W1C.d.cts → types-CSHvCbhZ.d.cts} +0 -1
  30. package/lib/ui/StormcloudVideoPlayer.cjs +80 -1038
  31. package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
  32. package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
  33. package/lib/utils/tracking.d.cts +1 -1
  34. package/lib/utils/vastMacros.cjs +10 -15
  35. package/lib/utils/vastMacros.cjs.map +1 -1
  36. package/lib/utils/vastMacros.d.cts +0 -1
  37. package/package.json +1 -1
  38. package/lib/player/AdPreloadPool.cjs +0 -673
  39. package/lib/player/AdPreloadPool.cjs.map +0 -1
  40. package/lib/player/AdPreloadPool.d.cts +0 -37
@@ -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,12 +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;
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",
6645
+ value: function nextAdRequestUrl(baseVastUrl) {
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);
7140
6649
  }
7141
6650
  },
7142
6651
  {
@@ -7308,7 +6817,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7308
6817
  // ───────────────────────────────────────────────────────────────
7309
6818
  function handleAdStart(_marker) {
7310
6819
  return _async_to_generator(function() {
7311
- var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, podPlayed, firstAdUrl, usePreloadedAd, preloadedController, preloaded, firstAdUrlArray, adPlayer, preservedMuted, preservedVolume, adVolume, adPlayer1, adVolume1, error, fallbackPreloaded, ap, adVolume2, fallbackError;
6820
+ var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, podPlayed;
7312
6821
  return _ts_generator(this, function(_state) {
7313
6822
  switch(_state.label){
7314
6823
  case 0:
@@ -7355,292 +6864,29 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7355
6864
  if (this.timing.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
7356
6865
  this.timing.expectedAdBreakDurationMs = adBreakDurationMs;
7357
6866
  }
7358
- if (!this.optimizedPodsEnabled) return [
7359
- 3,
7360
- 2
7361
- ];
7362
6867
  return [
7363
6868
  4,
7364
6869
  this.startOptimizedPod(baseVastUrl, adBreakDurationMs, currentMuted, currentVolume)
7365
6870
  ];
7366
6871
  case 1:
7367
6872
  podPlayed = _state.sent();
7368
- if (podPlayed) {
7369
- return [
7370
- 2
7371
- ];
7372
- }
6873
+ if (!!podPlayed) return [
6874
+ 3,
6875
+ 3
6876
+ ];
7373
6877
  if (this.debug) {
7374
- 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");
7375
6879
  }
7376
- _state.label = 2;
6880
+ this.continuousFetchingActive = true;
6881
+ this.startContinuousFetching(baseVastUrl);
6882
+ return [
6883
+ 4,
6884
+ this.tryNextAvailableAdWithRateLimit()
6885
+ ];
7377
6886
  case 2:
7378
- usePreloadedAd = false;
7379
- preloaded = this.preloadPool.getPreloadedAd();
7380
- if (preloaded) {
7381
- firstAdUrl = preloaded.vastUrl;
7382
- preloadedController = preloaded.adController;
7383
- usePreloadedAd = true;
7384
- sendAdLoadedTracking(this.host.config.licenseKey, {
7385
- source: "hls",
7386
- vastUrl: firstAdUrl,
7387
- timestamp: /* @__PURE__ */ new Date().toISOString()
7388
- }, this.analyticsContext).catch(function() {});
7389
- if (this.debug) {
7390
- console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool (preloaded in advance, ready immediately!)");
7391
- }
7392
- } else if (this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0) {
7393
- this.adRequestQueue = _to_consumable_array(this.pendingAdBreak.vastUrls);
7394
- firstAdUrl = this.adRequestQueue.shift();
7395
- if (this.debug) {
7396
- console.log("[CONTINUOUS-FETCH] Pool empty, using prefetched URLs (".concat(this.adRequestQueue.length + 1, " available)"));
7397
- }
7398
- this.clearPendingAdBreak();
7399
- } else {
7400
- if (this.debug) {
7401
- console.log("[CONTINUOUS-FETCH] Generating new ad URLs...");
7402
- }
7403
- firstAdUrlArray = this.host.generateVastUrls(baseVastUrl, 1);
7404
- firstAdUrl = firstAdUrlArray[0];
7405
- this.adRequestQueue = [];
7406
- }
7407
- if (!firstAdUrl) {
7408
- if (this.debug) {
7409
- console.warn("[CONTINUOUS-FETCH] Failed to get first ad URL");
7410
- }
7411
- this.handleAdPodComplete();
7412
- return [
7413
- 2
7414
- ];
7415
- }
7416
- if (this.debug) {
7417
- console.log("[CONTINUOUS-FETCH] First VAST URL:", firstAdUrl);
7418
- }
6887
+ _state.sent();
7419
6888
  _state.label = 3;
7420
6889
  case 3:
7421
- _state.trys.push([
7422
- 3,
7423
- 14,
7424
- ,
7425
- 22
7426
- ]);
7427
- if (!(usePreloadedAd && preloadedController)) return [
7428
- 3,
7429
- 7
7430
- ];
7431
- if (!!this.timing.ensureLoadedAdFitsBudget(preloadedController)) return [
7432
- 3,
7433
- 5
7434
- ];
7435
- this.timing.rejectLoadedAdForDuration(preloadedController);
7436
- this.startContinuousFetching(baseVastUrl);
7437
- return [
7438
- 4,
7439
- this.tryNextAvailableAdWithRateLimit()
7440
- ];
7441
- case 4:
7442
- _state.sent();
7443
- return [
7444
- 2
7445
- ];
7446
- case 5:
7447
- adPlayer = this.host.getAdPlayer();
7448
- preservedMuted = adPlayer.getOriginalMutedState();
7449
- preservedVolume = adPlayer.getOriginalVolume();
7450
- adPlayer.destroy();
7451
- this.host.video.muted = true;
7452
- this.host.setAdPlayer(preloadedController);
7453
- preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
7454
- this.attachImaEventListeners();
7455
- if (this.debug) {
7456
- console.log("[CONTINUOUS-FETCH] Using preloaded ad, resuming and starting playback immediately (no request delay!)");
7457
- }
7458
- preloadedController.resume();
7459
- this.timing.consecutiveFailures = 0;
7460
- this.startContinuousFetching(baseVastUrl);
7461
- if (!this.preloadPool.active) {
7462
- this.preloadPool.active = true;
7463
- }
7464
- if (!this.preloadPool.isLoopRunning) {
7465
- this.preloadPool.preloadPoolLoop(baseVastUrl);
7466
- }
7467
- return [
7468
- 4,
7469
- preloadedController.play()
7470
- ];
7471
- case 6:
7472
- _state.sent();
7473
- this.timing.markAdStarted();
7474
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7475
- this.timing.scheduleAdStopAtBreakBoundary();
7476
- }
7477
- adVolume = currentMuted ? 0 : currentVolume;
7478
- preloadedController.setAdVolume(adVolume);
7479
- return [
7480
- 3,
7481
- 13
7482
- ];
7483
- case 7:
7484
- adPlayer1 = this.host.getAdPlayer();
7485
- return [
7486
- 4,
7487
- this.timing.enforceGlobalRateLimit()
7488
- ];
7489
- case 8:
7490
- _state.sent();
7491
- this.timing.lastAdRequestTime = Date.now();
7492
- return [
7493
- 4,
7494
- adPlayer1.requestAds(firstAdUrl)
7495
- ];
7496
- case 9:
7497
- _state.sent();
7498
- sendAdLoadedTracking(this.host.config.licenseKey, {
7499
- source: "hls",
7500
- vastUrl: firstAdUrl,
7501
- timestamp: /* @__PURE__ */ new Date().toISOString()
7502
- }, this.analyticsContext).catch(function() {});
7503
- if (this.debug) {
7504
- console.log("[CONTINUOUS-FETCH] First ad request successful, starting playback");
7505
- }
7506
- if (!!this.timing.ensureLoadedAdFitsBudget(adPlayer1)) return [
7507
- 3,
7508
- 11
7509
- ];
7510
- this.timing.rejectLoadedAdForDuration(adPlayer1);
7511
- this.recreateAdController();
7512
- this.startContinuousFetching(baseVastUrl);
7513
- return [
7514
- 4,
7515
- this.tryNextAvailableAdWithRateLimit()
7516
- ];
7517
- case 10:
7518
- _state.sent();
7519
- return [
7520
- 2
7521
- ];
7522
- case 11:
7523
- this.timing.consecutiveFailures = 0;
7524
- this.startContinuousFetching(baseVastUrl);
7525
- if (!this.preloadPool.active) {
7526
- this.preloadPool.startPreloadPool(baseVastUrl, []);
7527
- }
7528
- return [
7529
- 4,
7530
- adPlayer1.play()
7531
- ];
7532
- case 12:
7533
- _state.sent();
7534
- this.timing.markAdStarted();
7535
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7536
- this.timing.scheduleAdStopAtBreakBoundary();
7537
- }
7538
- adVolume1 = currentMuted ? 0 : currentVolume;
7539
- adPlayer1.setAdVolume(adVolume1);
7540
- _state.label = 13;
7541
- case 13:
7542
- return [
7543
- 3,
7544
- 22
7545
- ];
7546
- case 14:
7547
- error = _state.sent();
7548
- if (this.debug) {
7549
- console.warn("[CONTINUOUS-FETCH] First ad request failed:", error);
7550
- }
7551
- if (!!usePreloadedAd) return [
7552
- 3,
7553
- 20
7554
- ];
7555
- fallbackPreloaded = this.preloadPool.getPreloadedAd();
7556
- if (!fallbackPreloaded) return [
7557
- 3,
7558
- 20
7559
- ];
7560
- if (this.debug) {
7561
- console.log("[CONTINUOUS-FETCH] First ad failed, using preloaded fallback");
7562
- }
7563
- _state.label = 15;
7564
- case 15:
7565
- _state.trys.push([
7566
- 15,
7567
- 19,
7568
- ,
7569
- 20
7570
- ]);
7571
- if (!!this.timing.ensureLoadedAdFitsBudget(fallbackPreloaded.adController)) return [
7572
- 3,
7573
- 17
7574
- ];
7575
- this.timing.rejectLoadedAdForDuration(fallbackPreloaded.adController);
7576
- this.startContinuousFetching(baseVastUrl);
7577
- return [
7578
- 4,
7579
- this.tryNextAvailableAdWithRateLimit()
7580
- ];
7581
- case 16:
7582
- _state.sent();
7583
- return [
7584
- 2
7585
- ];
7586
- case 17:
7587
- this.swapToPreloadedAdPlayer(fallbackPreloaded.adController);
7588
- this.timing.consecutiveFailures = 0;
7589
- this.startContinuousFetching(baseVastUrl);
7590
- if (!this.preloadPool.active) {
7591
- this.preloadPool.active = true;
7592
- this.preloadPool.preloadPoolLoop(baseVastUrl);
7593
- }
7594
- ap = this.host.getAdPlayer();
7595
- return [
7596
- 4,
7597
- ap.play()
7598
- ];
7599
- case 18:
7600
- _state.sent();
7601
- this.timing.markAdStarted();
7602
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7603
- this.timing.scheduleAdStopAtBreakBoundary();
7604
- }
7605
- adVolume2 = currentMuted ? 0 : currentVolume;
7606
- ap.setAdVolume(adVolume2);
7607
- return [
7608
- 2
7609
- ];
7610
- case 19:
7611
- fallbackError = _state.sent();
7612
- if (this.debug) {
7613
- console.warn("[CONTINUOUS-FETCH] Preloaded fallback also failed:", fallbackError);
7614
- }
7615
- return [
7616
- 3,
7617
- 20
7618
- ];
7619
- case 20:
7620
- if (this.timing.isTemporaryAdError(error)) {
7621
- this.timing.temporaryFailureUrls.set(firstAdUrl, Date.now());
7622
- if (this.debug) {
7623
- console.log("[CONTINUOUS-FETCH] First ad had temporary error (no-fill) - will try alternatives");
7624
- }
7625
- } else {
7626
- this.timing.failedVastUrls.add(firstAdUrl);
7627
- if (this.debug) {
7628
- console.log("[CONTINUOUS-FETCH] First ad had permanent error - URL blacklisted");
7629
- }
7630
- }
7631
- this.timing.consecutiveFailures++;
7632
- this.startContinuousFetching(baseVastUrl);
7633
- return [
7634
- 4,
7635
- this.tryNextAvailableAdWithRateLimit()
7636
- ];
7637
- case 21:
7638
- _state.sent();
7639
- return [
7640
- 3,
7641
- 22
7642
- ];
7643
- case 22:
7644
6890
  return [
7645
6891
  2
7646
6892
  ];
@@ -7714,7 +6960,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7714
6960
  ];
7715
6961
  }
7716
6962
  if (this.debug) {
7717
- 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"));
7718
6964
  }
7719
6965
  sendAdLoadedTracking(this.host.config.licenseKey, {
7720
6966
  source: "hls",
@@ -7734,13 +6980,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7734
6980
  }
7735
6981
  adPlayer.setAdVolume(currentMuted ? 0 : currentVolume);
7736
6982
  this.timing.consecutiveFailures = 0;
7737
- if (podCount === 1) {
7738
- this.continuousFetchingActive = true;
7739
- this.startContinuousFetching(baseVastUrl);
7740
- if (!this.preloadPool.active) {
7741
- this.preloadPool.startPreloadPool(baseVastUrl, []);
7742
- }
7743
- }
6983
+ this.continuousFetchingActive = true;
6984
+ this.startContinuousFetching(baseVastUrl);
7744
6985
  return [
7745
6986
  2,
7746
6987
  true
@@ -7773,20 +7014,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7773
7014
  }).call(this);
7774
7015
  }
7775
7016
  },
7776
- {
7777
- key: "swapToPreloadedAdPlayer",
7778
- value: function swapToPreloadedAdPlayer(preloadedController) {
7779
- var adPlayer = this.host.getAdPlayer();
7780
- var preservedMuted = adPlayer.getOriginalMutedState();
7781
- var preservedVolume = adPlayer.getOriginalVolume();
7782
- adPlayer.destroy();
7783
- this.host.video.muted = true;
7784
- this.host.setAdPlayer(preloadedController);
7785
- this.attachImaEventListeners();
7786
- preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
7787
- preloadedController.resume();
7788
- }
7789
- },
7790
7017
  {
7791
7018
  // ───────────────────────────────────────────────────────────────
7792
7019
  // Continuous fetching
@@ -7880,7 +7107,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7880
7107
  "continue"
7881
7108
  ];
7882
7109
  case 2:
7883
- newAdUrl = _this.host.generateVastUrls(baseVastUrl, 1)[0];
7110
+ newAdUrl = _this.nextAdRequestUrl(baseVastUrl);
7884
7111
  if (!(!newAdUrl || _this.timing.failedVastUrls.has(newAdUrl) || _this.timing.isUrlInCooldown(newAdUrl))) return [
7885
7112
  3,
7886
7113
  4
@@ -8037,7 +7264,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8037
7264
  value: function tryNextAvailableAd() {
8038
7265
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
8039
7266
  return _async_to_generator(function() {
8040
- var remaining, preloaded, ap, error, nextAdUrl, error1, errorMessage, maxRetries;
7267
+ var remaining, nextAdUrl, error, errorMessage, maxRetries;
8041
7268
  return _ts_generator(this, function(_state) {
8042
7269
  switch(_state.label){
8043
7270
  case 0:
@@ -8075,132 +7302,71 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8075
7302
  ];
8076
7303
  }
8077
7304
  this.timing.cleanupTemporaryFailures();
8078
- preloaded = this.preloadPool.getPreloadedAd();
8079
- if (!preloaded) return [
8080
- 3,
8081
- 6
8082
- ];
8083
- if (this.debug) {
8084
- console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool");
8085
- }
8086
- sendAdLoadedTracking(this.host.config.licenseKey, {
8087
- source: "hls",
8088
- vastUrl: preloaded.vastUrl,
8089
- timestamp: /* @__PURE__ */ new Date().toISOString()
8090
- }, this.analyticsContext).catch(function() {});
8091
7305
  _state.label = 1;
8092
7306
  case 1:
8093
- _state.trys.push([
8094
- 1,
8095
- 5,
8096
- ,
8097
- 6
8098
- ]);
8099
- if (!!this.timing.ensureLoadedAdFitsBudget(preloaded.adController)) return [
8100
- 3,
8101
- 3
8102
- ];
8103
- this.timing.rejectLoadedAdForDuration(preloaded.adController);
8104
- return [
8105
- 4,
8106
- this.tryNextAvailableAdWithRateLimit()
8107
- ];
8108
- case 2:
8109
- _state.sent();
8110
- return [
8111
- 2
8112
- ];
8113
- case 3:
8114
- this.swapToPreloadedAdPlayer(preloaded.adController);
8115
- ap = this.host.getAdPlayer();
8116
- return [
8117
- 4,
8118
- ap.play()
8119
- ];
8120
- case 4:
8121
- _state.sent();
8122
- this.timing.markAdStarted();
8123
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
8124
- this.timing.scheduleAdStopAtBreakBoundary();
8125
- }
8126
- ap.setAdVolume(getAdAudioVolume(ap));
8127
- this.timing.consecutiveFailures = 0;
8128
- return [
8129
- 2
8130
- ];
8131
- case 5:
8132
- error = _state.sent();
8133
- if (this.debug) {
8134
- console.warn("[CONTINUOUS-FETCH] Preloaded ad failed to play:", error);
8135
- }
8136
- return [
8137
- 3,
8138
- 6
8139
- ];
8140
- case 6:
8141
7307
  if (!(this.adRequestQueue.length > 0)) return [
8142
7308
  3,
8143
- 14
7309
+ 9
8144
7310
  ];
8145
7311
  nextAdUrl = this.adRequestQueue.shift();
8146
7312
  if (!nextAdUrl) return [
8147
7313
  3,
8148
- 6
7314
+ 1
8149
7315
  ];
8150
7316
  if (this.timing.failedVastUrls.has(nextAdUrl)) {
8151
7317
  if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping permanently-failed URL, trying next...");
8152
7318
  return [
8153
7319
  3,
8154
- 6
7320
+ 1
8155
7321
  ];
8156
7322
  }
8157
7323
  if (this.timing.isUrlInCooldown(nextAdUrl)) {
8158
7324
  if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping URL in cooldown (recent no-fill), trying next...");
8159
7325
  return [
8160
7326
  3,
8161
- 6
7327
+ 1
8162
7328
  ];
8163
7329
  }
8164
7330
  if (this.debug) {
8165
7331
  console.log("[CONTINUOUS-FETCH] Requesting next ad via HLS ad player (".concat(this.timing.currentAdIndex + 1, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
8166
7332
  }
8167
- _state.label = 7;
8168
- case 7:
7333
+ _state.label = 2;
7334
+ case 2:
8169
7335
  _state.trys.push([
8170
- 7,
8171
- 9,
7336
+ 2,
7337
+ 4,
8172
7338
  ,
8173
- 13
7339
+ 8
8174
7340
  ]);
8175
7341
  return [
8176
7342
  4,
8177
7343
  this.playSingleAd(nextAdUrl)
8178
7344
  ];
8179
- case 8:
7345
+ case 3:
8180
7346
  _state.sent();
8181
7347
  this.timing.consecutiveFailures = 0;
8182
7348
  return [
8183
7349
  3,
8184
- 13
7350
+ 8
8185
7351
  ];
8186
- case 9:
8187
- error1 = _state.sent();
8188
- errorMessage = error1.message;
7352
+ case 4:
7353
+ error = _state.sent();
7354
+ errorMessage = error.message;
8189
7355
  if (this.debug) console.log("[CONTINUOUS-FETCH] Ad request failed:", errorMessage);
8190
7356
  if (!errorMessage.includes("ad_duration_exceeds_budget")) return [
8191
7357
  3,
8192
- 11
7358
+ 6
8193
7359
  ];
8194
7360
  return [
8195
7361
  4,
8196
7362
  this.tryNextAvailableAdWithRateLimit()
8197
7363
  ];
8198
- case 10:
7364
+ case 5:
8199
7365
  _state.sent();
8200
7366
  return [
8201
7367
  2
8202
7368
  ];
8203
- case 11:
7369
+ case 6:
8204
7370
  if (!errorMessage.includes("permanently failed") && !errorMessage.includes("in cooldown")) {
8205
7371
  this.timing.consecutiveFailures++;
8206
7372
  }
@@ -8208,21 +7374,21 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8208
7374
  4,
8209
7375
  this.tryNextAvailableAdWithRateLimit()
8210
7376
  ];
8211
- case 12:
7377
+ case 7:
8212
7378
  _state.sent();
8213
7379
  return [
8214
7380
  3,
8215
- 13
7381
+ 8
8216
7382
  ];
8217
- case 13:
7383
+ case 8:
8218
7384
  return [
8219
7385
  2
8220
7386
  ];
8221
- case 14:
7387
+ case 9:
8222
7388
  maxRetries = 3;
8223
7389
  if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
8224
7390
  3,
8225
- 17
7391
+ 12
8226
7392
  ];
8227
7393
  if (this.debug) {
8228
7394
  console.log("[CONTINUOUS-FETCH] Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
@@ -8233,18 +7399,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8233
7399
  return setTimeout(resolve, 500);
8234
7400
  })
8235
7401
  ];
8236
- case 15:
7402
+ case 10:
8237
7403
  _state.sent();
8238
7404
  return [
8239
7405
  4,
8240
7406
  this.tryNextAvailableAd(retryCount + 1)
8241
7407
  ];
8242
- case 16:
7408
+ case 11:
8243
7409
  _state.sent();
8244
7410
  return [
8245
7411
  2
8246
7412
  ];
8247
- case 17:
7413
+ case 12:
8248
7414
  if (!this.isShowingPlaceholder && remaining > 1e3) {
8249
7415
  this.showPlaceholderAndWaitForAds();
8250
7416
  } else {
@@ -8266,7 +7432,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8266
7432
  // ───────────────────────────────────────────────────────────────
8267
7433
  function playSingleAd(vastTagUrl) {
8268
7434
  return _async_to_generator(function() {
8269
- var adPlayer, requestToken, ap, playError, preloadedFallback, fbAp, fallbackError, error, errorMessage, preloadedFallback1, fbAp1, fallbackError1;
7435
+ var adPlayer, requestToken, ap, playError, error, errorMessage;
8270
7436
  return _ts_generator(this, function(_state) {
8271
7437
  switch(_state.label){
8272
7438
  case 0:
@@ -8298,9 +7464,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8298
7464
  case 1:
8299
7465
  _state.trys.push([
8300
7466
  1,
8301
- 12,
7467
+ 8,
8302
7468
  ,
8303
- 17
7469
+ 9
8304
7470
  ]);
8305
7471
  return [
8306
7472
  4,
@@ -8336,7 +7502,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8336
7502
  4,
8337
7503
  6,
8338
7504
  ,
8339
- 11
7505
+ 7
8340
7506
  ]);
8341
7507
  this.timing.startAdFailsafeTimer(requestToken);
8342
7508
  return [
@@ -8354,55 +7520,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8354
7520
  this.timing.temporaryFailureUrls.delete(vastTagUrl);
8355
7521
  return [
8356
7522
  3,
8357
- 11
7523
+ 7
8358
7524
  ];
8359
7525
  case 6:
8360
7526
  playError = _state.sent();
8361
7527
  if (this.debug) console.error("[AD-ERROR] Failed to play ad:", playError);
8362
- preloadedFallback = this.preloadPool.getPreloadedAd();
8363
- if (!preloadedFallback) return [
8364
- 3,
8365
- 10
8366
- ];
8367
- if (this.debug) console.log("[AD-ERROR] Play failed, trying preloaded fallback ad");
8368
- _state.label = 7;
8369
- case 7:
8370
- _state.trys.push([
8371
- 7,
8372
- 9,
8373
- ,
8374
- 10
8375
- ]);
8376
- if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback.adController)) {
8377
- this.timing.rejectLoadedAdForDuration(preloadedFallback.adController);
8378
- throw playError;
8379
- }
8380
- this.timing.clearAdFailsafeTimer();
8381
- this.swapToPreloadedAdPlayer(preloadedFallback.adController);
8382
- this.timing.consecutiveFailures = 0;
8383
- fbAp = this.host.getAdPlayer();
8384
- return [
8385
- 4,
8386
- fbAp.play()
8387
- ];
8388
- case 8:
8389
- _state.sent();
8390
- this.timing.markAdStarted();
8391
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
8392
- this.timing.scheduleAdStopAtBreakBoundary();
8393
- }
8394
- fbAp.setAdVolume(getAdAudioVolume(fbAp));
8395
- return [
8396
- 2
8397
- ];
8398
- case 9:
8399
- fallbackError = _state.sent();
8400
- if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError);
8401
- return [
8402
- 3,
8403
- 10
8404
- ];
8405
- case 10:
8406
7528
  if (this.timing.isTemporaryAdError(playError)) {
8407
7529
  this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
8408
7530
  if (this.debug) console.log("[AD-ERROR] Temporary play error - URL can be retried after cooldown");
@@ -8415,57 +7537,15 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8415
7537
  this.timing.activeAdRequestToken = null;
8416
7538
  }
8417
7539
  throw playError;
8418
- case 11:
7540
+ case 7:
8419
7541
  return [
8420
7542
  3,
8421
- 17
7543
+ 9
8422
7544
  ];
8423
- case 12:
7545
+ case 8:
8424
7546
  error = _state.sent();
8425
7547
  errorMessage = (error === null || error === void 0 ? void 0 : error.message) || "";
8426
7548
  if (this.debug) console.error("[AD-ERROR] Ad request failed:", errorMessage);
8427
- preloadedFallback1 = this.preloadPool.getPreloadedAd();
8428
- if (!preloadedFallback1) return [
8429
- 3,
8430
- 16
8431
- ];
8432
- if (this.debug) console.log("[AD-ERROR] Request failed, trying preloaded fallback ad");
8433
- _state.label = 13;
8434
- case 13:
8435
- _state.trys.push([
8436
- 13,
8437
- 15,
8438
- ,
8439
- 16
8440
- ]);
8441
- if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback1.adController)) {
8442
- this.timing.rejectLoadedAdForDuration(preloadedFallback1.adController);
8443
- throw error;
8444
- }
8445
- this.timing.clearAdRequestWatchdog();
8446
- this.timing.clearAdFailsafeTimer();
8447
- this.swapToPreloadedAdPlayer(preloadedFallback1.adController);
8448
- this.timing.consecutiveFailures = 0;
8449
- fbAp1 = this.host.getAdPlayer();
8450
- return [
8451
- 4,
8452
- fbAp1.play()
8453
- ];
8454
- case 14:
8455
- _state.sent();
8456
- this.timing.markAdStarted();
8457
- fbAp1.setAdVolume(getAdAudioVolume(fbAp1));
8458
- return [
8459
- 2
8460
- ];
8461
- case 15:
8462
- fallbackError1 = _state.sent();
8463
- if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError1);
8464
- return [
8465
- 3,
8466
- 16
8467
- ];
8468
- case 16:
8469
7549
  if (this.timing.isTemporaryAdError(error)) {
8470
7550
  this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
8471
7551
  if (this.debug) console.log("[AD-ERROR] Temporary error (no-fill/timeout) - URL can be retried after cooldown");
@@ -8479,7 +7559,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8479
7559
  this.timing.activeAdRequestToken = null;
8480
7560
  }
8481
7561
  throw error;
8482
- case 17:
7562
+ case 9:
8483
7563
  return [
8484
7564
  2
8485
7565
  ];
@@ -8669,7 +7749,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8669
7749
  }
8670
7750
  this.timing.resetForBreakEnd();
8671
7751
  this.stopContinuousFetching();
8672
- this.preloadPool.stop();
8673
7752
  this.clearPendingAdBreak();
8674
7753
  if (this.isShowingPlaceholder) {
8675
7754
  this.host.getAdPlayer().hidePlaceholder();
@@ -8779,25 +7858,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8779
7858
  return _this.adBreak.handleAdFailure();
8780
7859
  }
8781
7860
  });
8782
- this.preloadPool = new AdPreloadPool({
8783
- debug: !!this.config.debugAdTiming,
8784
- createAdPlayer: function createAdPlayer(c) {
8785
- return _this.createAdPlayer(c);
8786
- },
8787
- shouldContinueLiveStreamDuringAds: function shouldContinueLiveStreamDuringAds() {
8788
- return _this.shouldContinueLiveStreamDuringAds();
8789
- },
8790
- timing: this.timing,
8791
- generateVastUrlsWithCorrelators: function generateVastUrlsWithCorrelators(base, count) {
8792
- return _this.generateVastUrls(base, count);
8793
- },
8794
- isInAdBreak: function isInAdBreak() {
8795
- return _this.adBreak.inAdBreak;
8796
- },
8797
- getPendingAdBreak: function getPendingAdBreak() {
8798
- return _this.adBreak.pendingAdBreak;
8799
- }
8800
- });
8801
7861
  this.placeholder = new PlaceholderLayer(this.video, !!this.config.debugAdTiming);
8802
7862
  this.hlsEngine = new HlsEngine(this.config, this.video, this.cueManager, this.timing, {
8803
7863
  onManifestParsed: function onManifestParsed(isLive) {
@@ -8844,13 +7904,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8844
7904
  getLiveSyncPosition: function getLiveSyncPosition() {
8845
7905
  return _this.hlsEngine.getLiveSyncPosition();
8846
7906
  },
8847
- generateVastUrls: function generateVastUrls(base, count) {
8848
- return _this.generateVastUrls(base, count);
8849
- },
8850
7907
  generatePodVastUrl: function generatePodVastUrl(base, breakDurationMs) {
8851
7908
  return _this.generatePodVastUrl(base, breakDurationMs);
8852
7909
  }
8853
- }, this.timing, this.preloadPool, this.adConfig, this.cueManager, this.placeholder);
7910
+ }, this.timing, this.adConfig, this.cueManager, this.placeholder);
8854
7911
  }
8855
7912
  _create_class(StormcloudVideoPlayer, [
8856
7913
  {
@@ -8875,12 +7932,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8875
7932
  } : {}));
8876
7933
  }
8877
7934
  },
8878
- {
8879
- key: "generateVastUrls",
8880
- value: function generateVastUrls(baseUrl, count) {
8881
- return this.adConfig.generateVastUrlsWithCorrelators(baseUrl, count, this.adPlayer, this.palNonce, this.adBreak.inAdBreak);
8882
- }
8883
- },
8884
7935
  {
8885
7936
  key: "generatePodVastUrl",
8886
7937
  value: function generatePodVastUrl(baseUrl, breakDurationMs) {
@@ -9276,11 +8327,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9276
8327
  }
9277
8328
  this.adConfig.beginNewAdPod();
9278
8329
  this.adConfig.podAssignedByPrefetch = true;
9279
- var optimizedPods = this.config.optimizedPods !== false;
9280
8330
  var breakDurationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : void 0;
9281
- var generatedUrls = optimizedPods ? [
8331
+ var generatedUrls = [
9282
8332
  this.generatePodVastUrl(baseVastUrl, breakDurationMs)
9283
- ] : this.generateVastUrls(baseVastUrl, 1);
8333
+ ];
9284
8334
  this.adBreak.pendingAdBreak = _object_spread_props(_object_spread({
9285
8335
  marker: marker
9286
8336
  }, fragmentSn !== void 0 ? {
@@ -9302,15 +8352,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9302
8352
  }, detectPayload), buildAnalyticsContext(this.config)).catch(function() {});
9303
8353
  if (this.debug) {
9304
8354
  console.log("[PREFETCH] Starting ad prefetch for upcoming ad break");
9305
- console.log("[PREFETCH] Pre-generated ".concat(generatedUrls.length, " ").concat(optimizedPods ? "pod" : "VAST", " URL(s)"));
9306
- }
9307
- if (optimizedPods) {
9308
- if (this.debug) {
9309
- console.log("[PREFETCH] Optimized pods enabled - skipping single-ad preload pool");
9310
- }
9311
- return;
8355
+ console.log("[PREFETCH] Pre-generated pod request URL");
9312
8356
  }
9313
- this.preloadPool.startPreloadPool(baseVastUrl, generatedUrls.slice(0, 1), false);
9314
8357
  }
9315
8358
  },
9316
8359
  {
@@ -9549,7 +8592,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9549
8592
  value: function destroy() {
9550
8593
  var _this_adPlayer;
9551
8594
  this.adBreak.stopContinuousFetching();
9552
- this.preloadPool.stop();
9553
8595
  this.timing.destroy();
9554
8596
  this.adBreak.clearPendingAdBreak();
9555
8597
  this.placeholder.destroy();