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
@@ -3467,21 +3467,16 @@ function applyVastMacros(baseUrl, ctx) {
3467
3467
  if (ctx.pod != null) {
3468
3468
  params.set("pod", String(ctx.pod));
3469
3469
  }
3470
- var optimizedPodMode = ctx.podMaxAds != null || ctx.podMinDurationMs != null || ctx.podMaxDurationMs != null;
3471
- if (optimizedPodMode) {
3472
- params.delete("ppos");
3473
- params.delete("lip");
3474
- if (ctx.podMinDurationMs != null) {
3475
- params.set("pmnd", String(Math.max(0, Math.round(ctx.podMinDurationMs))));
3476
- }
3477
- if (ctx.podMaxDurationMs != null) {
3478
- params.set("pmxd", String(Math.max(0, Math.round(ctx.podMaxDurationMs))));
3479
- }
3480
- if (ctx.podMaxAds != null) {
3481
- params.set("pmad", String(Math.max(1, Math.round(ctx.podMaxAds))));
3482
- }
3483
- } else if (ctx.adPosition != null) {
3484
- params.set("ppos", String(ctx.adPosition));
3470
+ params.delete("ppos");
3471
+ params.delete("lip");
3472
+ if (ctx.podMinDurationMs != null) {
3473
+ params.set("pmnd", String(Math.max(0, Math.round(ctx.podMinDurationMs))));
3474
+ }
3475
+ if (ctx.podMaxDurationMs != null) {
3476
+ params.set("pmxd", String(Math.max(0, Math.round(ctx.podMaxDurationMs))));
3477
+ }
3478
+ if (ctx.podMaxAds != null) {
3479
+ params.set("pmad", String(Math.max(1, Math.round(ctx.podMaxAds))));
3485
3480
  }
3486
3481
  var requestUrl = ctx.contentUrl || ctx.pageUrl;
3487
3482
  if (requestUrl) {
@@ -4821,9 +4816,9 @@ var AdConfigManager = /*#__PURE__*/ function() {
4821
4816
  this.consentSignals = {};
4822
4817
  this.podCounter = 0;
4823
4818
  this.podAssignedByPrefetch = false;
4824
- this.adRequestPositionInBreak = 0;
4825
4819
  this.lastHeartbeatTime = 0;
4826
4820
  this.defaultPodMaxAds = 6;
4821
+ this.defaultPodMaxDurationMs = 12e4;
4827
4822
  this.config = config;
4828
4823
  this.video = video;
4829
4824
  }
@@ -5241,48 +5236,12 @@ var AdConfigManager = /*#__PURE__*/ function() {
5241
5236
  key: "beginNewAdPod",
5242
5237
  value: function beginNewAdPod() {
5243
5238
  this.podCounter++;
5244
- this.adRequestPositionInBreak = 0;
5245
- }
5246
- },
5247
- {
5248
- key: "generateVastUrlsWithCorrelators",
5249
- value: function generateVastUrlsWithCorrelators(baseUrl, count, adPlayer, palNonce, inAdBreak) {
5250
- var urls = [];
5251
- for(var i = 0; i < count; i++){
5252
- this.adRequestPositionInBreak++;
5253
- var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
5254
- var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest);
5255
- var urlWithMacros = applyVastMacros(baseUrl, {
5256
- correlator: this.viewCorrelator,
5257
- streamCorrelator: this.streamCorrelator,
5258
- pod: this.podCounter > 0 ? this.podCounter : void 0,
5259
- adPosition: this.adRequestPositionInBreak,
5260
- isCtv: envSignals.isCtv,
5261
- contentUrl: envSignals.contentUrl,
5262
- pageUrl: !envSignals.isCtv && typeof window !== "undefined" ? window.location.href : void 0,
5263
- adWillPlayMuted: adWillPlayMuted,
5264
- adWillAutoPlay: !!this.config.autoplay,
5265
- appId: envSignals.appId,
5266
- appName: envSignals.appName,
5267
- sessionId: envSignals.sessionId,
5268
- deviceId: envSignals.deviceId,
5269
- deviceIdType: envSignals.deviceIdType,
5270
- limitAdTracking: envSignals.limitAdTracking,
5271
- deviceTypeHint: envSignals.deviceTypeHint,
5272
- adTest: this.config.adTest,
5273
- consent: this.consentSignals
5274
- });
5275
- var finalUrl = palNonce.injectNonce(urlWithMacros);
5276
- console.log("[StormcloudVideoPlayer] Resolved ad request URL (pod=".concat(this.podCounter, ", pos=").concat(this.adRequestPositionInBreak, "):"), finalUrl);
5277
- urls.push(finalUrl);
5278
- }
5279
- return urls;
5280
5239
  }
5281
5240
  },
5282
5241
  {
5283
5242
  key: "resolvePodParams",
5284
5243
  value: function resolvePodParams(breakDurationMs) {
5285
- var maxDurationMs = breakDurationMs != null && breakDurationMs > 0 ? breakDurationMs : this.config.podMaxDurationMs;
5244
+ var maxDurationMs = breakDurationMs != null && breakDurationMs > 0 ? breakDurationMs : this.config.podMaxDurationMs != null && this.config.podMaxDurationMs > 0 ? this.config.podMaxDurationMs : this.defaultPodMaxDurationMs;
5286
5245
  var maxAds = this.config.podMaxAds && this.config.podMaxAds > 0 ? this.config.podMaxAds : this.apiNumberAds && this.apiNumberAds > 0 ? this.apiNumberAds : this.defaultPodMaxAds;
5287
5246
  var minDurationMs = this.config.podExactDuration && maxDurationMs != null ? maxDurationMs : 0;
5288
5247
  return {
@@ -5935,462 +5894,6 @@ var AdTimingService = /*#__PURE__*/ function() {
5935
5894
  ]);
5936
5895
  return AdTimingService;
5937
5896
  }();
5938
- // src/player/AdPreloadPool.ts
5939
- var AdPreloadPool = /*#__PURE__*/ function() {
5940
- function AdPreloadPool(deps) {
5941
- _class_call_check(this, AdPreloadPool);
5942
- this.pool = [];
5943
- this.maxPoolSize = 2;
5944
- this.poolActive = false;
5945
- this.loopRunning = false;
5946
- this.deps = deps;
5947
- }
5948
- _create_class(AdPreloadPool, [
5949
- {
5950
- key: "active",
5951
- get: function get() {
5952
- return this.poolActive;
5953
- },
5954
- set: function set(value) {
5955
- this.poolActive = value;
5956
- }
5957
- },
5958
- {
5959
- key: "isLoopRunning",
5960
- get: function get() {
5961
- return this.loopRunning;
5962
- }
5963
- },
5964
- {
5965
- key: "startPreloadPool",
5966
- value: function startPreloadPool(baseVastUrl, initialUrls) {
5967
- var startLoopImmediately = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
5968
- if (this.poolActive) {
5969
- if (this.deps.debug) {
5970
- console.log("[PRELOAD-POOL] Already active, skipping duplicate start");
5971
- }
5972
- return;
5973
- }
5974
- this.poolActive = true;
5975
- if (this.deps.debug) {
5976
- console.log("[PRELOAD-POOL] Starting preload pool EARLY (target size: ".concat(this.maxPoolSize, ")"));
5977
- console.log("[PRELOAD-POOL] Ad break hasn't started yet, but preloading ads in advance");
5978
- }
5979
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
5980
- try {
5981
- for(var _iterator = initialUrls[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
5982
- var url = _step.value;
5983
- if (this.pool.length < this.maxPoolSize) {
5984
- this.preloadAdIntoPool(url);
5985
- }
5986
- }
5987
- } catch (err) {
5988
- _didIteratorError = true;
5989
- _iteratorError = err;
5990
- } finally{
5991
- try {
5992
- if (!_iteratorNormalCompletion && _iterator.return != null) {
5993
- _iterator.return();
5994
- }
5995
- } finally{
5996
- if (_didIteratorError) {
5997
- throw _iteratorError;
5998
- }
5999
- }
6000
- }
6001
- if (startLoopImmediately) {
6002
- this.preloadPoolLoop(baseVastUrl);
6003
- } else if (this.deps.debug) {
6004
- console.log("[PRELOAD-POOL] Pre-break mode: preloaded once, waiting for SCTE start to continue fetching");
6005
- }
6006
- }
6007
- },
6008
- {
6009
- key: "preloadAdIntoPool",
6010
- value: function preloadAdIntoPool(vastUrl) {
6011
- return _async_to_generator(function() {
6012
- var _this, timing, epoch, loadPromise;
6013
- return _ts_generator(this, function(_state) {
6014
- _this = this;
6015
- timing = this.deps.timing;
6016
- if (timing.isGamInCooldown()) {
6017
- if (this.deps.debug) {
6018
- console.log("[CIRCUIT-BREAKER] GAM in cooldown, skipping preload");
6019
- }
6020
- return [
6021
- 2
6022
- ];
6023
- }
6024
- if (this.pool.some(function(entry) {
6025
- return entry.vastUrl === vastUrl;
6026
- }) || timing.failedVastUrls.has(vastUrl) || timing.isUrlInCooldown(vastUrl)) {
6027
- return [
6028
- 2
6029
- ];
6030
- }
6031
- if (this.pool.length >= this.maxPoolSize) {
6032
- return [
6033
- 2
6034
- ];
6035
- }
6036
- if (this.deps.debug) {
6037
- console.log("[PRELOAD-POOL] Preloading ad into pool: ".concat(vastUrl));
6038
- }
6039
- epoch = timing.adBreakEpoch;
6040
- loadPromise = function() {
6041
- return _async_to_generator(function() {
6042
- var _this, hasAdError, adErrorPayload, errorListenerCleanup, _preloadAd_getLoadedAdDuration, continueLiveStreamDuringAds, preloadAd, errorListener, isNoFill, poolEntry, loadedDuration, lateErrorListener, _poolEntry_durationSeconds, error;
6043
- return _ts_generator(this, function(_state) {
6044
- switch(_state.label){
6045
- case 0:
6046
- _this = this;
6047
- hasAdError = false;
6048
- adErrorPayload = null;
6049
- errorListenerCleanup = null;
6050
- _state.label = 1;
6051
- case 1:
6052
- _state.trys.push([
6053
- 1,
6054
- 5,
6055
- ,
6056
- 6
6057
- ]);
6058
- continueLiveStreamDuringAds = this.deps.shouldContinueLiveStreamDuringAds();
6059
- preloadAd = this.deps.createAdPlayer(continueLiveStreamDuringAds);
6060
- preloadAd.initialize();
6061
- errorListener = function errorListener(payload) {
6062
- hasAdError = true;
6063
- adErrorPayload = payload;
6064
- };
6065
- preloadAd.on("ad_error", errorListener);
6066
- errorListenerCleanup = function errorListenerCleanup() {
6067
- return preloadAd.off("ad_error", errorListener);
6068
- };
6069
- return [
6070
- 4,
6071
- timing.enforceGlobalRateLimit()
6072
- ];
6073
- case 2:
6074
- _state.sent();
6075
- return [
6076
- 4,
6077
- preloadAd.requestAds(vastUrl)
6078
- ];
6079
- case 3:
6080
- _state.sent();
6081
- preloadAd.pause();
6082
- return [
6083
- 4,
6084
- new Promise(function(resolve) {
6085
- return setTimeout(resolve, 1500);
6086
- })
6087
- ];
6088
- case 4:
6089
- _state.sent();
6090
- preloadAd.pause();
6091
- if (hasAdError) {
6092
- 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;
6093
- if (errorListenerCleanup) {
6094
- errorListenerCleanup();
6095
- }
6096
- preloadAd.destroy();
6097
- timing.recordGamNoFill();
6098
- if (isNoFill) {
6099
- if (this.deps.debug) {
6100
- console.log("[PRELOAD-POOL] Ad preload returned no-fill: ".concat(vastUrl));
6101
- }
6102
- timing.temporaryFailureUrls.set(vastUrl, Date.now());
6103
- } else {
6104
- if (this.deps.debug) {
6105
- console.log("[PRELOAD-POOL] Ad preload failed with error: ".concat(vastUrl), adErrorPayload);
6106
- }
6107
- if (adErrorPayload && !timing.isTemporaryAdError(adErrorPayload)) {
6108
- timing.failedVastUrls.add(vastUrl);
6109
- } else {
6110
- timing.temporaryFailureUrls.set(vastUrl, Date.now());
6111
- }
6112
- }
6113
- return [
6114
- 2
6115
- ];
6116
- }
6117
- if (!this.poolActive || epoch !== timing.adBreakEpoch) {
6118
- if (this.deps.debug) {
6119
- console.log("[PRELOAD-POOL] Discarding preloaded ad - break ended during fetch");
6120
- }
6121
- if (errorListenerCleanup) {
6122
- errorListenerCleanup();
6123
- }
6124
- try {
6125
- preloadAd.destroy();
6126
- } catch (unused) {}
6127
- return [
6128
- 2
6129
- ];
6130
- }
6131
- poolEntry = {
6132
- vastUrl: vastUrl,
6133
- adController: preloadAd,
6134
- loadedAt: Date.now(),
6135
- isReady: true,
6136
- loadPromise: Promise.resolve()
6137
- };
6138
- loadedDuration = (_preloadAd_getLoadedAdDuration = preloadAd.getLoadedAdDuration) === null || _preloadAd_getLoadedAdDuration === void 0 ? void 0 : _preloadAd_getLoadedAdDuration.call(preloadAd);
6139
- if (loadedDuration != null && loadedDuration > 0) {
6140
- poolEntry.durationSeconds = loadedDuration;
6141
- }
6142
- lateErrorListener = function lateErrorListener(payload) {
6143
- var index = _this.pool.findIndex(function(entry) {
6144
- return entry.vastUrl === vastUrl;
6145
- });
6146
- if (index >= 0) {
6147
- _this.pool.splice(index, 1);
6148
- if (_this.deps.debug) {
6149
- console.log("[PRELOAD-POOL] Late error detected, removed from pool: ".concat(vastUrl), payload);
6150
- }
6151
- try {
6152
- preloadAd.destroy();
6153
- } catch (unused) {}
6154
- }
6155
- };
6156
- preloadAd.on("ad_error", lateErrorListener);
6157
- this.pool.push(poolEntry);
6158
- if (this.deps.debug) {
6159
- ;
6160
- 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)"));
6161
- }
6162
- if (errorListenerCleanup) {
6163
- errorListenerCleanup();
6164
- }
6165
- return [
6166
- 3,
6167
- 6
6168
- ];
6169
- case 5:
6170
- error = _state.sent();
6171
- if (errorListenerCleanup) {
6172
- errorListenerCleanup();
6173
- }
6174
- timing.recordGamNoFill();
6175
- if (this.deps.debug) {
6176
- console.warn("[PRELOAD-POOL] Failed to preload ad: ".concat(vastUrl), error);
6177
- }
6178
- if (_instanceof(error, Error) && !timing.isTemporaryAdError(error)) {
6179
- timing.failedVastUrls.add(vastUrl);
6180
- } else if (_instanceof(error, Error) && timing.isTemporaryAdError(error)) {
6181
- timing.temporaryFailureUrls.set(vastUrl, Date.now());
6182
- }
6183
- return [
6184
- 3,
6185
- 6
6186
- ];
6187
- case 6:
6188
- return [
6189
- 2
6190
- ];
6191
- }
6192
- });
6193
- }).call(_this);
6194
- }();
6195
- loadPromise.catch(function() {});
6196
- return [
6197
- 2
6198
- ];
6199
- });
6200
- }).call(this);
6201
- }
6202
- },
6203
- {
6204
- key: "preloadPoolLoop",
6205
- value: function preloadPoolLoop(baseVastUrl) {
6206
- return _async_to_generator(function() {
6207
- var epoch, newUrls, newUrl;
6208
- return _ts_generator(this, function(_state) {
6209
- switch(_state.label){
6210
- case 0:
6211
- if (this.loopRunning) {
6212
- return [
6213
- 2
6214
- ];
6215
- }
6216
- this.loopRunning = true;
6217
- epoch = this.deps.timing.adBreakEpoch;
6218
- if (this.deps.debug) {
6219
- console.log("[PRELOAD-POOL] Starting continuous preload loop");
6220
- }
6221
- _state.label = 1;
6222
- case 1:
6223
- if (!(this.poolActive && epoch === this.deps.timing.adBreakEpoch)) return [
6224
- 3,
6225
- 10
6226
- ];
6227
- if (this.deps.timing.isGamInCooldown()) {
6228
- if (this.deps.debug) {
6229
- console.log("[CIRCUIT-BREAKER] GAM in cooldown, stopping preload pool loop");
6230
- }
6231
- return [
6232
- 3,
6233
- 10
6234
- ];
6235
- }
6236
- if (!(!this.deps.isInAdBreak() && this.pool.length >= this.maxPoolSize)) return [
6237
- 3,
6238
- 3
6239
- ];
6240
- return [
6241
- 4,
6242
- new Promise(function(resolve) {
6243
- return setTimeout(resolve, 2e3);
6244
- })
6245
- ];
6246
- case 2:
6247
- _state.sent();
6248
- return [
6249
- 3,
6250
- 1
6251
- ];
6252
- case 3:
6253
- if (!this.deps.isInAdBreak() && this.deps.getPendingAdBreak() === null) {
6254
- if (this.deps.debug) {
6255
- console.log("[PRELOAD-POOL] Ad break cancelled, stopping preload pool");
6256
- }
6257
- return [
6258
- 3,
6259
- 10
6260
- ];
6261
- }
6262
- _state.label = 4;
6263
- case 4:
6264
- if (!(this.pool.length < this.maxPoolSize)) return [
6265
- 3,
6266
- 8
6267
- ];
6268
- if (!this.poolActive || epoch !== this.deps.timing.adBreakEpoch || this.deps.timing.isGamInCooldown()) {
6269
- return [
6270
- 3,
6271
- 8
6272
- ];
6273
- }
6274
- if (this.deps.isInAdBreak() && !this.deps.timing.hasTimeToStartAnotherAd()) {
6275
- if (this.deps.debug) {
6276
- console.log("[PRELOAD-POOL] Not enough ad break time left, stopping preload");
6277
- }
6278
- return [
6279
- 3,
6280
- 8
6281
- ];
6282
- }
6283
- newUrls = this.deps.generateVastUrlsWithCorrelators(baseVastUrl, 1);
6284
- newUrl = newUrls[0];
6285
- if (!(newUrl && !this.deps.timing.failedVastUrls.has(newUrl) && !this.deps.timing.isUrlInCooldown(newUrl))) return [
6286
- 3,
6287
- 6
6288
- ];
6289
- return [
6290
- 4,
6291
- this.preloadAdIntoPool(newUrl)
6292
- ];
6293
- case 5:
6294
- _state.sent();
6295
- _state.label = 6;
6296
- case 6:
6297
- return [
6298
- 4,
6299
- new Promise(function(resolve) {
6300
- return setTimeout(resolve, 1e3);
6301
- })
6302
- ];
6303
- case 7:
6304
- _state.sent();
6305
- return [
6306
- 3,
6307
- 4
6308
- ];
6309
- case 8:
6310
- return [
6311
- 4,
6312
- new Promise(function(resolve) {
6313
- return setTimeout(resolve, 2e3);
6314
- })
6315
- ];
6316
- case 9:
6317
- _state.sent();
6318
- return [
6319
- 3,
6320
- 1
6321
- ];
6322
- case 10:
6323
- this.loopRunning = false;
6324
- if (this.deps.debug) {
6325
- console.log("[PRELOAD-POOL] Preload loop ended");
6326
- }
6327
- return [
6328
- 2
6329
- ];
6330
- }
6331
- });
6332
- }).call(this);
6333
- }
6334
- },
6335
- {
6336
- key: "getPreloadedAd",
6337
- value: function getPreloadedAd() {
6338
- if (this.pool.length === 0) {
6339
- return null;
6340
- }
6341
- var entry = this.pool.shift();
6342
- if (!entry || !entry.isReady) {
6343
- return null;
6344
- }
6345
- if (this.deps.debug) {
6346
- console.log("[PRELOAD-POOL] Using preloaded ad from pool (".concat(this.pool.length, " remaining)"));
6347
- }
6348
- return {
6349
- vastUrl: entry.vastUrl,
6350
- adController: entry.adController
6351
- };
6352
- }
6353
- },
6354
- {
6355
- key: "stop",
6356
- value: function stop() {
6357
- this.poolActive = false;
6358
- this.loopRunning = false;
6359
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6360
- try {
6361
- for(var _iterator = this.pool[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6362
- var entry = _step.value;
6363
- try {
6364
- entry.adController.destroy();
6365
- } catch (error) {
6366
- if (this.deps.debug) {
6367
- console.warn("[PRELOAD-POOL] Error destroying preloaded controller:", error);
6368
- }
6369
- }
6370
- }
6371
- } catch (err) {
6372
- _didIteratorError = true;
6373
- _iteratorError = err;
6374
- } finally{
6375
- try {
6376
- if (!_iteratorNormalCompletion && _iterator.return != null) {
6377
- _iterator.return();
6378
- }
6379
- } finally{
6380
- if (_didIteratorError) {
6381
- throw _iteratorError;
6382
- }
6383
- }
6384
- }
6385
- this.pool = [];
6386
- if (this.deps.debug) {
6387
- console.log("[PRELOAD-POOL] Preload pool stopped and cleaned up");
6388
- }
6389
- }
6390
- }
6391
- ]);
6392
- return AdPreloadPool;
6393
- }();
6394
5897
  // src/player/PlaceholderLayer.ts
6395
5898
  var PlaceholderLayer = /*#__PURE__*/ function() {
6396
5899
  function PlaceholderLayer(video, debug) {
@@ -7112,7 +6615,7 @@ function resizePlayer(video, adPlayer, debug) {
7112
6615
  }
7113
6616
  // src/player/AdBreakOrchestrator.ts
7114
6617
  var AdBreakOrchestrator = /*#__PURE__*/ function() {
7115
- function AdBreakOrchestrator(host, timing, preloadPool, adConfig, cueManager, placeholder) {
6618
+ function AdBreakOrchestrator(host, timing, adConfig, cueManager, placeholder) {
7116
6619
  _class_call_check(this, AdBreakOrchestrator);
7117
6620
  this.inAdBreak = false;
7118
6621
  this.showAds = false;
@@ -7126,7 +6629,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7126
6629
  this.pendingAdBreak = null;
7127
6630
  this.host = host;
7128
6631
  this.timing = timing;
7129
- this.preloadPool = preloadPool;
7130
6632
  this.adConfig = adConfig;
7131
6633
  this.cueManager = cueManager;
7132
6634
  this.placeholder = placeholder;
@@ -7145,12 +6647,19 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7145
6647
  }
7146
6648
  },
7147
6649
  {
7148
- key: "optimizedPodsEnabled",
7149
- get: // ───────────────────────────────────────────────────────────────
6650
+ // ───────────────────────────────────────────────────────────────
7150
6651
  // IMA event listeners
7151
6652
  // ───────────────────────────────────────────────────────────────
7152
- function get() {
7153
- return this.host.config.optimizedPods !== false;
6653
+ /**
6654
+ * Produces the next pod ad-request URL for the current break. Every request
6655
+ * (initial and continuous-fetch top-up) carries pod macros (pmad/pmnd/pmxd,
6656
+ * no ppos); pmxd tracks the remaining break time so top-up pods only ask for
6657
+ * what still fits.
6658
+ */ key: "nextAdRequestUrl",
6659
+ value: function nextAdRequestUrl(baseVastUrl) {
6660
+ var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
6661
+ var breakDurationMs = remaining > 0 ? remaining : void 0;
6662
+ return this.host.generatePodVastUrl(baseVastUrl, breakDurationMs);
7154
6663
  }
7155
6664
  },
7156
6665
  {
@@ -7322,7 +6831,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7322
6831
  // ───────────────────────────────────────────────────────────────
7323
6832
  function handleAdStart(_marker) {
7324
6833
  return _async_to_generator(function() {
7325
- 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;
6834
+ var scheduled, tags, baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, podPlayed;
7326
6835
  return _ts_generator(this, function(_state) {
7327
6836
  switch(_state.label){
7328
6837
  case 0:
@@ -7369,292 +6878,29 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7369
6878
  if (this.timing.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
7370
6879
  this.timing.expectedAdBreakDurationMs = adBreakDurationMs;
7371
6880
  }
7372
- if (!this.optimizedPodsEnabled) return [
7373
- 3,
7374
- 2
7375
- ];
7376
6881
  return [
7377
6882
  4,
7378
6883
  this.startOptimizedPod(baseVastUrl, adBreakDurationMs, currentMuted, currentVolume)
7379
6884
  ];
7380
6885
  case 1:
7381
6886
  podPlayed = _state.sent();
7382
- if (podPlayed) {
7383
- return [
7384
- 2
7385
- ];
7386
- }
6887
+ if (!!podPlayed) return [
6888
+ 3,
6889
+ 3
6890
+ ];
7387
6891
  if (this.debug) {
7388
- console.log("[POD] Optimized pod unavailable, falling back to sequential single-ad path");
6892
+ console.log("[POD] Initial pod request did not fill; attempting top-up pod request");
7389
6893
  }
7390
- _state.label = 2;
6894
+ this.continuousFetchingActive = true;
6895
+ this.startContinuousFetching(baseVastUrl);
6896
+ return [
6897
+ 4,
6898
+ this.tryNextAvailableAdWithRateLimit()
6899
+ ];
7391
6900
  case 2:
7392
- usePreloadedAd = false;
7393
- preloaded = this.preloadPool.getPreloadedAd();
7394
- if (preloaded) {
7395
- firstAdUrl = preloaded.vastUrl;
7396
- preloadedController = preloaded.adController;
7397
- usePreloadedAd = true;
7398
- sendAdLoadedTracking(this.host.config.licenseKey, {
7399
- source: "hls",
7400
- vastUrl: firstAdUrl,
7401
- timestamp: /* @__PURE__ */ new Date().toISOString()
7402
- }, this.analyticsContext).catch(function() {});
7403
- if (this.debug) {
7404
- console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool (preloaded in advance, ready immediately!)");
7405
- }
7406
- } else if (this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0) {
7407
- this.adRequestQueue = _to_consumable_array(this.pendingAdBreak.vastUrls);
7408
- firstAdUrl = this.adRequestQueue.shift();
7409
- if (this.debug) {
7410
- console.log("[CONTINUOUS-FETCH] Pool empty, using prefetched URLs (".concat(this.adRequestQueue.length + 1, " available)"));
7411
- }
7412
- this.clearPendingAdBreak();
7413
- } else {
7414
- if (this.debug) {
7415
- console.log("[CONTINUOUS-FETCH] Generating new ad URLs...");
7416
- }
7417
- firstAdUrlArray = this.host.generateVastUrls(baseVastUrl, 1);
7418
- firstAdUrl = firstAdUrlArray[0];
7419
- this.adRequestQueue = [];
7420
- }
7421
- if (!firstAdUrl) {
7422
- if (this.debug) {
7423
- console.warn("[CONTINUOUS-FETCH] Failed to get first ad URL");
7424
- }
7425
- this.handleAdPodComplete();
7426
- return [
7427
- 2
7428
- ];
7429
- }
7430
- if (this.debug) {
7431
- console.log("[CONTINUOUS-FETCH] First VAST URL:", firstAdUrl);
7432
- }
6901
+ _state.sent();
7433
6902
  _state.label = 3;
7434
6903
  case 3:
7435
- _state.trys.push([
7436
- 3,
7437
- 14,
7438
- ,
7439
- 22
7440
- ]);
7441
- if (!(usePreloadedAd && preloadedController)) return [
7442
- 3,
7443
- 7
7444
- ];
7445
- if (!!this.timing.ensureLoadedAdFitsBudget(preloadedController)) return [
7446
- 3,
7447
- 5
7448
- ];
7449
- this.timing.rejectLoadedAdForDuration(preloadedController);
7450
- this.startContinuousFetching(baseVastUrl);
7451
- return [
7452
- 4,
7453
- this.tryNextAvailableAdWithRateLimit()
7454
- ];
7455
- case 4:
7456
- _state.sent();
7457
- return [
7458
- 2
7459
- ];
7460
- case 5:
7461
- adPlayer = this.host.getAdPlayer();
7462
- preservedMuted = adPlayer.getOriginalMutedState();
7463
- preservedVolume = adPlayer.getOriginalVolume();
7464
- adPlayer.destroy();
7465
- this.host.video.muted = true;
7466
- this.host.setAdPlayer(preloadedController);
7467
- preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
7468
- this.attachImaEventListeners();
7469
- if (this.debug) {
7470
- console.log("[CONTINUOUS-FETCH] Using preloaded ad, resuming and starting playback immediately (no request delay!)");
7471
- }
7472
- preloadedController.resume();
7473
- this.timing.consecutiveFailures = 0;
7474
- this.startContinuousFetching(baseVastUrl);
7475
- if (!this.preloadPool.active) {
7476
- this.preloadPool.active = true;
7477
- }
7478
- if (!this.preloadPool.isLoopRunning) {
7479
- this.preloadPool.preloadPoolLoop(baseVastUrl);
7480
- }
7481
- return [
7482
- 4,
7483
- preloadedController.play()
7484
- ];
7485
- case 6:
7486
- _state.sent();
7487
- this.timing.markAdStarted();
7488
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7489
- this.timing.scheduleAdStopAtBreakBoundary();
7490
- }
7491
- adVolume = currentMuted ? 0 : currentVolume;
7492
- preloadedController.setAdVolume(adVolume);
7493
- return [
7494
- 3,
7495
- 13
7496
- ];
7497
- case 7:
7498
- adPlayer1 = this.host.getAdPlayer();
7499
- return [
7500
- 4,
7501
- this.timing.enforceGlobalRateLimit()
7502
- ];
7503
- case 8:
7504
- _state.sent();
7505
- this.timing.lastAdRequestTime = Date.now();
7506
- return [
7507
- 4,
7508
- adPlayer1.requestAds(firstAdUrl)
7509
- ];
7510
- case 9:
7511
- _state.sent();
7512
- sendAdLoadedTracking(this.host.config.licenseKey, {
7513
- source: "hls",
7514
- vastUrl: firstAdUrl,
7515
- timestamp: /* @__PURE__ */ new Date().toISOString()
7516
- }, this.analyticsContext).catch(function() {});
7517
- if (this.debug) {
7518
- console.log("[CONTINUOUS-FETCH] First ad request successful, starting playback");
7519
- }
7520
- if (!!this.timing.ensureLoadedAdFitsBudget(adPlayer1)) return [
7521
- 3,
7522
- 11
7523
- ];
7524
- this.timing.rejectLoadedAdForDuration(adPlayer1);
7525
- this.recreateAdController();
7526
- this.startContinuousFetching(baseVastUrl);
7527
- return [
7528
- 4,
7529
- this.tryNextAvailableAdWithRateLimit()
7530
- ];
7531
- case 10:
7532
- _state.sent();
7533
- return [
7534
- 2
7535
- ];
7536
- case 11:
7537
- this.timing.consecutiveFailures = 0;
7538
- this.startContinuousFetching(baseVastUrl);
7539
- if (!this.preloadPool.active) {
7540
- this.preloadPool.startPreloadPool(baseVastUrl, []);
7541
- }
7542
- return [
7543
- 4,
7544
- adPlayer1.play()
7545
- ];
7546
- case 12:
7547
- _state.sent();
7548
- this.timing.markAdStarted();
7549
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7550
- this.timing.scheduleAdStopAtBreakBoundary();
7551
- }
7552
- adVolume1 = currentMuted ? 0 : currentVolume;
7553
- adPlayer1.setAdVolume(adVolume1);
7554
- _state.label = 13;
7555
- case 13:
7556
- return [
7557
- 3,
7558
- 22
7559
- ];
7560
- case 14:
7561
- error = _state.sent();
7562
- if (this.debug) {
7563
- console.warn("[CONTINUOUS-FETCH] First ad request failed:", error);
7564
- }
7565
- if (!!usePreloadedAd) return [
7566
- 3,
7567
- 20
7568
- ];
7569
- fallbackPreloaded = this.preloadPool.getPreloadedAd();
7570
- if (!fallbackPreloaded) return [
7571
- 3,
7572
- 20
7573
- ];
7574
- if (this.debug) {
7575
- console.log("[CONTINUOUS-FETCH] First ad failed, using preloaded fallback");
7576
- }
7577
- _state.label = 15;
7578
- case 15:
7579
- _state.trys.push([
7580
- 15,
7581
- 19,
7582
- ,
7583
- 20
7584
- ]);
7585
- if (!!this.timing.ensureLoadedAdFitsBudget(fallbackPreloaded.adController)) return [
7586
- 3,
7587
- 17
7588
- ];
7589
- this.timing.rejectLoadedAdForDuration(fallbackPreloaded.adController);
7590
- this.startContinuousFetching(baseVastUrl);
7591
- return [
7592
- 4,
7593
- this.tryNextAvailableAdWithRateLimit()
7594
- ];
7595
- case 16:
7596
- _state.sent();
7597
- return [
7598
- 2
7599
- ];
7600
- case 17:
7601
- this.swapToPreloadedAdPlayer(fallbackPreloaded.adController);
7602
- this.timing.consecutiveFailures = 0;
7603
- this.startContinuousFetching(baseVastUrl);
7604
- if (!this.preloadPool.active) {
7605
- this.preloadPool.active = true;
7606
- this.preloadPool.preloadPoolLoop(baseVastUrl);
7607
- }
7608
- ap = this.host.getAdPlayer();
7609
- return [
7610
- 4,
7611
- ap.play()
7612
- ];
7613
- case 18:
7614
- _state.sent();
7615
- this.timing.markAdStarted();
7616
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
7617
- this.timing.scheduleAdStopAtBreakBoundary();
7618
- }
7619
- adVolume2 = currentMuted ? 0 : currentVolume;
7620
- ap.setAdVolume(adVolume2);
7621
- return [
7622
- 2
7623
- ];
7624
- case 19:
7625
- fallbackError = _state.sent();
7626
- if (this.debug) {
7627
- console.warn("[CONTINUOUS-FETCH] Preloaded fallback also failed:", fallbackError);
7628
- }
7629
- return [
7630
- 3,
7631
- 20
7632
- ];
7633
- case 20:
7634
- if (this.timing.isTemporaryAdError(error)) {
7635
- this.timing.temporaryFailureUrls.set(firstAdUrl, Date.now());
7636
- if (this.debug) {
7637
- console.log("[CONTINUOUS-FETCH] First ad had temporary error (no-fill) - will try alternatives");
7638
- }
7639
- } else {
7640
- this.timing.failedVastUrls.add(firstAdUrl);
7641
- if (this.debug) {
7642
- console.log("[CONTINUOUS-FETCH] First ad had permanent error - URL blacklisted");
7643
- }
7644
- }
7645
- this.timing.consecutiveFailures++;
7646
- this.startContinuousFetching(baseVastUrl);
7647
- return [
7648
- 4,
7649
- this.tryNextAvailableAdWithRateLimit()
7650
- ];
7651
- case 21:
7652
- _state.sent();
7653
- return [
7654
- 3,
7655
- 22
7656
- ];
7657
- case 22:
7658
6904
  return [
7659
6905
  2
7660
6906
  ];
@@ -7728,7 +6974,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7728
6974
  ];
7729
6975
  }
7730
6976
  if (this.debug) {
7731
- 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"));
6977
+ 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"));
7732
6978
  }
7733
6979
  sendAdLoadedTracking(this.host.config.licenseKey, {
7734
6980
  source: "hls",
@@ -7748,13 +6994,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7748
6994
  }
7749
6995
  adPlayer.setAdVolume(currentMuted ? 0 : currentVolume);
7750
6996
  this.timing.consecutiveFailures = 0;
7751
- if (podCount === 1) {
7752
- this.continuousFetchingActive = true;
7753
- this.startContinuousFetching(baseVastUrl);
7754
- if (!this.preloadPool.active) {
7755
- this.preloadPool.startPreloadPool(baseVastUrl, []);
7756
- }
7757
- }
6997
+ this.continuousFetchingActive = true;
6998
+ this.startContinuousFetching(baseVastUrl);
7758
6999
  return [
7759
7000
  2,
7760
7001
  true
@@ -7787,20 +7028,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7787
7028
  }).call(this);
7788
7029
  }
7789
7030
  },
7790
- {
7791
- key: "swapToPreloadedAdPlayer",
7792
- value: function swapToPreloadedAdPlayer(preloadedController) {
7793
- var adPlayer = this.host.getAdPlayer();
7794
- var preservedMuted = adPlayer.getOriginalMutedState();
7795
- var preservedVolume = adPlayer.getOriginalVolume();
7796
- adPlayer.destroy();
7797
- this.host.video.muted = true;
7798
- this.host.setAdPlayer(preloadedController);
7799
- this.attachImaEventListeners();
7800
- preloadedController.updateOriginalMutedState(preservedMuted, preservedVolume);
7801
- preloadedController.resume();
7802
- }
7803
- },
7804
7031
  {
7805
7032
  // ───────────────────────────────────────────────────────────────
7806
7033
  // Continuous fetching
@@ -7894,7 +7121,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7894
7121
  "continue"
7895
7122
  ];
7896
7123
  case 2:
7897
- newAdUrl = _this.host.generateVastUrls(baseVastUrl, 1)[0];
7124
+ newAdUrl = _this.nextAdRequestUrl(baseVastUrl);
7898
7125
  if (!(!newAdUrl || _this.timing.failedVastUrls.has(newAdUrl) || _this.timing.isUrlInCooldown(newAdUrl))) return [
7899
7126
  3,
7900
7127
  4
@@ -8051,7 +7278,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8051
7278
  value: function tryNextAvailableAd() {
8052
7279
  var retryCount = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
8053
7280
  return _async_to_generator(function() {
8054
- var remaining, preloaded, ap, error, nextAdUrl, error1, errorMessage, maxRetries;
7281
+ var remaining, nextAdUrl, error, errorMessage, maxRetries;
8055
7282
  return _ts_generator(this, function(_state) {
8056
7283
  switch(_state.label){
8057
7284
  case 0:
@@ -8089,132 +7316,71 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8089
7316
  ];
8090
7317
  }
8091
7318
  this.timing.cleanupTemporaryFailures();
8092
- preloaded = this.preloadPool.getPreloadedAd();
8093
- if (!preloaded) return [
8094
- 3,
8095
- 6
8096
- ];
8097
- if (this.debug) {
8098
- console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool");
8099
- }
8100
- sendAdLoadedTracking(this.host.config.licenseKey, {
8101
- source: "hls",
8102
- vastUrl: preloaded.vastUrl,
8103
- timestamp: /* @__PURE__ */ new Date().toISOString()
8104
- }, this.analyticsContext).catch(function() {});
8105
7319
  _state.label = 1;
8106
7320
  case 1:
8107
- _state.trys.push([
8108
- 1,
8109
- 5,
8110
- ,
8111
- 6
8112
- ]);
8113
- if (!!this.timing.ensureLoadedAdFitsBudget(preloaded.adController)) return [
8114
- 3,
8115
- 3
8116
- ];
8117
- this.timing.rejectLoadedAdForDuration(preloaded.adController);
8118
- return [
8119
- 4,
8120
- this.tryNextAvailableAdWithRateLimit()
8121
- ];
8122
- case 2:
8123
- _state.sent();
8124
- return [
8125
- 2
8126
- ];
8127
- case 3:
8128
- this.swapToPreloadedAdPlayer(preloaded.adController);
8129
- ap = this.host.getAdPlayer();
8130
- return [
8131
- 4,
8132
- ap.play()
8133
- ];
8134
- case 4:
8135
- _state.sent();
8136
- this.timing.markAdStarted();
8137
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
8138
- this.timing.scheduleAdStopAtBreakBoundary();
8139
- }
8140
- ap.setAdVolume(getAdAudioVolume(ap));
8141
- this.timing.consecutiveFailures = 0;
8142
- return [
8143
- 2
8144
- ];
8145
- case 5:
8146
- error = _state.sent();
8147
- if (this.debug) {
8148
- console.warn("[CONTINUOUS-FETCH] Preloaded ad failed to play:", error);
8149
- }
8150
- return [
8151
- 3,
8152
- 6
8153
- ];
8154
- case 6:
8155
7321
  if (!(this.adRequestQueue.length > 0)) return [
8156
7322
  3,
8157
- 14
7323
+ 9
8158
7324
  ];
8159
7325
  nextAdUrl = this.adRequestQueue.shift();
8160
7326
  if (!nextAdUrl) return [
8161
7327
  3,
8162
- 6
7328
+ 1
8163
7329
  ];
8164
7330
  if (this.timing.failedVastUrls.has(nextAdUrl)) {
8165
7331
  if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping permanently-failed URL, trying next...");
8166
7332
  return [
8167
7333
  3,
8168
- 6
7334
+ 1
8169
7335
  ];
8170
7336
  }
8171
7337
  if (this.timing.isUrlInCooldown(nextAdUrl)) {
8172
7338
  if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping URL in cooldown (recent no-fill), trying next...");
8173
7339
  return [
8174
7340
  3,
8175
- 6
7341
+ 1
8176
7342
  ];
8177
7343
  }
8178
7344
  if (this.debug) {
8179
7345
  console.log("[CONTINUOUS-FETCH] Requesting next ad via HLS ad player (".concat(this.timing.currentAdIndex + 1, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
8180
7346
  }
8181
- _state.label = 7;
8182
- case 7:
7347
+ _state.label = 2;
7348
+ case 2:
8183
7349
  _state.trys.push([
8184
- 7,
8185
- 9,
7350
+ 2,
7351
+ 4,
8186
7352
  ,
8187
- 13
7353
+ 8
8188
7354
  ]);
8189
7355
  return [
8190
7356
  4,
8191
7357
  this.playSingleAd(nextAdUrl)
8192
7358
  ];
8193
- case 8:
7359
+ case 3:
8194
7360
  _state.sent();
8195
7361
  this.timing.consecutiveFailures = 0;
8196
7362
  return [
8197
7363
  3,
8198
- 13
7364
+ 8
8199
7365
  ];
8200
- case 9:
8201
- error1 = _state.sent();
8202
- errorMessage = error1.message;
7366
+ case 4:
7367
+ error = _state.sent();
7368
+ errorMessage = error.message;
8203
7369
  if (this.debug) console.log("[CONTINUOUS-FETCH] Ad request failed:", errorMessage);
8204
7370
  if (!errorMessage.includes("ad_duration_exceeds_budget")) return [
8205
7371
  3,
8206
- 11
7372
+ 6
8207
7373
  ];
8208
7374
  return [
8209
7375
  4,
8210
7376
  this.tryNextAvailableAdWithRateLimit()
8211
7377
  ];
8212
- case 10:
7378
+ case 5:
8213
7379
  _state.sent();
8214
7380
  return [
8215
7381
  2
8216
7382
  ];
8217
- case 11:
7383
+ case 6:
8218
7384
  if (!errorMessage.includes("permanently failed") && !errorMessage.includes("in cooldown")) {
8219
7385
  this.timing.consecutiveFailures++;
8220
7386
  }
@@ -8222,21 +7388,21 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8222
7388
  4,
8223
7389
  this.tryNextAvailableAdWithRateLimit()
8224
7390
  ];
8225
- case 12:
7391
+ case 7:
8226
7392
  _state.sent();
8227
7393
  return [
8228
7394
  3,
8229
- 13
7395
+ 8
8230
7396
  ];
8231
- case 13:
7397
+ case 8:
8232
7398
  return [
8233
7399
  2
8234
7400
  ];
8235
- case 14:
7401
+ case 9:
8236
7402
  maxRetries = 3;
8237
7403
  if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
8238
7404
  3,
8239
- 17
7405
+ 12
8240
7406
  ];
8241
7407
  if (this.debug) {
8242
7408
  console.log("[CONTINUOUS-FETCH] Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
@@ -8247,18 +7413,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8247
7413
  return setTimeout(resolve, 500);
8248
7414
  })
8249
7415
  ];
8250
- case 15:
7416
+ case 10:
8251
7417
  _state.sent();
8252
7418
  return [
8253
7419
  4,
8254
7420
  this.tryNextAvailableAd(retryCount + 1)
8255
7421
  ];
8256
- case 16:
7422
+ case 11:
8257
7423
  _state.sent();
8258
7424
  return [
8259
7425
  2
8260
7426
  ];
8261
- case 17:
7427
+ case 12:
8262
7428
  if (!this.isShowingPlaceholder && remaining > 1e3) {
8263
7429
  this.showPlaceholderAndWaitForAds();
8264
7430
  } else {
@@ -8280,7 +7446,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8280
7446
  // ───────────────────────────────────────────────────────────────
8281
7447
  function playSingleAd(vastTagUrl) {
8282
7448
  return _async_to_generator(function() {
8283
- var adPlayer, requestToken, ap, playError, preloadedFallback, fbAp, fallbackError, error, errorMessage, preloadedFallback1, fbAp1, fallbackError1;
7449
+ var adPlayer, requestToken, ap, playError, error, errorMessage;
8284
7450
  return _ts_generator(this, function(_state) {
8285
7451
  switch(_state.label){
8286
7452
  case 0:
@@ -8312,9 +7478,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8312
7478
  case 1:
8313
7479
  _state.trys.push([
8314
7480
  1,
8315
- 12,
7481
+ 8,
8316
7482
  ,
8317
- 17
7483
+ 9
8318
7484
  ]);
8319
7485
  return [
8320
7486
  4,
@@ -8350,7 +7516,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8350
7516
  4,
8351
7517
  6,
8352
7518
  ,
8353
- 11
7519
+ 7
8354
7520
  ]);
8355
7521
  this.timing.startAdFailsafeTimer(requestToken);
8356
7522
  return [
@@ -8368,55 +7534,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8368
7534
  this.timing.temporaryFailureUrls.delete(vastTagUrl);
8369
7535
  return [
8370
7536
  3,
8371
- 11
7537
+ 7
8372
7538
  ];
8373
7539
  case 6:
8374
7540
  playError = _state.sent();
8375
7541
  if (this.debug) console.error("[AD-ERROR] Failed to play ad:", playError);
8376
- preloadedFallback = this.preloadPool.getPreloadedAd();
8377
- if (!preloadedFallback) return [
8378
- 3,
8379
- 10
8380
- ];
8381
- if (this.debug) console.log("[AD-ERROR] Play failed, trying preloaded fallback ad");
8382
- _state.label = 7;
8383
- case 7:
8384
- _state.trys.push([
8385
- 7,
8386
- 9,
8387
- ,
8388
- 10
8389
- ]);
8390
- if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback.adController)) {
8391
- this.timing.rejectLoadedAdForDuration(preloadedFallback.adController);
8392
- throw playError;
8393
- }
8394
- this.timing.clearAdFailsafeTimer();
8395
- this.swapToPreloadedAdPlayer(preloadedFallback.adController);
8396
- this.timing.consecutiveFailures = 0;
8397
- fbAp = this.host.getAdPlayer();
8398
- return [
8399
- 4,
8400
- fbAp.play()
8401
- ];
8402
- case 8:
8403
- _state.sent();
8404
- this.timing.markAdStarted();
8405
- if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
8406
- this.timing.scheduleAdStopAtBreakBoundary();
8407
- }
8408
- fbAp.setAdVolume(getAdAudioVolume(fbAp));
8409
- return [
8410
- 2
8411
- ];
8412
- case 9:
8413
- fallbackError = _state.sent();
8414
- if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError);
8415
- return [
8416
- 3,
8417
- 10
8418
- ];
8419
- case 10:
8420
7542
  if (this.timing.isTemporaryAdError(playError)) {
8421
7543
  this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
8422
7544
  if (this.debug) console.log("[AD-ERROR] Temporary play error - URL can be retried after cooldown");
@@ -8429,57 +7551,15 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8429
7551
  this.timing.activeAdRequestToken = null;
8430
7552
  }
8431
7553
  throw playError;
8432
- case 11:
7554
+ case 7:
8433
7555
  return [
8434
7556
  3,
8435
- 17
7557
+ 9
8436
7558
  ];
8437
- case 12:
7559
+ case 8:
8438
7560
  error = _state.sent();
8439
7561
  errorMessage = (error === null || error === void 0 ? void 0 : error.message) || "";
8440
7562
  if (this.debug) console.error("[AD-ERROR] Ad request failed:", errorMessage);
8441
- preloadedFallback1 = this.preloadPool.getPreloadedAd();
8442
- if (!preloadedFallback1) return [
8443
- 3,
8444
- 16
8445
- ];
8446
- if (this.debug) console.log("[AD-ERROR] Request failed, trying preloaded fallback ad");
8447
- _state.label = 13;
8448
- case 13:
8449
- _state.trys.push([
8450
- 13,
8451
- 15,
8452
- ,
8453
- 16
8454
- ]);
8455
- if (!this.timing.ensureLoadedAdFitsBudget(preloadedFallback1.adController)) {
8456
- this.timing.rejectLoadedAdForDuration(preloadedFallback1.adController);
8457
- throw error;
8458
- }
8459
- this.timing.clearAdRequestWatchdog();
8460
- this.timing.clearAdFailsafeTimer();
8461
- this.swapToPreloadedAdPlayer(preloadedFallback1.adController);
8462
- this.timing.consecutiveFailures = 0;
8463
- fbAp1 = this.host.getAdPlayer();
8464
- return [
8465
- 4,
8466
- fbAp1.play()
8467
- ];
8468
- case 14:
8469
- _state.sent();
8470
- this.timing.markAdStarted();
8471
- fbAp1.setAdVolume(getAdAudioVolume(fbAp1));
8472
- return [
8473
- 2
8474
- ];
8475
- case 15:
8476
- fallbackError1 = _state.sent();
8477
- if (this.debug) console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError1);
8478
- return [
8479
- 3,
8480
- 16
8481
- ];
8482
- case 16:
8483
7563
  if (this.timing.isTemporaryAdError(error)) {
8484
7564
  this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
8485
7565
  if (this.debug) console.log("[AD-ERROR] Temporary error (no-fill/timeout) - URL can be retried after cooldown");
@@ -8493,7 +7573,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8493
7573
  this.timing.activeAdRequestToken = null;
8494
7574
  }
8495
7575
  throw error;
8496
- case 17:
7576
+ case 9:
8497
7577
  return [
8498
7578
  2
8499
7579
  ];
@@ -8683,7 +7763,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
8683
7763
  }
8684
7764
  this.timing.resetForBreakEnd();
8685
7765
  this.stopContinuousFetching();
8686
- this.preloadPool.stop();
8687
7766
  this.clearPendingAdBreak();
8688
7767
  if (this.isShowingPlaceholder) {
8689
7768
  this.host.getAdPlayer().hidePlaceholder();
@@ -8793,25 +7872,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8793
7872
  return _this.adBreak.handleAdFailure();
8794
7873
  }
8795
7874
  });
8796
- this.preloadPool = new AdPreloadPool({
8797
- debug: !!this.config.debugAdTiming,
8798
- createAdPlayer: function createAdPlayer(c) {
8799
- return _this.createAdPlayer(c);
8800
- },
8801
- shouldContinueLiveStreamDuringAds: function shouldContinueLiveStreamDuringAds() {
8802
- return _this.shouldContinueLiveStreamDuringAds();
8803
- },
8804
- timing: this.timing,
8805
- generateVastUrlsWithCorrelators: function generateVastUrlsWithCorrelators(base, count) {
8806
- return _this.generateVastUrls(base, count);
8807
- },
8808
- isInAdBreak: function isInAdBreak() {
8809
- return _this.adBreak.inAdBreak;
8810
- },
8811
- getPendingAdBreak: function getPendingAdBreak() {
8812
- return _this.adBreak.pendingAdBreak;
8813
- }
8814
- });
8815
7875
  this.placeholder = new PlaceholderLayer(this.video, !!this.config.debugAdTiming);
8816
7876
  this.hlsEngine = new HlsEngine(this.config, this.video, this.cueManager, this.timing, {
8817
7877
  onManifestParsed: function onManifestParsed(isLive) {
@@ -8858,13 +7918,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8858
7918
  getLiveSyncPosition: function getLiveSyncPosition() {
8859
7919
  return _this.hlsEngine.getLiveSyncPosition();
8860
7920
  },
8861
- generateVastUrls: function generateVastUrls(base, count) {
8862
- return _this.generateVastUrls(base, count);
8863
- },
8864
7921
  generatePodVastUrl: function generatePodVastUrl(base, breakDurationMs) {
8865
7922
  return _this.generatePodVastUrl(base, breakDurationMs);
8866
7923
  }
8867
- }, this.timing, this.preloadPool, this.adConfig, this.cueManager, this.placeholder);
7924
+ }, this.timing, this.adConfig, this.cueManager, this.placeholder);
8868
7925
  }
8869
7926
  _create_class(StormcloudVideoPlayer, [
8870
7927
  {
@@ -8889,12 +7946,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8889
7946
  } : {}));
8890
7947
  }
8891
7948
  },
8892
- {
8893
- key: "generateVastUrls",
8894
- value: function generateVastUrls(baseUrl, count) {
8895
- return this.adConfig.generateVastUrlsWithCorrelators(baseUrl, count, this.adPlayer, this.palNonce, this.adBreak.inAdBreak);
8896
- }
8897
- },
8898
7949
  {
8899
7950
  key: "generatePodVastUrl",
8900
7951
  value: function generatePodVastUrl(baseUrl, breakDurationMs) {
@@ -9290,11 +8341,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9290
8341
  }
9291
8342
  this.adConfig.beginNewAdPod();
9292
8343
  this.adConfig.podAssignedByPrefetch = true;
9293
- var optimizedPods = this.config.optimizedPods !== false;
9294
8344
  var breakDurationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : void 0;
9295
- var generatedUrls = optimizedPods ? [
8345
+ var generatedUrls = [
9296
8346
  this.generatePodVastUrl(baseVastUrl, breakDurationMs)
9297
- ] : this.generateVastUrls(baseVastUrl, 1);
8347
+ ];
9298
8348
  this.adBreak.pendingAdBreak = _object_spread_props(_object_spread({
9299
8349
  marker: marker
9300
8350
  }, fragmentSn !== void 0 ? {
@@ -9316,15 +8366,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9316
8366
  }, detectPayload), buildAnalyticsContext(this.config)).catch(function() {});
9317
8367
  if (this.debug) {
9318
8368
  console.log("[PREFETCH] Starting ad prefetch for upcoming ad break");
9319
- console.log("[PREFETCH] Pre-generated ".concat(generatedUrls.length, " ").concat(optimizedPods ? "pod" : "VAST", " URL(s)"));
9320
- }
9321
- if (optimizedPods) {
9322
- if (this.debug) {
9323
- console.log("[PREFETCH] Optimized pods enabled - skipping single-ad preload pool");
9324
- }
9325
- return;
8369
+ console.log("[PREFETCH] Pre-generated pod request URL");
9326
8370
  }
9327
- this.preloadPool.startPreloadPool(baseVastUrl, generatedUrls.slice(0, 1), false);
9328
8371
  }
9329
8372
  },
9330
8373
  {
@@ -9563,7 +8606,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9563
8606
  value: function destroy() {
9564
8607
  var _this_adPlayer;
9565
8608
  this.adBreak.stopContinuousFetching();
9566
- this.preloadPool.stop();
9567
8609
  this.timing.destroy();
9568
8610
  this.adBreak.clearPendingAdBreak();
9569
8611
  this.placeholder.destroy();