stormcloud-video-player 0.8.64 → 0.8.66
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.
- package/dist/stormcloud-vp.min.js +2 -2
- package/lib/StormcloudPlayer.cjs +1897 -917
- package/lib/StormcloudPlayer.cjs.map +1 -1
- package/lib/index.cjs +1853 -909
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +10 -0
- package/lib/index.js +1853 -909
- package/lib/index.js.map +1 -1
- package/lib/player/AdBreakOrchestrator.cjs +899 -736
- package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
- package/lib/player/AdBreakOrchestrator.d.cts +50 -16
- package/lib/player/AdConfigManager.cjs +16 -1
- package/lib/player/AdConfigManager.cjs.map +1 -1
- package/lib/player/AdTimingService.cjs +9 -1
- package/lib/player/AdTimingService.cjs.map +1 -1
- package/lib/player/AdTimingService.d.cts +1 -0
- package/lib/player/StormcloudVideoPlayer.cjs +1890 -910
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +1890 -910
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +1890 -910
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +975 -175
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.d.cts +1 -0
- package/lib/types.d.cts +9 -0
- package/lib/ui/StormcloudVideoPlayer.cjs +1854 -910
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/utils/vastMacros.cjs +19 -0
- package/lib/utils/vastMacros.cjs.map +1 -1
- package/lib/utils/vastMacros.d.cts +2 -1
- package/package.json +1 -1
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
function _array_like_to_array(arr, len) {
|
|
3
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
4
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
5
|
-
return arr2;
|
|
6
|
-
}
|
|
7
|
-
function _array_without_holes(arr) {
|
|
8
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
9
|
-
}
|
|
10
2
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
11
3
|
try {
|
|
12
4
|
var info = gen[key](arg);
|
|
@@ -61,14 +53,6 @@ function _define_property(obj, key, value) {
|
|
|
61
53
|
} else obj[key] = value;
|
|
62
54
|
return obj;
|
|
63
55
|
}
|
|
64
|
-
function _iterable_to_array(iter) {
|
|
65
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) {
|
|
66
|
-
return Array.from(iter);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
function _non_iterable_spread() {
|
|
70
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
71
|
-
}
|
|
72
56
|
function _object_spread(target) {
|
|
73
57
|
for(var i = 1; i < arguments.length; i++){
|
|
74
58
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
@@ -107,8 +91,41 @@ function _object_spread_props(target, source) {
|
|
|
107
91
|
}
|
|
108
92
|
return target;
|
|
109
93
|
}
|
|
110
|
-
function
|
|
111
|
-
|
|
94
|
+
function _object_without_properties(source, excluded) {
|
|
95
|
+
if (source == null) return {};
|
|
96
|
+
var target = {}, sourceKeys, key, i;
|
|
97
|
+
if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
|
|
98
|
+
sourceKeys = Reflect.ownKeys(Object(source));
|
|
99
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
100
|
+
key = sourceKeys[i];
|
|
101
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
102
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
103
|
+
target[key] = source[key];
|
|
104
|
+
}
|
|
105
|
+
return target;
|
|
106
|
+
}
|
|
107
|
+
target = _object_without_properties_loose(source, excluded);
|
|
108
|
+
if (Object.getOwnPropertySymbols) {
|
|
109
|
+
sourceKeys = Object.getOwnPropertySymbols(source);
|
|
110
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
111
|
+
key = sourceKeys[i];
|
|
112
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
113
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
114
|
+
target[key] = source[key];
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return target;
|
|
118
|
+
}
|
|
119
|
+
function _object_without_properties_loose(source, excluded) {
|
|
120
|
+
if (source == null) return {};
|
|
121
|
+
var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
|
|
122
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
123
|
+
key = sourceKeys[i];
|
|
124
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
125
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
126
|
+
target[key] = source[key];
|
|
127
|
+
}
|
|
128
|
+
return target;
|
|
112
129
|
}
|
|
113
130
|
function _ts_generator(thisArg, body) {
|
|
114
131
|
var f, y, t, _ = {
|
|
@@ -209,38 +226,10 @@ function _ts_generator(thisArg, body) {
|
|
|
209
226
|
};
|
|
210
227
|
}
|
|
211
228
|
}
|
|
212
|
-
function _ts_values(o) {
|
|
213
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
214
|
-
if (m) {
|
|
215
|
-
return m.call(o);
|
|
216
|
-
}
|
|
217
|
-
if (o && typeof o.length === "number") {
|
|
218
|
-
return {
|
|
219
|
-
next: function() {
|
|
220
|
-
if (o && i >= o.length) {
|
|
221
|
-
o = void 0;
|
|
222
|
-
}
|
|
223
|
-
return {
|
|
224
|
-
value: o && o[i++],
|
|
225
|
-
done: !o
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
231
|
-
}
|
|
232
229
|
function _type_of(obj) {
|
|
233
230
|
"@swc/helpers - typeof";
|
|
234
231
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
235
232
|
}
|
|
236
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
237
|
-
if (!o) return;
|
|
238
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
239
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
240
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
241
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
242
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
243
|
-
}
|
|
244
233
|
var __defProp = Object.defineProperty;
|
|
245
234
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
246
235
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -1299,7 +1288,35 @@ function sendHeartbeat(_0) {
|
|
|
1299
1288
|
function getAdAudioVolume(adPlayer) {
|
|
1300
1289
|
return adPlayer.getOriginalMutedState() ? 0 : adPlayer.getOriginalVolume();
|
|
1301
1290
|
}
|
|
1291
|
+
// src/utils/vastMacros.ts
|
|
1292
|
+
var GAM_AD_HOSTS = /* @__PURE__ */ new Set([
|
|
1293
|
+
"pubads.g.doubleclick.net",
|
|
1294
|
+
"securepubads.g.doubleclick.net"
|
|
1295
|
+
]);
|
|
1296
|
+
function ensureVideoAdType(rawUrl) {
|
|
1297
|
+
try {
|
|
1298
|
+
var url = new URL(rawUrl);
|
|
1299
|
+
if (!GAM_AD_HOSTS.has(url.hostname)) return rawUrl;
|
|
1300
|
+
if (url.searchParams.has("ad_type")) return rawUrl;
|
|
1301
|
+
url.searchParams.set("ad_type", "video");
|
|
1302
|
+
return url.toString();
|
|
1303
|
+
} catch (unused) {
|
|
1304
|
+
return rawUrl;
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1302
1307
|
// src/player/AdBreakOrchestrator.ts
|
|
1308
|
+
var REQUEST_FAILURE_STAGES = /* @__PURE__ */ new Set([
|
|
1309
|
+
"no_fill",
|
|
1310
|
+
"vast_fill_rejected",
|
|
1311
|
+
"request_failed",
|
|
1312
|
+
"media_unsupported",
|
|
1313
|
+
"play_failed",
|
|
1314
|
+
"play_resolved_but_never_started",
|
|
1315
|
+
"hls_fatal",
|
|
1316
|
+
"media_error",
|
|
1317
|
+
"stall",
|
|
1318
|
+
"decode_failure"
|
|
1319
|
+
]);
|
|
1303
1320
|
var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
1304
1321
|
function AdBreakOrchestrator(host, timing, adConfig, cueManager, placeholder) {
|
|
1305
1322
|
_class_call_check(this, AdBreakOrchestrator);
|
|
@@ -1307,11 +1324,17 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
1307
1324
|
this.showAds = false;
|
|
1308
1325
|
this.isShowingPlaceholder = false;
|
|
1309
1326
|
this.adDetectSentForCurrentBreak = false;
|
|
1310
|
-
this.
|
|
1311
|
-
this.
|
|
1312
|
-
this.
|
|
1327
|
+
this.slotState = "IDLE";
|
|
1328
|
+
this.unusableResponsesInBreak = 0;
|
|
1329
|
+
this.controllerGeneration = 0;
|
|
1330
|
+
this.requestDiagnostics = /* @__PURE__ */ new Map();
|
|
1331
|
+
this.breakFunnel = {};
|
|
1332
|
+
this.controllerCallInFlight = false;
|
|
1333
|
+
this.playbackStartedForCurrentRequest = false;
|
|
1334
|
+
this.opportunityEpoch = -1;
|
|
1313
1335
|
this.adPodQueue = [];
|
|
1314
|
-
this.
|
|
1336
|
+
this.defaultMinRemainingMsToRequestAd = 1e4;
|
|
1337
|
+
this.defaultMaxNoFillsPerBreak = 2;
|
|
1315
1338
|
this.pendingAdBreak = null;
|
|
1316
1339
|
this.host = host;
|
|
1317
1340
|
this.timing = timing;
|
|
@@ -1347,7 +1370,23 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
1347
1370
|
key: "attachImaEventListeners",
|
|
1348
1371
|
value: function attachImaEventListeners() {
|
|
1349
1372
|
var _this = this;
|
|
1350
|
-
var
|
|
1373
|
+
var controller = this.host.getAdPlayer();
|
|
1374
|
+
var generation = this.controllerGeneration;
|
|
1375
|
+
var adPlayer = {
|
|
1376
|
+
on: function on(event, handler) {
|
|
1377
|
+
controller.on(event, function(payload) {
|
|
1378
|
+
if (generation !== _this.controllerGeneration) {
|
|
1379
|
+
_this.logOrchestratorFunnel("stale_callback_ignored", {
|
|
1380
|
+
event: event,
|
|
1381
|
+
staleControllerId: generation,
|
|
1382
|
+
currentControllerId: _this.controllerGeneration
|
|
1383
|
+
});
|
|
1384
|
+
return;
|
|
1385
|
+
}
|
|
1386
|
+
handler(payload);
|
|
1387
|
+
});
|
|
1388
|
+
}
|
|
1389
|
+
};
|
|
1351
1390
|
adPlayer.on("pod_ad_started", function(payload) {
|
|
1352
1391
|
_this.timing.notePodAdStarted();
|
|
1353
1392
|
if (_this.debug) {
|
|
@@ -1361,7 +1400,35 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
1361
1400
|
adPlayer.on("ad_interaction", function(event) {
|
|
1362
1401
|
if (event) _this.host.onAdInteraction(event);
|
|
1363
1402
|
});
|
|
1403
|
+
adPlayer.on("ad_funnel", function(payload) {
|
|
1404
|
+
if (!(payload === null || payload === void 0 ? void 0 : payload.stage)) return;
|
|
1405
|
+
var stage = payload.stage;
|
|
1406
|
+
_this.countFunnelStage(stage);
|
|
1407
|
+
if (payload.reason) {
|
|
1408
|
+
_this.countFunnelStage("".concat(stage, ":").concat(payload.reason));
|
|
1409
|
+
}
|
|
1410
|
+
if (stage === "impression_fired" && payload.pixelCount != null) {
|
|
1411
|
+
_this.countFunnelStage("impression_urls", payload.pixelCount);
|
|
1412
|
+
}
|
|
1413
|
+
if (payload.visibilityState === "hidden") {
|
|
1414
|
+
_this.countFunnelStage("while_hidden");
|
|
1415
|
+
}
|
|
1416
|
+
if (stage === "gam_http_request_sent") {
|
|
1417
|
+
if (payload.attempt === 1) {
|
|
1418
|
+
_this.timing.noteAdRequestSent();
|
|
1419
|
+
} else {
|
|
1420
|
+
_this.countFunnelStage("gam_http_request_retry");
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
_this.recordRequestDiagnostic(payload);
|
|
1424
|
+
});
|
|
1364
1425
|
adPlayer.on("ad_impression", function() {
|
|
1426
|
+
_this.timing.consecutiveFailures = 0;
|
|
1427
|
+
_this.setSlotState("PLAYING", "impression");
|
|
1428
|
+
if (!_this.playbackStartedForCurrentRequest) {
|
|
1429
|
+
_this.playbackStartedForCurrentRequest = true;
|
|
1430
|
+
_this.timing.markAdStarted();
|
|
1431
|
+
}
|
|
1365
1432
|
sendAdImpressionTracking(_this.host.config.licenseKey, _object_spread_props(_object_spread({
|
|
1366
1433
|
source: "hls",
|
|
1367
1434
|
adIndex: _this.timing.currentAdIndex
|
|
@@ -1376,16 +1443,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
1376
1443
|
var remaining = _this.timing.getRemainingAdMs();
|
|
1377
1444
|
_this.timing.consecutiveFailures = 0;
|
|
1378
1445
|
if (_this.debug) {
|
|
1379
|
-
console.log("[StormcloudVideoPlayer] all_ads_completed event received - remaining=".concat(remaining, "ms
|
|
1380
|
-
queuedUrls: _to_consumable_array(_this.adRequestQueue)
|
|
1381
|
-
} : {});
|
|
1446
|
+
console.log("[StormcloudVideoPlayer] all_ads_completed event received - remaining=".concat(remaining, "ms"));
|
|
1382
1447
|
}
|
|
1383
1448
|
if (_this.inAdBreak) {
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
} else {
|
|
1387
|
-
_this.handleAdPodComplete();
|
|
1388
|
-
}
|
|
1449
|
+
_this.setSlotState("NEEDS_NEXT_AD", "all_ads_completed");
|
|
1450
|
+
_this.requestNextAd("all_ads_completed");
|
|
1389
1451
|
}
|
|
1390
1452
|
});
|
|
1391
1453
|
adPlayer.on("ad_error", function(errorPayload) {
|
|
@@ -1405,7 +1467,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
1405
1467
|
}
|
|
1406
1468
|
}
|
|
1407
1469
|
console.error("[AD-ERROR]", errorMessage, errorPayload || "");
|
|
1408
|
-
_this.
|
|
1470
|
+
if (_this.controllerCallInFlight) {
|
|
1471
|
+
return;
|
|
1472
|
+
}
|
|
1473
|
+
_this.handleAdFailure("ad_error");
|
|
1409
1474
|
});
|
|
1410
1475
|
adPlayer.on("content_pause", function() {
|
|
1411
1476
|
_this.timing.clearAdFailsafeTimer();
|
|
@@ -1444,26 +1509,32 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
1444
1509
|
}
|
|
1445
1510
|
_this.timing.consecutiveFailures = 0;
|
|
1446
1511
|
_this.timing.recordPlayedAdDuration(_this.host.getAdPlayer());
|
|
1447
|
-
var remaining = _this.timing.getRemainingAdMs();
|
|
1448
1512
|
if (_this.debug) {
|
|
1449
|
-
console.log("[
|
|
1450
|
-
queuedUrls: _to_consumable_array(_this.adRequestQueue)
|
|
1451
|
-
} : {});
|
|
1452
|
-
}
|
|
1453
|
-
if (_this.timing.hasTimeToStartAnotherAd()) {
|
|
1454
|
-
_this.tryNextAvailableAdWithRateLimit();
|
|
1455
|
-
} else {
|
|
1456
|
-
_this.handleAdPodComplete();
|
|
1513
|
+
console.log("[AdBreak] content_resume: remaining=".concat(_this.timing.getRemainingAdMs(), "ms"));
|
|
1457
1514
|
}
|
|
1515
|
+
_this.setSlotState("NEEDS_NEXT_AD", "ad_complete");
|
|
1516
|
+
_this.requestNextAd("ad_complete");
|
|
1458
1517
|
});
|
|
1459
1518
|
}
|
|
1460
1519
|
},
|
|
1461
1520
|
{
|
|
1462
1521
|
key: "recreateAdController",
|
|
1463
|
-
value: function recreateAdController() {
|
|
1464
|
-
if (this.
|
|
1465
|
-
console.
|
|
1522
|
+
value: function recreateAdController(reason) {
|
|
1523
|
+
if (reason === "new_request" && (this.slotState === "REQUESTING" || this.slotState === "READY")) {
|
|
1524
|
+
console.warn("[AD-CONTROLLER] destroy during active request", {
|
|
1525
|
+
controllerId: this.controllerGeneration,
|
|
1526
|
+
requestId: this.currentRequestId,
|
|
1527
|
+
state: this.slotState,
|
|
1528
|
+
reason: reason
|
|
1529
|
+
});
|
|
1466
1530
|
}
|
|
1531
|
+
console.log("[AD-CONTROLLER] destroy", {
|
|
1532
|
+
controllerId: this.controllerGeneration,
|
|
1533
|
+
requestId: this.currentRequestId,
|
|
1534
|
+
state: this.slotState,
|
|
1535
|
+
reason: reason
|
|
1536
|
+
});
|
|
1537
|
+
this.countFunnelStage("controller_destroy:".concat(reason));
|
|
1467
1538
|
var shouldShowPlaceholder = this.inAdBreak && this.showAds;
|
|
1468
1539
|
var adPlayer = this.host.getAdPlayer();
|
|
1469
1540
|
if (shouldShowPlaceholder && adPlayer) {
|
|
@@ -1476,6 +1547,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
1476
1547
|
}
|
|
1477
1548
|
var preservedMutedState = adPlayer.getOriginalMutedState();
|
|
1478
1549
|
var preservedVolumeState = adPlayer.getOriginalVolume();
|
|
1550
|
+
this.playbackStartedForCurrentRequest = false;
|
|
1479
1551
|
if (adPlayer) {
|
|
1480
1552
|
try {
|
|
1481
1553
|
adPlayer.destroy();
|
|
@@ -1489,9 +1561,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
1489
1561
|
var continueLiveStreamDuringAds = this.host.shouldContinueLiveStreamDuringAds();
|
|
1490
1562
|
var newAdPlayer = this.host.createAdPlayer(continueLiveStreamDuringAds);
|
|
1491
1563
|
this.host.setAdPlayer(newAdPlayer);
|
|
1564
|
+
this.controllerGeneration++;
|
|
1492
1565
|
newAdPlayer.initialize();
|
|
1493
1566
|
newAdPlayer.updateOriginalMutedState(preservedMutedState, preservedVolumeState);
|
|
1494
1567
|
this.attachImaEventListeners();
|
|
1568
|
+
if (this.debug) {
|
|
1569
|
+
console.log("[AD-CONTROLLER] create", {
|
|
1570
|
+
controllerId: this.controllerGeneration,
|
|
1571
|
+
reason: reason
|
|
1572
|
+
});
|
|
1573
|
+
}
|
|
1495
1574
|
if (shouldShowPlaceholder) {
|
|
1496
1575
|
this.placeholder.show();
|
|
1497
1576
|
newAdPlayer.showPlaceholder();
|
|
@@ -1512,32 +1591,57 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
1512
1591
|
}
|
|
1513
1592
|
},
|
|
1514
1593
|
{
|
|
1515
|
-
|
|
1516
|
-
value: // ───────────────────────────────────────────────────────────────
|
|
1594
|
+
// ───────────────────────────────────────────────────────────────
|
|
1517
1595
|
// Ad break start
|
|
1518
1596
|
// ───────────────────────────────────────────────────────────────
|
|
1519
|
-
|
|
1597
|
+
key: "isBreakActive",
|
|
1598
|
+
value: function isBreakActive() {
|
|
1599
|
+
return this.slotState !== "IDLE";
|
|
1600
|
+
}
|
|
1601
|
+
},
|
|
1602
|
+
{
|
|
1603
|
+
key: "getSlotState",
|
|
1604
|
+
value: function getSlotState() {
|
|
1605
|
+
return this.slotState;
|
|
1606
|
+
}
|
|
1607
|
+
},
|
|
1608
|
+
{
|
|
1609
|
+
key: "beginVmapBreak",
|
|
1610
|
+
value: function beginVmapBreak(breakKey) {
|
|
1611
|
+
this.breakSource = "vmap";
|
|
1612
|
+
this.followUpBaseVastUrl = void 0;
|
|
1613
|
+
this.unusableResponsesInBreak = 0;
|
|
1614
|
+
this.timing.totalAdRequestsInBreak = 0;
|
|
1615
|
+
this.setSlotState("NEEDS_NEXT_AD", "vmap_break_start");
|
|
1616
|
+
this.noteOpportunity("vmap", breakKey);
|
|
1617
|
+
}
|
|
1618
|
+
},
|
|
1619
|
+
{
|
|
1620
|
+
key: "handleAdStart",
|
|
1621
|
+
value: function handleAdStart(marker) {
|
|
1520
1622
|
return _async_to_generator(function() {
|
|
1521
|
-
var
|
|
1623
|
+
var baseVastUrl, adBreakDurationMs, mode, currentMuted, currentVolume, epoch, podPlayed;
|
|
1522
1624
|
return _ts_generator(this, function(_state) {
|
|
1523
1625
|
switch(_state.label){
|
|
1524
1626
|
case 0:
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1627
|
+
if (this.slotState !== "IDLE") {
|
|
1628
|
+
this.logOrchestratorFunnel("duplicate_break_start", {
|
|
1629
|
+
source: "scte35",
|
|
1630
|
+
state: this.slotState
|
|
1631
|
+
});
|
|
1632
|
+
return [
|
|
1633
|
+
2
|
|
1634
|
+
];
|
|
1528
1635
|
}
|
|
1529
|
-
|
|
1530
|
-
if (
|
|
1531
|
-
|
|
1532
|
-
} else if (this.adConfig.apiVastTagUrl) {
|
|
1533
|
-
baseVastUrl = this.adConfig.apiVastTagUrl;
|
|
1534
|
-
} else {
|
|
1636
|
+
baseVastUrl = this.adConfig.apiVastTagUrl;
|
|
1637
|
+
if (!baseVastUrl) {
|
|
1638
|
+
console.warn("[AdBreak] SCTE-35 break started but no direct VAST tag is configured");
|
|
1535
1639
|
this.clearPendingAdBreak();
|
|
1536
1640
|
return [
|
|
1537
1641
|
2
|
|
1538
1642
|
];
|
|
1539
1643
|
}
|
|
1540
|
-
adBreakDurationMs =
|
|
1644
|
+
adBreakDurationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : this.timing.expectedAdBreakDurationMs;
|
|
1541
1645
|
if (this.debug) {
|
|
1542
1646
|
mode = this.host.config.isLiveStream ? "LIVE" : "VOD";
|
|
1543
1647
|
console.log("[CONTINUOUS-FETCH] ".concat(mode, " MODE: Target duration=").concat(adBreakDurationMs, "ms"));
|
|
@@ -1545,9 +1649,12 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
1545
1649
|
this.timing.failedVastUrls.clear();
|
|
1546
1650
|
this.timing.temporaryFailureUrls.clear();
|
|
1547
1651
|
this.timing.consecutiveFailures = 0;
|
|
1548
|
-
this.continuousFetchingActive = true;
|
|
1549
1652
|
this.isShowingPlaceholder = false;
|
|
1550
1653
|
this.timing.totalAdRequestsInBreak = 0;
|
|
1654
|
+
this.breakSource = "scte35";
|
|
1655
|
+
this.followUpBaseVastUrl = baseVastUrl;
|
|
1656
|
+
this.unusableResponsesInBreak = 0;
|
|
1657
|
+
this.setSlotState("NEEDS_NEXT_AD", "scte35_break_start");
|
|
1551
1658
|
if (this.adConfig.podAssignedByPrefetch) {
|
|
1552
1659
|
this.adConfig.podAssignedByPrefetch = false;
|
|
1553
1660
|
} else {
|
|
@@ -1565,29 +1672,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
1565
1672
|
if (this.timing.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
|
|
1566
1673
|
this.timing.expectedAdBreakDurationMs = adBreakDurationMs;
|
|
1567
1674
|
}
|
|
1675
|
+
this.noteOpportunity("scte35", this.cueManager.activeScte35BreakKey);
|
|
1676
|
+
epoch = this.timing.adBreakEpoch;
|
|
1568
1677
|
return [
|
|
1569
1678
|
4,
|
|
1570
|
-
this.startOptimizedPod(baseVastUrl, adBreakDurationMs
|
|
1679
|
+
this.startOptimizedPod(baseVastUrl, adBreakDurationMs)
|
|
1571
1680
|
];
|
|
1572
1681
|
case 1:
|
|
1573
1682
|
podPlayed = _state.sent();
|
|
1574
|
-
if (
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
];
|
|
1578
|
-
if (this.debug) {
|
|
1579
|
-
console.log("[POD] Initial pod request did not fill; attempting top-up pod request");
|
|
1683
|
+
if (!podPlayed && this.inAdBreak && epoch === this.timing.adBreakEpoch) {
|
|
1684
|
+
this.setSlotState("NEEDS_NEXT_AD", "initial_request_failed");
|
|
1685
|
+
this.requestNextAd("initial_request_failed");
|
|
1580
1686
|
}
|
|
1581
|
-
this.continuousFetchingActive = true;
|
|
1582
|
-
this.startContinuousFetching(baseVastUrl);
|
|
1583
|
-
return [
|
|
1584
|
-
4,
|
|
1585
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
1586
|
-
];
|
|
1587
|
-
case 2:
|
|
1588
|
-
_state.sent();
|
|
1589
|
-
_state.label = 3;
|
|
1590
|
-
case 3:
|
|
1591
1687
|
return [
|
|
1592
1688
|
2
|
|
1593
1689
|
];
|
|
@@ -1601,12 +1697,13 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
1601
1697
|
value: // ───────────────────────────────────────────────────────────────
|
|
1602
1698
|
// Optimized pod (single multi-ad request)
|
|
1603
1699
|
// ───────────────────────────────────────────────────────────────
|
|
1604
|
-
function startOptimizedPod(baseVastUrl, breakDurationMs
|
|
1700
|
+
function startOptimizedPod(baseVastUrl, breakDurationMs) {
|
|
1605
1701
|
return _async_to_generator(function() {
|
|
1606
|
-
var podUrl, adPlayer, requestToken, _ref, _adPlayer_getPodAdCount, podCount, error;
|
|
1702
|
+
var podUrl, prefetched, epoch, generation, adPlayer, requestToken, _ref, _adPlayer_getPodAdCount, podCount, error;
|
|
1607
1703
|
return _ts_generator(this, function(_state) {
|
|
1608
1704
|
switch(_state.label){
|
|
1609
1705
|
case 0:
|
|
1706
|
+
prefetched = !!(this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0);
|
|
1610
1707
|
if (this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0) {
|
|
1611
1708
|
podUrl = this.pendingAdBreak.vastUrls[0];
|
|
1612
1709
|
this.clearPendingAdBreak();
|
|
@@ -1619,12 +1716,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
1619
1716
|
false
|
|
1620
1717
|
];
|
|
1621
1718
|
}
|
|
1622
|
-
this.
|
|
1623
|
-
this.
|
|
1719
|
+
this.noteVastUrlGenerated(podUrl, prefetched ? "prefetch" : "break_start");
|
|
1720
|
+
epoch = this.timing.adBreakEpoch;
|
|
1721
|
+
this.recreateAdController("new_request");
|
|
1722
|
+
generation = this.controllerGeneration;
|
|
1624
1723
|
adPlayer = this.host.getAdPlayer();
|
|
1625
1724
|
requestToken = ++this.timing.adRequestTokenCounter;
|
|
1626
1725
|
this.timing.activeAdRequestToken = requestToken;
|
|
1627
1726
|
this.currentVastUrl = podUrl;
|
|
1727
|
+
this.setSlotState("REQUESTING", "initial_pod");
|
|
1728
|
+
this.beginFunnelRequest(adPlayer, requestToken, "initial_pod");
|
|
1628
1729
|
_state.label = 1;
|
|
1629
1730
|
case 1:
|
|
1630
1731
|
_state.trys.push([
|
|
@@ -1639,16 +1740,24 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
1639
1740
|
];
|
|
1640
1741
|
case 2:
|
|
1641
1742
|
_state.sent();
|
|
1743
|
+
if (this.isStale(epoch, generation)) return [
|
|
1744
|
+
2,
|
|
1745
|
+
true
|
|
1746
|
+
];
|
|
1642
1747
|
this.timing.startAdRequestWatchdog(requestToken);
|
|
1643
|
-
this.timing.lastAdRequestTime = Date.now();
|
|
1644
1748
|
return [
|
|
1645
1749
|
4,
|
|
1646
|
-
|
|
1750
|
+
this.callController(function() {
|
|
1751
|
+
return adPlayer.requestAds(podUrl);
|
|
1752
|
+
})
|
|
1647
1753
|
];
|
|
1648
1754
|
case 3:
|
|
1649
1755
|
_state.sent();
|
|
1650
1756
|
this.timing.clearAdRequestWatchdog();
|
|
1651
|
-
if (this.
|
|
1757
|
+
if (this.isStale(epoch, generation)) {
|
|
1758
|
+
this.logOrchestratorFunnel("stale_request_result_ignored", {
|
|
1759
|
+
requestId: requestToken
|
|
1760
|
+
});
|
|
1652
1761
|
return [
|
|
1653
1762
|
2,
|
|
1654
1763
|
true
|
|
@@ -1656,11 +1765,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
1656
1765
|
}
|
|
1657
1766
|
podCount = (_ref = (_adPlayer_getPodAdCount = adPlayer.getPodAdCount) === null || _adPlayer_getPodAdCount === void 0 ? void 0 : _adPlayer_getPodAdCount.call(adPlayer)) !== null && _ref !== void 0 ? _ref : 1;
|
|
1658
1767
|
if (podCount < 1) {
|
|
1768
|
+
if (this.timing.activeAdRequestToken === requestToken) {
|
|
1769
|
+
this.timing.activeAdRequestToken = null;
|
|
1770
|
+
}
|
|
1771
|
+
this.recordRequestFailure(new Error("No ads available"), podUrl);
|
|
1659
1772
|
return [
|
|
1660
1773
|
2,
|
|
1661
1774
|
false
|
|
1662
1775
|
];
|
|
1663
1776
|
}
|
|
1777
|
+
this.setSlotState("READY", "vast_ready");
|
|
1664
1778
|
if (this.debug) {
|
|
1665
1779
|
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"));
|
|
1666
1780
|
}
|
|
@@ -1672,18 +1786,20 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
1672
1786
|
this.timing.startAdFailsafeTimer(requestToken);
|
|
1673
1787
|
return [
|
|
1674
1788
|
4,
|
|
1675
|
-
|
|
1789
|
+
this.callController(function() {
|
|
1790
|
+
return adPlayer.play();
|
|
1791
|
+
})
|
|
1676
1792
|
];
|
|
1677
1793
|
case 4:
|
|
1678
1794
|
_state.sent();
|
|
1679
|
-
this.
|
|
1795
|
+
if (this.isStale(epoch, generation)) return [
|
|
1796
|
+
2,
|
|
1797
|
+
true
|
|
1798
|
+
];
|
|
1680
1799
|
if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
|
|
1681
1800
|
this.timing.scheduleAdStopAtBreakBoundary();
|
|
1682
1801
|
}
|
|
1683
|
-
adPlayer.setAdVolume(
|
|
1684
|
-
this.timing.consecutiveFailures = 0;
|
|
1685
|
-
this.continuousFetchingActive = true;
|
|
1686
|
-
this.startContinuousFetching(baseVastUrl);
|
|
1802
|
+
adPlayer.setAdVolume(getAdAudioVolume(adPlayer));
|
|
1687
1803
|
return [
|
|
1688
1804
|
2,
|
|
1689
1805
|
true
|
|
@@ -1695,14 +1811,20 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
1695
1811
|
if (this.timing.activeAdRequestToken === requestToken) {
|
|
1696
1812
|
this.timing.activeAdRequestToken = null;
|
|
1697
1813
|
}
|
|
1814
|
+
if (this.isStale(epoch, generation)) {
|
|
1815
|
+
this.logOrchestratorFunnel("stale_request_result_ignored", {
|
|
1816
|
+
requestId: requestToken,
|
|
1817
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
1818
|
+
});
|
|
1819
|
+
return [
|
|
1820
|
+
2,
|
|
1821
|
+
true
|
|
1822
|
+
];
|
|
1823
|
+
}
|
|
1698
1824
|
if (this.debug) {
|
|
1699
1825
|
console.warn("[POD] Optimized pod request/play failed:", error);
|
|
1700
1826
|
}
|
|
1701
|
-
|
|
1702
|
-
this.timing.temporaryFailureUrls.set(podUrl, Date.now());
|
|
1703
|
-
}
|
|
1704
|
-
this.continuousFetchingActive = true;
|
|
1705
|
-
this.recreateAdController();
|
|
1827
|
+
this.recordRequestFailure(error, podUrl);
|
|
1706
1828
|
return [
|
|
1707
1829
|
2,
|
|
1708
1830
|
false
|
|
@@ -1718,168 +1840,204 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
1718
1840
|
},
|
|
1719
1841
|
{
|
|
1720
1842
|
// ───────────────────────────────────────────────────────────────
|
|
1721
|
-
//
|
|
1843
|
+
// Next-ad scheduling (single flight)
|
|
1722
1844
|
// ───────────────────────────────────────────────────────────────
|
|
1723
|
-
key: "
|
|
1724
|
-
value: function
|
|
1725
|
-
if (
|
|
1845
|
+
key: "setSlotState",
|
|
1846
|
+
value: function setSlotState(next, reason) {
|
|
1847
|
+
if (this.slotState === next) return;
|
|
1848
|
+
var previous = this.slotState;
|
|
1849
|
+
this.slotState = next;
|
|
1850
|
+
if (this.debug) {
|
|
1851
|
+
console.log("[AdBreak][STATE] ".concat(previous, " -> ").concat(next), {
|
|
1852
|
+
reason: reason,
|
|
1853
|
+
breakId: this.timing.adBreakEpoch,
|
|
1854
|
+
requestId: this.currentRequestId,
|
|
1855
|
+
controllerId: this.controllerGeneration
|
|
1856
|
+
});
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
},
|
|
1860
|
+
{
|
|
1861
|
+
key: "isStale",
|
|
1862
|
+
value: function isStale(epoch, generation) {
|
|
1863
|
+
return !this.inAdBreak || epoch !== this.timing.adBreakEpoch || generation !== this.controllerGeneration;
|
|
1864
|
+
}
|
|
1865
|
+
},
|
|
1866
|
+
{
|
|
1867
|
+
key: "getMinRemainingMsToRequestAd",
|
|
1868
|
+
value: function getMinRemainingMsToRequestAd() {
|
|
1869
|
+
var configured = this.host.config.minRemainingMsToRequestAd;
|
|
1870
|
+
var floor = this.timing.getMinRemainingMsToStartAd();
|
|
1871
|
+
if (typeof configured === "number" && configured >= 0) {
|
|
1872
|
+
return Math.max(configured, floor);
|
|
1873
|
+
}
|
|
1874
|
+
return Math.max(this.defaultMinRemainingMsToRequestAd, floor);
|
|
1875
|
+
}
|
|
1876
|
+
},
|
|
1877
|
+
{
|
|
1878
|
+
key: "getMaxNoFillsPerBreak",
|
|
1879
|
+
value: function getMaxNoFillsPerBreak() {
|
|
1880
|
+
var configured = this.host.config.maxNoFillsPerBreak;
|
|
1881
|
+
return typeof configured === "number" && configured > 0 ? configured : this.defaultMaxNoFillsPerBreak;
|
|
1882
|
+
}
|
|
1883
|
+
},
|
|
1884
|
+
{
|
|
1885
|
+
key: "isBreakTimeBounded",
|
|
1886
|
+
value: function isBreakTimeBounded() {
|
|
1887
|
+
return this.breakSource === "scte35" || this.timing.expectedAdBreakDurationMs != null;
|
|
1888
|
+
}
|
|
1889
|
+
},
|
|
1890
|
+
{
|
|
1891
|
+
key: "getStopRequestingReason",
|
|
1892
|
+
value: function getStopRequestingReason(remainingMs) {
|
|
1893
|
+
if (this.breakSource === "vmap") {
|
|
1894
|
+
if (this.adPodQueue.length === 0) return "vmap_queue_empty";
|
|
1895
|
+
} else if (this.breakSource !== "scte35" || !this.followUpBaseVastUrl) {
|
|
1896
|
+
return "no_follow_up_source";
|
|
1897
|
+
}
|
|
1898
|
+
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
1899
|
+
return "max_consecutive_failures";
|
|
1900
|
+
}
|
|
1901
|
+
if (this.unusableResponsesInBreak >= this.getMaxNoFillsPerBreak()) {
|
|
1902
|
+
return "unusable_response_limit";
|
|
1903
|
+
}
|
|
1904
|
+
if (this.timing.totalAdRequestsInBreak >= this.timing.maxTotalAdRequestsPerBreak) {
|
|
1905
|
+
return "request_cap";
|
|
1906
|
+
}
|
|
1907
|
+
if (this.timing.isGamInCooldown()) {
|
|
1908
|
+
return "gam_cooldown";
|
|
1909
|
+
}
|
|
1910
|
+
if (this.isBreakTimeBounded() && remainingMs < this.getMinRemainingMsToRequestAd()) {
|
|
1911
|
+
return "insufficient_break_time";
|
|
1912
|
+
}
|
|
1913
|
+
return void 0;
|
|
1914
|
+
}
|
|
1915
|
+
},
|
|
1916
|
+
{
|
|
1917
|
+
key: "getNextRequestDelayMs",
|
|
1918
|
+
value: function getNextRequestDelayMs() {
|
|
1919
|
+
var failures = this.timing.consecutiveFailures;
|
|
1920
|
+
var backoff = failures > 0 ? Math.min(this.timing.backoffBaseMs * Math.pow(2, failures), this.timing.maxBackoffMs) : 0;
|
|
1921
|
+
var minInterval = this.timing.minAdRequestIntervalMs + backoff;
|
|
1922
|
+
var sinceLast = Date.now() - this.timing.lastAdRequestTime;
|
|
1923
|
+
return Math.max(0, minInterval - sinceLast);
|
|
1924
|
+
}
|
|
1925
|
+
},
|
|
1926
|
+
{
|
|
1927
|
+
key: "requestNextAd",
|
|
1928
|
+
value: function requestNextAd(trigger) {
|
|
1929
|
+
var _this = this;
|
|
1930
|
+
if (!this.inAdBreak) return;
|
|
1931
|
+
if (this.slotState !== "NEEDS_NEXT_AD") {
|
|
1932
|
+
this.logOrchestratorFunnel("request_suppressed", {
|
|
1933
|
+
trigger: trigger,
|
|
1934
|
+
state: this.slotState,
|
|
1935
|
+
why: "slot_busy"
|
|
1936
|
+
});
|
|
1726
1937
|
return;
|
|
1727
1938
|
}
|
|
1728
|
-
if (this.
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1939
|
+
if (this.nextAdTimerId != null) {
|
|
1940
|
+
this.logOrchestratorFunnel("request_suppressed", {
|
|
1941
|
+
trigger: trigger,
|
|
1942
|
+
state: this.slotState,
|
|
1943
|
+
why: "request_already_scheduled"
|
|
1944
|
+
});
|
|
1732
1945
|
return;
|
|
1733
1946
|
}
|
|
1734
|
-
|
|
1735
|
-
|
|
1947
|
+
var remainingMs = this.timing.getRemainingAdMs();
|
|
1948
|
+
var stopReason = this.getStopRequestingReason(remainingMs);
|
|
1949
|
+
if (stopReason) {
|
|
1950
|
+
this.logOrchestratorFunnel("next_ad_decision", {
|
|
1951
|
+
trigger: trigger,
|
|
1952
|
+
decision: "end_break",
|
|
1953
|
+
reason: stopReason,
|
|
1954
|
+
remainingMs: remainingMs,
|
|
1955
|
+
requestsSent: this.timing.totalAdRequestsInBreak,
|
|
1956
|
+
unusableResponses: this.unusableResponsesInBreak,
|
|
1957
|
+
consecutiveFailures: this.timing.consecutiveFailures
|
|
1958
|
+
});
|
|
1959
|
+
this.handleAdPodComplete(stopReason);
|
|
1960
|
+
return;
|
|
1961
|
+
}
|
|
1962
|
+
var waitMs = this.getNextRequestDelayMs();
|
|
1963
|
+
if (waitMs > 0 && this.isBreakTimeBounded() && remainingMs - waitMs < this.getMinRemainingMsToRequestAd()) {
|
|
1964
|
+
this.logOrchestratorFunnel("next_ad_decision", {
|
|
1965
|
+
trigger: trigger,
|
|
1966
|
+
decision: "end_break",
|
|
1967
|
+
reason: "insufficient_break_time_after_backoff",
|
|
1968
|
+
remainingMs: remainingMs,
|
|
1969
|
+
waitMs: waitMs
|
|
1970
|
+
});
|
|
1971
|
+
this.handleAdPodComplete("insufficient_break_time_after_backoff");
|
|
1972
|
+
return;
|
|
1973
|
+
}
|
|
1974
|
+
this.logOrchestratorFunnel("next_ad_decision", {
|
|
1975
|
+
trigger: trigger,
|
|
1976
|
+
decision: waitMs > 0 ? "request_after_delay" : "request_now",
|
|
1977
|
+
waitMs: waitMs,
|
|
1978
|
+
remainingMs: remainingMs,
|
|
1979
|
+
consecutiveFailures: this.timing.consecutiveFailures
|
|
1980
|
+
});
|
|
1981
|
+
if (waitMs > 0) {
|
|
1982
|
+
if (!this.isShowingPlaceholder) {
|
|
1983
|
+
this.isShowingPlaceholder = true;
|
|
1984
|
+
this.host.getAdPlayer().showPlaceholder();
|
|
1985
|
+
}
|
|
1986
|
+
var epoch = this.timing.adBreakEpoch;
|
|
1987
|
+
this.nextAdTimerId = window.setTimeout(function() {
|
|
1988
|
+
_this.nextAdTimerId = void 0;
|
|
1989
|
+
if (!_this.inAdBreak || epoch !== _this.timing.adBreakEpoch) return;
|
|
1990
|
+
_this.requestNextAd("".concat(trigger, ":after_delay"));
|
|
1991
|
+
}, waitMs);
|
|
1992
|
+
return;
|
|
1736
1993
|
}
|
|
1737
|
-
this.
|
|
1738
|
-
this.continuousFetchLoop(baseVastUrl);
|
|
1994
|
+
void this.requestFollowUpAd(trigger);
|
|
1739
1995
|
}
|
|
1740
1996
|
},
|
|
1741
1997
|
{
|
|
1742
|
-
key: "
|
|
1743
|
-
value: function
|
|
1998
|
+
key: "requestFollowUpAd",
|
|
1999
|
+
value: function requestFollowUpAd(trigger) {
|
|
1744
2000
|
return _async_to_generator(function() {
|
|
1745
|
-
var
|
|
2001
|
+
var url, epoch, unused;
|
|
1746
2002
|
return _ts_generator(this, function(_state) {
|
|
1747
2003
|
switch(_state.label){
|
|
1748
2004
|
case 0:
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
}
|
|
1759
|
-
return [
|
|
1760
|
-
2,
|
|
1761
|
-
"break"
|
|
1762
|
-
];
|
|
1763
|
-
}
|
|
1764
|
-
if (_this.timing.isGamInCooldown()) {
|
|
1765
|
-
if (_this.debug) {
|
|
1766
|
-
console.log("[CIRCUIT-BREAKER] GAM in cooldown, stopping URL generation");
|
|
1767
|
-
}
|
|
1768
|
-
return [
|
|
1769
|
-
2,
|
|
1770
|
-
"break"
|
|
1771
|
-
];
|
|
1772
|
-
}
|
|
1773
|
-
if (_this.timing.consecutiveFailures >= _this.timing.maxConsecutiveFailures) {
|
|
1774
|
-
if (_this.debug) {
|
|
1775
|
-
console.log("[CONTINUOUS-FETCH] Too many consecutive failures (".concat(_this.timing.consecutiveFailures, "), stopping URL generation"));
|
|
1776
|
-
}
|
|
1777
|
-
return [
|
|
1778
|
-
2,
|
|
1779
|
-
"break"
|
|
1780
|
-
];
|
|
1781
|
-
}
|
|
1782
|
-
if (_this.timing.totalAdRequestsInBreak >= _this.timing.maxTotalAdRequestsPerBreak) {
|
|
1783
|
-
if (_this.debug) {
|
|
1784
|
-
console.log("[CONTINUOUS-FETCH] Maximum ad requests reached (".concat(_this.timing.maxTotalAdRequestsPerBreak, "), stopping"));
|
|
1785
|
-
}
|
|
1786
|
-
return [
|
|
1787
|
-
2,
|
|
1788
|
-
"break"
|
|
1789
|
-
];
|
|
1790
|
-
}
|
|
1791
|
-
maxQueueSize = 5;
|
|
1792
|
-
if (!(_this.adRequestQueue.length >= maxQueueSize)) return [
|
|
1793
|
-
3,
|
|
1794
|
-
2
|
|
1795
|
-
];
|
|
1796
|
-
if (_this.debug) {
|
|
1797
|
-
console.log("[CONTINUOUS-FETCH] URL queue full (".concat(_this.adRequestQueue.length, "), waiting..."));
|
|
1798
|
-
}
|
|
1799
|
-
return [
|
|
1800
|
-
4,
|
|
1801
|
-
new Promise(function(resolve) {
|
|
1802
|
-
return setTimeout(resolve, 1e3);
|
|
1803
|
-
})
|
|
1804
|
-
];
|
|
1805
|
-
case 1:
|
|
1806
|
-
_state.sent();
|
|
1807
|
-
return [
|
|
1808
|
-
2,
|
|
1809
|
-
"continue"
|
|
1810
|
-
];
|
|
1811
|
-
case 2:
|
|
1812
|
-
newAdUrl = _this.nextAdRequestUrl(baseVastUrl);
|
|
1813
|
-
if (!(!newAdUrl || _this.timing.failedVastUrls.has(newAdUrl) || _this.timing.isUrlInCooldown(newAdUrl))) return [
|
|
1814
|
-
3,
|
|
1815
|
-
4
|
|
1816
|
-
];
|
|
1817
|
-
return [
|
|
1818
|
-
4,
|
|
1819
|
-
new Promise(function(resolve) {
|
|
1820
|
-
return setTimeout(resolve, 500);
|
|
1821
|
-
})
|
|
1822
|
-
];
|
|
1823
|
-
case 3:
|
|
1824
|
-
_state.sent();
|
|
1825
|
-
return [
|
|
1826
|
-
2,
|
|
1827
|
-
"continue"
|
|
1828
|
-
];
|
|
1829
|
-
case 4:
|
|
1830
|
-
if (_this.debug) {
|
|
1831
|
-
queuedUrlsPreview = _to_consumable_array(_this.adRequestQueue).concat([
|
|
1832
|
-
newAdUrl
|
|
1833
|
-
]);
|
|
1834
|
-
console.log("[CONTINUOUS-FETCH] Queued VAST URL (queue size: ".concat(queuedUrlsPreview.length, ")"), {
|
|
1835
|
-
queuedUrls: queuedUrlsPreview
|
|
1836
|
-
});
|
|
1837
|
-
}
|
|
1838
|
-
_this.adRequestQueue.push(newAdUrl);
|
|
1839
|
-
generationDelay = _this.timing.consecutiveFailures > 0 ? Math.min(1e3 * Math.pow(2, _this.timing.consecutiveFailures), 5e3) : 500;
|
|
1840
|
-
return [
|
|
1841
|
-
4,
|
|
1842
|
-
new Promise(function(resolve) {
|
|
1843
|
-
return setTimeout(resolve, generationDelay);
|
|
1844
|
-
})
|
|
1845
|
-
];
|
|
1846
|
-
case 5:
|
|
1847
|
-
_state.sent();
|
|
1848
|
-
return [
|
|
1849
|
-
2
|
|
1850
|
-
];
|
|
1851
|
-
}
|
|
1852
|
-
});
|
|
1853
|
-
};
|
|
2005
|
+
if (this.breakSource === "vmap") {
|
|
2006
|
+
url = this.adPodQueue.shift();
|
|
2007
|
+
} else if (this.followUpBaseVastUrl) {
|
|
2008
|
+
url = this.nextAdRequestUrl(this.followUpBaseVastUrl);
|
|
2009
|
+
}
|
|
2010
|
+
if (!url) return [
|
|
2011
|
+
2
|
|
2012
|
+
];
|
|
2013
|
+
this.noteVastUrlGenerated(ensureVideoAdType(url), trigger);
|
|
1854
2014
|
epoch = this.timing.adBreakEpoch;
|
|
1855
2015
|
_state.label = 1;
|
|
1856
2016
|
case 1:
|
|
1857
|
-
|
|
2017
|
+
_state.trys.push([
|
|
2018
|
+
1,
|
|
1858
2019
|
3,
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
2020
|
+
,
|
|
2021
|
+
4
|
|
2022
|
+
]);
|
|
1862
2023
|
return [
|
|
1863
|
-
|
|
1864
|
-
|
|
2024
|
+
4,
|
|
2025
|
+
this.playSingleAd(url, trigger)
|
|
1865
2026
|
];
|
|
1866
2027
|
case 2:
|
|
1867
|
-
|
|
1868
|
-
|
|
2028
|
+
_state.sent();
|
|
2029
|
+
return [
|
|
1869
2030
|
3,
|
|
1870
|
-
|
|
2031
|
+
4
|
|
1871
2032
|
];
|
|
2033
|
+
case 3:
|
|
2034
|
+
unused = _state.sent();
|
|
2035
|
+
this.continueAfterRequestFailure(epoch);
|
|
1872
2036
|
return [
|
|
1873
2037
|
3,
|
|
1874
|
-
|
|
2038
|
+
4
|
|
1875
2039
|
];
|
|
1876
|
-
case
|
|
1877
|
-
this.continuousFetchLoopRunning = false;
|
|
1878
|
-
if (this.debug) {
|
|
1879
|
-
console.log("[CONTINUOUS-FETCH] URL generation loop ended (queued: ".concat(this.adRequestQueue.length, ")"), this.adRequestQueue.length > 0 ? {
|
|
1880
|
-
queuedUrls: _to_consumable_array(this.adRequestQueue)
|
|
1881
|
-
} : {});
|
|
1882
|
-
}
|
|
2040
|
+
case 4:
|
|
1883
2041
|
return [
|
|
1884
2042
|
2
|
|
1885
2043
|
];
|
|
@@ -1889,242 +2047,158 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
1889
2047
|
}
|
|
1890
2048
|
},
|
|
1891
2049
|
{
|
|
1892
|
-
key: "
|
|
1893
|
-
value: function
|
|
1894
|
-
|
|
1895
|
-
this.
|
|
1896
|
-
this.
|
|
1897
|
-
|
|
1898
|
-
|
|
2050
|
+
key: "continueAfterRequestFailure",
|
|
2051
|
+
value: function continueAfterRequestFailure() {
|
|
2052
|
+
var epoch = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.timing.adBreakEpoch;
|
|
2053
|
+
if (!this.inAdBreak || epoch !== this.timing.adBreakEpoch) return;
|
|
2054
|
+
this.setSlotState("NEEDS_NEXT_AD", "request_failed");
|
|
2055
|
+
this.requestNextAd("after_failure");
|
|
2056
|
+
}
|
|
2057
|
+
},
|
|
2058
|
+
{
|
|
2059
|
+
key: "cancelScheduledRequest",
|
|
2060
|
+
value: function cancelScheduledRequest() {
|
|
2061
|
+
if (this.nextAdTimerId != null) {
|
|
2062
|
+
clearTimeout(this.nextAdTimerId);
|
|
2063
|
+
this.nextAdTimerId = void 0;
|
|
1899
2064
|
}
|
|
1900
2065
|
}
|
|
1901
2066
|
},
|
|
1902
2067
|
{
|
|
1903
|
-
key: "
|
|
1904
|
-
value:
|
|
1905
|
-
|
|
2068
|
+
key: "noteVastUrlGenerated",
|
|
2069
|
+
value: function noteVastUrlGenerated(url, source) {
|
|
2070
|
+
var _ref, _ref1, _ref2, _ref3, _ref4;
|
|
2071
|
+
var params;
|
|
2072
|
+
try {
|
|
2073
|
+
params = new URL(url).searchParams;
|
|
2074
|
+
} catch (unused) {}
|
|
2075
|
+
var adType = (_ref = params === null || params === void 0 ? void 0 : params.get("ad_type")) !== null && _ref !== void 0 ? _ref : void 0;
|
|
2076
|
+
this.logOrchestratorFunnel("vast_url_generated", {
|
|
2077
|
+
source: source,
|
|
2078
|
+
pod: (_ref1 = params === null || params === void 0 ? void 0 : params.get("pod")) !== null && _ref1 !== void 0 ? _ref1 : void 0,
|
|
2079
|
+
pmad: (_ref2 = params === null || params === void 0 ? void 0 : params.get("pmad")) !== null && _ref2 !== void 0 ? _ref2 : void 0,
|
|
2080
|
+
pmnd: (_ref3 = params === null || params === void 0 ? void 0 : params.get("pmnd")) !== null && _ref3 !== void 0 ? _ref3 : void 0,
|
|
2081
|
+
pmxd: (_ref4 = params === null || params === void 0 ? void 0 : params.get("pmxd")) !== null && _ref4 !== void 0 ? _ref4 : void 0,
|
|
2082
|
+
adType: adType
|
|
2083
|
+
});
|
|
2084
|
+
if (adType === "audio" || adType === "audio_video") {
|
|
2085
|
+
console.warn("[AdBreak] VAST tag requests ad_type=".concat(adType, "; GAM may return audio-only creatives, which this video player rejects"));
|
|
2086
|
+
this.countFunnelStage("tag_allows_audio");
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
},
|
|
2090
|
+
{
|
|
2091
|
+
key: "recordRequestFailure",
|
|
2092
|
+
value: function recordRequestFailure(error, vastTagUrl) {
|
|
2093
|
+
var _diag_vastAdCount;
|
|
2094
|
+
var diag = this.currentRequestId != null ? this.requestDiagnostics.get(this.currentRequestId) : void 0;
|
|
2095
|
+
var message = (error === null || error === void 0 ? void 0 : error.message) || "";
|
|
2096
|
+
var outcome;
|
|
2097
|
+
if (message.includes("ad_duration_exceeds_budget")) {
|
|
2098
|
+
outcome = "discarded_budget";
|
|
2099
|
+
} else if (message.includes("VAST fill rejected")) {
|
|
2100
|
+
outcome = "fill_rejected";
|
|
2101
|
+
} else if (/no ads available|no fill|nofill/i.test(message)) {
|
|
2102
|
+
outcome = "no_fill";
|
|
2103
|
+
} else if (/timeout/i.test(message)) {
|
|
2104
|
+
outcome = "request_timeout";
|
|
2105
|
+
} else if (/destroyed|aborted/i.test(message)) {
|
|
2106
|
+
outcome = "request_aborted";
|
|
2107
|
+
} else if (diag && ((_diag_vastAdCount = diag.vastAdCount) !== null && _diag_vastAdCount !== void 0 ? _diag_vastAdCount : 0) > 0 && !diag.impressionFired) {
|
|
2108
|
+
outcome = "playback_failed";
|
|
2109
|
+
} else {
|
|
2110
|
+
outcome = "request_failed";
|
|
2111
|
+
}
|
|
2112
|
+
this.timing.consecutiveFailures++;
|
|
2113
|
+
if (outcome === "no_fill" || outcome === "fill_rejected" || outcome === "discarded_budget") {
|
|
2114
|
+
this.unusableResponsesInBreak++;
|
|
2115
|
+
}
|
|
2116
|
+
if (outcome === "no_fill") {
|
|
2117
|
+
this.timing.recordGamNoFill();
|
|
2118
|
+
}
|
|
2119
|
+
if (diag && !diag.failureReason) {
|
|
2120
|
+
diag.failureReason = "".concat(outcome, ": ").concat(message);
|
|
2121
|
+
}
|
|
2122
|
+
if (this.timing.isTemporaryAdError(error)) {
|
|
2123
|
+
this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
|
|
2124
|
+
} else if (outcome !== "discarded_budget") {
|
|
2125
|
+
this.timing.failedVastUrls.add(vastTagUrl);
|
|
2126
|
+
}
|
|
2127
|
+
this.countFunnelStage("request_outcome:".concat(outcome));
|
|
2128
|
+
this.logOrchestratorFunnel("request_outcome", {
|
|
2129
|
+
outcome: outcome,
|
|
2130
|
+
errorMessage: message,
|
|
2131
|
+
consecutiveFailures: this.timing.consecutiveFailures,
|
|
2132
|
+
unusableResponsesInBreak: this.unusableResponsesInBreak
|
|
2133
|
+
});
|
|
2134
|
+
}
|
|
2135
|
+
},
|
|
2136
|
+
{
|
|
1906
2137
|
// ───────────────────────────────────────────────────────────────
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
backoffDelay = Math.min(this.timing.backoffBaseMs * backoffMultiplier, this.timing.maxBackoffMs);
|
|
1930
|
-
effectiveMinInterval = this.timing.minAdRequestIntervalMs + (this.timing.consecutiveFailures > 0 ? backoffDelay : 0);
|
|
1931
|
-
timeSinceLastRequest = Date.now() - this.timing.lastAdRequestTime;
|
|
1932
|
-
if (!(timeSinceLastRequest < effectiveMinInterval)) return [
|
|
1933
|
-
3,
|
|
1934
|
-
2
|
|
1935
|
-
];
|
|
1936
|
-
waitTime = effectiveMinInterval - timeSinceLastRequest;
|
|
1937
|
-
if (this.debug) {
|
|
1938
|
-
console.log("[CONTINUOUS-FETCH] Rate limiting: waiting ".concat(waitTime, "ms before next request (backoff: ").concat(this.timing.consecutiveFailures, " failures)"));
|
|
1939
|
-
}
|
|
1940
|
-
return [
|
|
1941
|
-
4,
|
|
1942
|
-
new Promise(function(resolve) {
|
|
1943
|
-
return setTimeout(resolve, waitTime);
|
|
1944
|
-
})
|
|
1945
|
-
];
|
|
1946
|
-
case 1:
|
|
1947
|
-
_state.sent();
|
|
1948
|
-
_state.label = 2;
|
|
1949
|
-
case 2:
|
|
1950
|
-
if (!this.inAdBreak || epoch !== this.timing.adBreakEpoch) {
|
|
1951
|
-
return [
|
|
1952
|
-
2
|
|
1953
|
-
];
|
|
1954
|
-
}
|
|
1955
|
-
return [
|
|
1956
|
-
2,
|
|
1957
|
-
this.tryNextAvailableAd(0)
|
|
1958
|
-
];
|
|
2138
|
+
// Per-request diagnostics
|
|
2139
|
+
// ───────────────────────────────────────────────────────────────
|
|
2140
|
+
key: "recordRequestDiagnostic",
|
|
2141
|
+
value: function recordRequestDiagnostic(payload) {
|
|
2142
|
+
var requestId = payload.requestId;
|
|
2143
|
+
if (typeof requestId !== "number") return;
|
|
2144
|
+
var diag = this.requestDiagnostics.get(requestId);
|
|
2145
|
+
if (!diag) return;
|
|
2146
|
+
switch(payload.stage){
|
|
2147
|
+
case "gam_http_request_sent":
|
|
2148
|
+
diag.gamRequestSent++;
|
|
2149
|
+
break;
|
|
2150
|
+
case "gam_response_received":
|
|
2151
|
+
diag.vastHttpStatus = payload.httpStatus;
|
|
2152
|
+
break;
|
|
2153
|
+
case "vast_parsed":
|
|
2154
|
+
diag.vastAdCount = payload.adElementCount;
|
|
2155
|
+
break;
|
|
2156
|
+
case "wrapper_fetch":
|
|
2157
|
+
case "inline_resolved":
|
|
2158
|
+
if (typeof payload.depth === "number") {
|
|
2159
|
+
diag.wrapperDepth = Math.max(diag.wrapperDepth, payload.depth);
|
|
1959
2160
|
}
|
|
1960
|
-
|
|
1961
|
-
|
|
2161
|
+
if (payload.stage === "inline_resolved") diag.inlineResolved = true;
|
|
2162
|
+
break;
|
|
2163
|
+
case "mediafile_evaluated":
|
|
2164
|
+
diag.mediaCandidateCount++;
|
|
2165
|
+
if (payload.whyAccepted) diag.supportedMediaCount++;
|
|
2166
|
+
break;
|
|
2167
|
+
case "playing":
|
|
2168
|
+
diag.playStarted = true;
|
|
2169
|
+
break;
|
|
2170
|
+
case "impression_fired":
|
|
2171
|
+
diag.impressionFired = true;
|
|
2172
|
+
break;
|
|
2173
|
+
default:
|
|
2174
|
+
if (REQUEST_FAILURE_STAGES.has(payload.stage) && !diag.failureReason) {
|
|
2175
|
+
diag.failureReason = payload.reason ? "".concat(payload.stage, ":").concat(payload.reason) : payload.stage;
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
1962
2178
|
}
|
|
1963
2179
|
},
|
|
1964
2180
|
{
|
|
1965
|
-
key: "
|
|
1966
|
-
value: function
|
|
1967
|
-
var
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
];
|
|
1987
|
-
}
|
|
1988
|
-
if (this.timing.isGamInCooldown()) {
|
|
1989
|
-
if (this.debug) {
|
|
1990
|
-
console.log("[CIRCUIT-BREAKER] GAM in cooldown, ending ad break gracefully");
|
|
1991
|
-
}
|
|
1992
|
-
this.handleAdPodComplete();
|
|
1993
|
-
return [
|
|
1994
|
-
2
|
|
1995
|
-
];
|
|
1996
|
-
}
|
|
1997
|
-
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
1998
|
-
if (this.debug) {
|
|
1999
|
-
console.log("[CONTINUOUS-FETCH] Too many consecutive failures (".concat(this.timing.consecutiveFailures, "), ending ad break"));
|
|
2000
|
-
}
|
|
2001
|
-
this.handleAdPodComplete();
|
|
2002
|
-
return [
|
|
2003
|
-
2
|
|
2004
|
-
];
|
|
2005
|
-
}
|
|
2006
|
-
this.timing.cleanupTemporaryFailures();
|
|
2007
|
-
_state.label = 1;
|
|
2008
|
-
case 1:
|
|
2009
|
-
if (!(this.adRequestQueue.length > 0)) return [
|
|
2010
|
-
3,
|
|
2011
|
-
9
|
|
2012
|
-
];
|
|
2013
|
-
nextAdUrl = this.adRequestQueue.shift();
|
|
2014
|
-
if (!nextAdUrl) return [
|
|
2015
|
-
3,
|
|
2016
|
-
1
|
|
2017
|
-
];
|
|
2018
|
-
if (this.timing.failedVastUrls.has(nextAdUrl)) {
|
|
2019
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping permanently-failed URL, trying next...");
|
|
2020
|
-
return [
|
|
2021
|
-
3,
|
|
2022
|
-
1
|
|
2023
|
-
];
|
|
2024
|
-
}
|
|
2025
|
-
if (this.timing.isUrlInCooldown(nextAdUrl)) {
|
|
2026
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping URL in cooldown (recent no-fill), trying next...");
|
|
2027
|
-
return [
|
|
2028
|
-
3,
|
|
2029
|
-
1
|
|
2030
|
-
];
|
|
2031
|
-
}
|
|
2032
|
-
if (this.debug) {
|
|
2033
|
-
console.log("[CONTINUOUS-FETCH] Requesting next ad via HLS ad player (".concat(this.timing.currentAdIndex + 1, ", ").concat(this.adRequestQueue.length, " remaining in queue)"));
|
|
2034
|
-
}
|
|
2035
|
-
_state.label = 2;
|
|
2036
|
-
case 2:
|
|
2037
|
-
_state.trys.push([
|
|
2038
|
-
2,
|
|
2039
|
-
4,
|
|
2040
|
-
,
|
|
2041
|
-
8
|
|
2042
|
-
]);
|
|
2043
|
-
return [
|
|
2044
|
-
4,
|
|
2045
|
-
this.playSingleAd(nextAdUrl)
|
|
2046
|
-
];
|
|
2047
|
-
case 3:
|
|
2048
|
-
_state.sent();
|
|
2049
|
-
this.timing.consecutiveFailures = 0;
|
|
2050
|
-
return [
|
|
2051
|
-
3,
|
|
2052
|
-
8
|
|
2053
|
-
];
|
|
2054
|
-
case 4:
|
|
2055
|
-
error = _state.sent();
|
|
2056
|
-
errorMessage = error.message;
|
|
2057
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Ad request failed:", errorMessage);
|
|
2058
|
-
if (!errorMessage.includes("ad_duration_exceeds_budget")) return [
|
|
2059
|
-
3,
|
|
2060
|
-
6
|
|
2061
|
-
];
|
|
2062
|
-
return [
|
|
2063
|
-
4,
|
|
2064
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
2065
|
-
];
|
|
2066
|
-
case 5:
|
|
2067
|
-
_state.sent();
|
|
2068
|
-
return [
|
|
2069
|
-
2
|
|
2070
|
-
];
|
|
2071
|
-
case 6:
|
|
2072
|
-
if (!errorMessage.includes("permanently failed") && !errorMessage.includes("in cooldown")) {
|
|
2073
|
-
this.timing.consecutiveFailures++;
|
|
2074
|
-
}
|
|
2075
|
-
return [
|
|
2076
|
-
4,
|
|
2077
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
2078
|
-
];
|
|
2079
|
-
case 7:
|
|
2080
|
-
_state.sent();
|
|
2081
|
-
return [
|
|
2082
|
-
3,
|
|
2083
|
-
8
|
|
2084
|
-
];
|
|
2085
|
-
case 8:
|
|
2086
|
-
return [
|
|
2087
|
-
2
|
|
2088
|
-
];
|
|
2089
|
-
case 9:
|
|
2090
|
-
maxRetries = 3;
|
|
2091
|
-
if (!(this.continuousFetchingActive && retryCount < maxRetries && remaining > 2e3)) return [
|
|
2092
|
-
3,
|
|
2093
|
-
12
|
|
2094
|
-
];
|
|
2095
|
-
if (this.debug) {
|
|
2096
|
-
console.log("[CONTINUOUS-FETCH] Queue empty, waiting for URLs... (".concat(retryCount + 1, "/").concat(maxRetries, ")"));
|
|
2097
|
-
}
|
|
2098
|
-
return [
|
|
2099
|
-
4,
|
|
2100
|
-
new Promise(function(resolve) {
|
|
2101
|
-
return setTimeout(resolve, 500);
|
|
2102
|
-
})
|
|
2103
|
-
];
|
|
2104
|
-
case 10:
|
|
2105
|
-
_state.sent();
|
|
2106
|
-
return [
|
|
2107
|
-
4,
|
|
2108
|
-
this.tryNextAvailableAd(retryCount + 1)
|
|
2109
|
-
];
|
|
2110
|
-
case 11:
|
|
2111
|
-
_state.sent();
|
|
2112
|
-
return [
|
|
2113
|
-
2
|
|
2114
|
-
];
|
|
2115
|
-
case 12:
|
|
2116
|
-
if (!this.isShowingPlaceholder && remaining > 1e3) {
|
|
2117
|
-
this.showPlaceholderAndWaitForAds();
|
|
2118
|
-
} else {
|
|
2119
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] No more ads available, ending ad break");
|
|
2120
|
-
this.handleAdPodComplete();
|
|
2121
|
-
}
|
|
2122
|
-
return [
|
|
2123
|
-
2
|
|
2124
|
-
];
|
|
2125
|
-
}
|
|
2126
|
-
});
|
|
2127
|
-
}).call(this);
|
|
2181
|
+
key: "finalizeRequestDiagnostics",
|
|
2182
|
+
value: function finalizeRequestDiagnostics(requestId, endReason) {
|
|
2183
|
+
var _diag_vastAdCount;
|
|
2184
|
+
if (requestId == null) return;
|
|
2185
|
+
var diag = this.requestDiagnostics.get(requestId);
|
|
2186
|
+
if (!diag) return;
|
|
2187
|
+
this.requestDiagnostics.delete(requestId);
|
|
2188
|
+
if (!diag.impressionFired && !diag.failureReason && endReason) {
|
|
2189
|
+
diag.failureReason = endReason;
|
|
2190
|
+
}
|
|
2191
|
+
var gamReturnedAdWithoutImpression = ((_diag_vastAdCount = diag.vastAdCount) !== null && _diag_vastAdCount !== void 0 ? _diag_vastAdCount : 0) > 0 && !diag.impressionFired;
|
|
2192
|
+
if (gamReturnedAdWithoutImpression) {
|
|
2193
|
+
this.countFunnelStage("gam_ad_without_impression");
|
|
2194
|
+
}
|
|
2195
|
+
var startedAt = diag.startedAt, fields = _object_without_properties(diag, [
|
|
2196
|
+
"startedAt"
|
|
2197
|
+
]);
|
|
2198
|
+
console.log("[AdBreak][REQUEST] summary", _object_spread_props(_object_spread({}, fields), {
|
|
2199
|
+
durationMs: Date.now() - startedAt,
|
|
2200
|
+
gamReturnedAdWithoutImpression: gamReturnedAdWithoutImpression
|
|
2201
|
+
}));
|
|
2128
2202
|
}
|
|
2129
2203
|
},
|
|
2130
2204
|
{
|
|
@@ -2132,7 +2206,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
2132
2206
|
// Single ad playback
|
|
2133
2207
|
// ───────────────────────────────────────────────────────────────
|
|
2134
2208
|
key: "withCurrentPodBudget",
|
|
2135
|
-
value: function withCurrentPodBudget(
|
|
2209
|
+
value: function withCurrentPodBudget(rawVastTagUrl) {
|
|
2210
|
+
var vastTagUrl = ensureVideoAdType(rawVastTagUrl);
|
|
2136
2211
|
var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
|
|
2137
2212
|
if (!(remaining > 0)) return vastTagUrl;
|
|
2138
2213
|
try {
|
|
@@ -2151,23 +2226,174 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
2151
2226
|
}
|
|
2152
2227
|
},
|
|
2153
2228
|
{
|
|
2154
|
-
key: "
|
|
2155
|
-
value: function
|
|
2229
|
+
key: "countFunnelStage",
|
|
2230
|
+
value: function countFunnelStage(stage) {
|
|
2231
|
+
var amount = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1;
|
|
2232
|
+
var _this_breakFunnel_stage;
|
|
2233
|
+
this.breakFunnel[stage] = ((_this_breakFunnel_stage = this.breakFunnel[stage]) !== null && _this_breakFunnel_stage !== void 0 ? _this_breakFunnel_stage : 0) + amount;
|
|
2234
|
+
}
|
|
2235
|
+
},
|
|
2236
|
+
{
|
|
2237
|
+
key: "logOrchestratorFunnel",
|
|
2238
|
+
value: function logOrchestratorFunnel(stage) {
|
|
2239
|
+
var extra = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
2240
|
+
this.countFunnelStage(stage);
|
|
2241
|
+
console.log("[AdBreak][FUNNEL] ".concat(stage), _object_spread({
|
|
2242
|
+
breakId: this.timing.adBreakEpoch,
|
|
2243
|
+
requestId: this.currentRequestId,
|
|
2244
|
+
visibilityState: typeof document !== "undefined" ? document.visibilityState : void 0
|
|
2245
|
+
}, extra));
|
|
2246
|
+
}
|
|
2247
|
+
},
|
|
2248
|
+
{
|
|
2249
|
+
key: "noteOpportunity",
|
|
2250
|
+
value: function noteOpportunity(source, breakKey) {
|
|
2251
|
+
if (breakKey && breakKey === this.opportunityBreakKey && this.opportunityEpoch === this.timing.adBreakEpoch) {
|
|
2252
|
+
this.logOrchestratorFunnel("duplicate_break_start", {
|
|
2253
|
+
source: source,
|
|
2254
|
+
breakKey: breakKey
|
|
2255
|
+
});
|
|
2256
|
+
return;
|
|
2257
|
+
}
|
|
2258
|
+
this.opportunityBreakKey = breakKey;
|
|
2259
|
+
this.opportunityEpoch = this.timing.adBreakEpoch;
|
|
2260
|
+
this.logOrchestratorFunnel("opportunity_created", {
|
|
2261
|
+
source: source,
|
|
2262
|
+
breakKey: breakKey,
|
|
2263
|
+
expectedDurationMs: this.timing.expectedAdBreakDurationMs
|
|
2264
|
+
});
|
|
2265
|
+
}
|
|
2266
|
+
},
|
|
2267
|
+
{
|
|
2268
|
+
key: "beginFunnelRequest",
|
|
2269
|
+
value: function beginFunnelRequest(adPlayer, requestToken, trigger) {
|
|
2270
|
+
var _adPlayer_setFunnelContext;
|
|
2271
|
+
if (this.controllerCallInFlight) {
|
|
2272
|
+
this.logOrchestratorFunnel("duplicate_request_detected", {
|
|
2273
|
+
newRequestId: requestToken
|
|
2274
|
+
});
|
|
2275
|
+
}
|
|
2276
|
+
this.finalizeRequestDiagnostics(this.currentRequestId);
|
|
2277
|
+
this.currentRequestId = requestToken;
|
|
2278
|
+
this.requestStartedAt = Date.now();
|
|
2279
|
+
this.requestDiagnostics.set(requestToken, {
|
|
2280
|
+
breakId: this.timing.adBreakEpoch,
|
|
2281
|
+
requestId: requestToken,
|
|
2282
|
+
controllerId: this.controllerGeneration,
|
|
2283
|
+
trigger: trigger,
|
|
2284
|
+
gamRequestSent: 0,
|
|
2285
|
+
wrapperDepth: 0,
|
|
2286
|
+
inlineResolved: false,
|
|
2287
|
+
mediaCandidateCount: 0,
|
|
2288
|
+
supportedMediaCount: 0,
|
|
2289
|
+
playStarted: false,
|
|
2290
|
+
impressionFired: false,
|
|
2291
|
+
startedAt: Date.now()
|
|
2292
|
+
});
|
|
2293
|
+
(_adPlayer_setFunnelContext = adPlayer.setFunnelContext) === null || _adPlayer_setFunnelContext === void 0 ? void 0 : _adPlayer_setFunnelContext.call(adPlayer, {
|
|
2294
|
+
breakId: this.timing.adBreakEpoch,
|
|
2295
|
+
requestId: requestToken,
|
|
2296
|
+
controllerId: this.controllerGeneration
|
|
2297
|
+
});
|
|
2298
|
+
}
|
|
2299
|
+
},
|
|
2300
|
+
{
|
|
2301
|
+
key: "isAdLoadingWithoutPlayback",
|
|
2302
|
+
value: function isAdLoadingWithoutPlayback() {
|
|
2303
|
+
return this.host.getAdPlayer().isAdPlaying() && !this.playbackStartedForCurrentRequest;
|
|
2304
|
+
}
|
|
2305
|
+
},
|
|
2306
|
+
{
|
|
2307
|
+
key: "noteStopBeforeStart",
|
|
2308
|
+
value: function noteStopBeforeStart(reason) {
|
|
2309
|
+
if (!this.isAdLoadingWithoutPlayback()) return;
|
|
2310
|
+
this.logOrchestratorFunnel("ad_stopped_before_start", {
|
|
2311
|
+
reason: reason,
|
|
2312
|
+
elapsedSinceRequestMs: this.requestStartedAt != null ? Date.now() - this.requestStartedAt : void 0
|
|
2313
|
+
});
|
|
2314
|
+
}
|
|
2315
|
+
},
|
|
2316
|
+
{
|
|
2317
|
+
key: "handleRequestWatchdogTimeout",
|
|
2318
|
+
value: function handleRequestWatchdogTimeout() {
|
|
2319
|
+
var adPlayer = this.host.getAdPlayer();
|
|
2320
|
+
if (this.controllerCallInFlight && adPlayer.abortPendingRequest) {
|
|
2321
|
+
this.logOrchestratorFunnel("request_aborted_timeout", {
|
|
2322
|
+
elapsedSinceRequestMs: this.requestStartedAt != null ? Date.now() - this.requestStartedAt : void 0
|
|
2323
|
+
});
|
|
2324
|
+
adPlayer.abortPendingRequest("VAST request aborted after request watchdog timeout");
|
|
2325
|
+
return;
|
|
2326
|
+
}
|
|
2327
|
+
this.handleAdFailure("request_watchdog_timeout");
|
|
2328
|
+
}
|
|
2329
|
+
},
|
|
2330
|
+
{
|
|
2331
|
+
key: "callController",
|
|
2332
|
+
value: function callController(call) {
|
|
2156
2333
|
return _async_to_generator(function() {
|
|
2157
|
-
var adPlayer, requestToken, ap, requestUrl, playError, error, errorMessage;
|
|
2158
2334
|
return _ts_generator(this, function(_state) {
|
|
2159
2335
|
switch(_state.label){
|
|
2160
2336
|
case 0:
|
|
2161
|
-
|
|
2162
|
-
|
|
2337
|
+
this.controllerCallInFlight = true;
|
|
2338
|
+
_state.label = 1;
|
|
2339
|
+
case 1:
|
|
2340
|
+
_state.trys.push([
|
|
2341
|
+
1,
|
|
2342
|
+
,
|
|
2343
|
+
3,
|
|
2344
|
+
4
|
|
2345
|
+
]);
|
|
2346
|
+
return [
|
|
2347
|
+
4,
|
|
2348
|
+
call()
|
|
2349
|
+
];
|
|
2350
|
+
case 2:
|
|
2351
|
+
_state.sent();
|
|
2352
|
+
return [
|
|
2353
|
+
3,
|
|
2354
|
+
4
|
|
2355
|
+
];
|
|
2356
|
+
case 3:
|
|
2357
|
+
this.controllerCallInFlight = false;
|
|
2358
|
+
return [
|
|
2359
|
+
7
|
|
2360
|
+
];
|
|
2361
|
+
case 4:
|
|
2362
|
+
return [
|
|
2163
2363
|
2
|
|
2164
2364
|
];
|
|
2365
|
+
}
|
|
2366
|
+
});
|
|
2367
|
+
}).call(this);
|
|
2368
|
+
}
|
|
2369
|
+
},
|
|
2370
|
+
{
|
|
2371
|
+
key: "playSingleAd",
|
|
2372
|
+
value: function playSingleAd(vastTagUrl) {
|
|
2373
|
+
var trigger = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "vmap";
|
|
2374
|
+
return _async_to_generator(function() {
|
|
2375
|
+
var epoch, generation, requestToken, ap, requestUrl, _ap_getLoadedAdDuration, adDurationS, remainingMs, error;
|
|
2376
|
+
return _ts_generator(this, function(_state) {
|
|
2377
|
+
switch(_state.label){
|
|
2378
|
+
case 0:
|
|
2379
|
+
if (this.slotState === "REQUESTING" || this.slotState === "READY" || this.slotState === "PLAYING" || this.slotState === "ENDING") {
|
|
2380
|
+
this.logOrchestratorFunnel("request_suppressed", {
|
|
2381
|
+
trigger: trigger,
|
|
2382
|
+
state: this.slotState,
|
|
2383
|
+
why: "request_in_flight"
|
|
2384
|
+
});
|
|
2385
|
+
return [
|
|
2386
|
+
2
|
|
2387
|
+
];
|
|
2388
|
+
}
|
|
2165
2389
|
if (this.timing.failedVastUrls.has(vastTagUrl)) {
|
|
2166
2390
|
if (this.debug) console.warn("[AD-ERROR] Skipping permanently-failed VAST URL:", vastTagUrl);
|
|
2391
|
+
this.timing.consecutiveFailures++;
|
|
2167
2392
|
throw new Error("VAST URL permanently failed");
|
|
2168
2393
|
}
|
|
2169
2394
|
if (this.timing.isUrlInCooldown(vastTagUrl)) {
|
|
2170
2395
|
if (this.debug) console.warn("[AD-ERROR] Skipping URL in cooldown (recent no-fill):", vastTagUrl);
|
|
2396
|
+
this.timing.consecutiveFailures++;
|
|
2171
2397
|
throw new Error("VAST URL in cooldown after no-fill");
|
|
2172
2398
|
}
|
|
2173
2399
|
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
@@ -2178,16 +2404,23 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
2178
2404
|
if (this.debug) console.warn("[CIRCUIT-BREAKER] GAM in cooldown, skipping ad request");
|
|
2179
2405
|
throw new Error("GAM in cooldown");
|
|
2180
2406
|
}
|
|
2181
|
-
this.
|
|
2407
|
+
epoch = this.timing.adBreakEpoch;
|
|
2408
|
+
this.recreateAdController("new_request");
|
|
2409
|
+
generation = this.controllerGeneration;
|
|
2182
2410
|
requestToken = ++this.timing.adRequestTokenCounter;
|
|
2183
2411
|
this.timing.activeAdRequestToken = requestToken;
|
|
2412
|
+
ap = this.host.getAdPlayer();
|
|
2413
|
+
requestUrl = this.withCurrentPodBudget(vastTagUrl);
|
|
2414
|
+
this.currentVastUrl = requestUrl;
|
|
2415
|
+
this.setSlotState("REQUESTING", trigger);
|
|
2416
|
+
this.beginFunnelRequest(ap, requestToken, trigger);
|
|
2184
2417
|
_state.label = 1;
|
|
2185
2418
|
case 1:
|
|
2186
2419
|
_state.trys.push([
|
|
2187
2420
|
1,
|
|
2188
|
-
|
|
2421
|
+
5,
|
|
2189
2422
|
,
|
|
2190
|
-
|
|
2423
|
+
6
|
|
2191
2424
|
]);
|
|
2192
2425
|
return [
|
|
2193
2426
|
4,
|
|
@@ -2195,265 +2428,87 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
2195
2428
|
];
|
|
2196
2429
|
case 2:
|
|
2197
2430
|
_state.sent();
|
|
2431
|
+
if (this.isStale(epoch, generation)) return [
|
|
2432
|
+
2
|
|
2433
|
+
];
|
|
2198
2434
|
this.timing.startAdRequestWatchdog(requestToken);
|
|
2199
|
-
this.timing.lastAdRequestTime = Date.now();
|
|
2200
|
-
ap = this.host.getAdPlayer();
|
|
2201
|
-
requestUrl = this.withCurrentPodBudget(vastTagUrl);
|
|
2202
|
-
this.currentVastUrl = requestUrl;
|
|
2203
2435
|
return [
|
|
2204
2436
|
4,
|
|
2205
|
-
|
|
2437
|
+
this.callController(function() {
|
|
2438
|
+
return ap.requestAds(requestUrl);
|
|
2439
|
+
})
|
|
2206
2440
|
];
|
|
2207
2441
|
case 3:
|
|
2208
2442
|
_state.sent();
|
|
2443
|
+
this.timing.clearAdRequestWatchdog();
|
|
2444
|
+
if (this.isStale(epoch, generation)) {
|
|
2445
|
+
this.logOrchestratorFunnel("stale_request_result_ignored", {
|
|
2446
|
+
requestId: requestToken
|
|
2447
|
+
});
|
|
2448
|
+
return [
|
|
2449
|
+
2
|
|
2450
|
+
];
|
|
2451
|
+
}
|
|
2209
2452
|
sendAdLoadedTracking(this.host.config.licenseKey, {
|
|
2210
2453
|
source: "hls",
|
|
2211
2454
|
vastUrl: requestUrl,
|
|
2212
2455
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
2213
2456
|
}, this.analyticsContext).catch(function() {});
|
|
2214
|
-
this.timing.clearAdRequestWatchdog();
|
|
2215
|
-
if (this.timing.activeAdRequestToken !== requestToken) return [
|
|
2216
|
-
2
|
|
2217
|
-
];
|
|
2218
2457
|
if (!this.timing.ensureLoadedAdFitsBudget(ap)) {
|
|
2219
|
-
|
|
2220
|
-
|
|
2458
|
+
;
|
|
2459
|
+
adDurationS = (_ap_getLoadedAdDuration = ap.getLoadedAdDuration) === null || _ap_getLoadedAdDuration === void 0 ? void 0 : _ap_getLoadedAdDuration.call(ap);
|
|
2460
|
+
remainingMs = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
|
|
2461
|
+
this.logOrchestratorFunnel("discarded_budget", {
|
|
2462
|
+
adDurationMs: adDurationS != null ? adDurationS * 1e3 : void 0,
|
|
2463
|
+
remainingMs: remainingMs
|
|
2464
|
+
});
|
|
2221
2465
|
throw new Error("ad_duration_exceeds_budget");
|
|
2222
2466
|
}
|
|
2223
|
-
|
|
2224
|
-
case 4:
|
|
2225
|
-
_state.trys.push([
|
|
2226
|
-
4,
|
|
2227
|
-
6,
|
|
2228
|
-
,
|
|
2229
|
-
7
|
|
2230
|
-
]);
|
|
2467
|
+
this.setSlotState("READY", "vast_ready");
|
|
2231
2468
|
this.timing.startAdFailsafeTimer(requestToken);
|
|
2232
2469
|
return [
|
|
2233
2470
|
4,
|
|
2234
|
-
|
|
2471
|
+
this.callController(function() {
|
|
2472
|
+
return ap.play();
|
|
2473
|
+
})
|
|
2235
2474
|
];
|
|
2236
|
-
case
|
|
2475
|
+
case 4:
|
|
2237
2476
|
_state.sent();
|
|
2238
|
-
this.
|
|
2477
|
+
if (this.isStale(epoch, generation)) return [
|
|
2478
|
+
2
|
|
2479
|
+
];
|
|
2239
2480
|
if (this.timing.expectedAdBreakDurationMs != null && this.timing.getAdBreakEndWallClockMs() == null) {
|
|
2240
2481
|
this.timing.scheduleAdStopAtBreakBoundary();
|
|
2241
2482
|
}
|
|
2242
2483
|
ap.setAdVolume(getAdAudioVolume(ap));
|
|
2243
|
-
this.timing.consecutiveFailures = 0;
|
|
2244
2484
|
this.timing.temporaryFailureUrls.delete(vastTagUrl);
|
|
2245
2485
|
return [
|
|
2246
2486
|
3,
|
|
2247
|
-
|
|
2248
|
-
];
|
|
2249
|
-
case 6:
|
|
2250
|
-
playError = _state.sent();
|
|
2251
|
-
if (this.debug) console.error("[AD-ERROR] Failed to play ad:", playError);
|
|
2252
|
-
if (this.timing.isTemporaryAdError(playError)) {
|
|
2253
|
-
this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
|
|
2254
|
-
if (this.debug) console.log("[AD-ERROR] Temporary play error - URL can be retried after cooldown");
|
|
2255
|
-
} else {
|
|
2256
|
-
this.timing.failedVastUrls.add(vastTagUrl);
|
|
2257
|
-
if (this.debug) console.log("[AD-ERROR] Permanent play error - URL blacklisted");
|
|
2258
|
-
}
|
|
2259
|
-
this.timing.clearAdFailsafeTimer();
|
|
2260
|
-
if (this.timing.activeAdRequestToken === requestToken) {
|
|
2261
|
-
this.timing.activeAdRequestToken = null;
|
|
2262
|
-
}
|
|
2263
|
-
throw playError;
|
|
2264
|
-
case 7:
|
|
2265
|
-
return [
|
|
2266
|
-
3,
|
|
2267
|
-
9
|
|
2487
|
+
6
|
|
2268
2488
|
];
|
|
2269
|
-
case
|
|
2489
|
+
case 5:
|
|
2270
2490
|
error = _state.sent();
|
|
2271
|
-
errorMessage = (error === null || error === void 0 ? void 0 : error.message) || "";
|
|
2272
|
-
if (this.debug) console.error("[AD-ERROR] Ad request failed:", errorMessage);
|
|
2273
|
-
if (this.timing.isTemporaryAdError(error)) {
|
|
2274
|
-
this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
|
|
2275
|
-
if (this.debug) console.log("[AD-ERROR] Temporary error (no-fill/timeout) - URL can be retried after cooldown");
|
|
2276
|
-
} else {
|
|
2277
|
-
this.timing.failedVastUrls.add(vastTagUrl);
|
|
2278
|
-
if (this.debug) console.log("[AD-ERROR] Permanent error - URL blacklisted:", errorMessage);
|
|
2279
|
-
}
|
|
2280
2491
|
this.timing.clearAdRequestWatchdog();
|
|
2281
2492
|
this.timing.clearAdFailsafeTimer();
|
|
2282
2493
|
if (this.timing.activeAdRequestToken === requestToken) {
|
|
2283
2494
|
this.timing.activeAdRequestToken = null;
|
|
2284
2495
|
}
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
}
|
|
2291
|
-
});
|
|
2292
|
-
}).call(this);
|
|
2293
|
-
}
|
|
2294
|
-
},
|
|
2295
|
-
{
|
|
2296
|
-
key: "showPlaceholderAndWaitForAds",
|
|
2297
|
-
value: // ───────────────────────────────────────────────────────────────
|
|
2298
|
-
// Placeholder wait
|
|
2299
|
-
// ───────────────────────────────────────────────────────────────
|
|
2300
|
-
function showPlaceholderAndWaitForAds() {
|
|
2301
|
-
return _async_to_generator(function() {
|
|
2302
|
-
var remaining, waitTime, checkInterval, maxChecks, i, nextAdUrl, error, errorMessage;
|
|
2303
|
-
return _ts_generator(this, function(_state) {
|
|
2304
|
-
switch(_state.label){
|
|
2305
|
-
case 0:
|
|
2306
|
-
remaining = this.timing.getRemainingAdMs();
|
|
2307
|
-
waitTime = Math.min(this.maxPlaceholderDurationMs, remaining);
|
|
2308
|
-
if (this.timing.isGamInCooldown()) {
|
|
2309
|
-
if (this.debug) console.log("[CIRCUIT-BREAKER] GAM in cooldown, skipping placeholder wait");
|
|
2310
|
-
this.handleAdPodComplete();
|
|
2311
|
-
return [
|
|
2312
|
-
2
|
|
2313
|
-
];
|
|
2314
|
-
}
|
|
2315
|
-
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
2316
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Skipping placeholder - too many consecutive failures");
|
|
2317
|
-
this.handleAdPodComplete();
|
|
2318
|
-
return [
|
|
2319
|
-
2
|
|
2320
|
-
];
|
|
2321
|
-
}
|
|
2322
|
-
if (waitTime < 1e3) {
|
|
2323
|
-
this.handleAdPodComplete();
|
|
2496
|
+
if (this.isStale(epoch, generation)) {
|
|
2497
|
+
this.logOrchestratorFunnel("stale_request_result_ignored", {
|
|
2498
|
+
requestId: requestToken,
|
|
2499
|
+
errorMessage: error === null || error === void 0 ? void 0 : error.message
|
|
2500
|
+
});
|
|
2324
2501
|
return [
|
|
2325
2502
|
2
|
|
2326
2503
|
];
|
|
2327
2504
|
}
|
|
2328
|
-
if (this.debug)
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
this.host.getAdPlayer().showPlaceholder();
|
|
2333
|
-
checkInterval = 300;
|
|
2334
|
-
maxChecks = Math.floor(waitTime / checkInterval);
|
|
2335
|
-
i = 0;
|
|
2336
|
-
_state.label = 1;
|
|
2337
|
-
case 1:
|
|
2338
|
-
if (!(i < maxChecks)) return [
|
|
2339
|
-
3,
|
|
2340
|
-
12
|
|
2341
|
-
];
|
|
2342
|
-
return [
|
|
2343
|
-
4,
|
|
2344
|
-
new Promise(function(resolve) {
|
|
2345
|
-
return setTimeout(resolve, checkInterval);
|
|
2346
|
-
})
|
|
2347
|
-
];
|
|
2348
|
-
case 2:
|
|
2349
|
-
_state.sent();
|
|
2350
|
-
if (!this.inAdBreak) return [
|
|
2351
|
-
2
|
|
2352
|
-
];
|
|
2353
|
-
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
2354
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Too many failures during placeholder wait");
|
|
2355
|
-
return [
|
|
2356
|
-
3,
|
|
2357
|
-
12
|
|
2358
|
-
];
|
|
2359
|
-
}
|
|
2360
|
-
if (!this.timing.hasTimeToStartAnotherAd()) {
|
|
2361
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Not enough time remaining during placeholder wait, ending ad break");
|
|
2362
|
-
return [
|
|
2363
|
-
3,
|
|
2364
|
-
12
|
|
2365
|
-
];
|
|
2505
|
+
if (this.debug) console.error("[AD-ERROR] Ad request failed:", error === null || error === void 0 ? void 0 : error.message);
|
|
2506
|
+
this.recordRequestFailure(error, vastTagUrl);
|
|
2507
|
+
if ((error === null || error === void 0 ? void 0 : error.message) === "ad_duration_exceeds_budget") {
|
|
2508
|
+
this.recreateAdController("discarded_budget");
|
|
2366
2509
|
}
|
|
2367
|
-
|
|
2368
|
-
case 3:
|
|
2369
|
-
if (!(this.adRequestQueue.length > 0)) return [
|
|
2370
|
-
3,
|
|
2371
|
-
11
|
|
2372
|
-
];
|
|
2373
|
-
if (!this.timing.hasTimeToStartAnotherAd()) return [
|
|
2374
|
-
3,
|
|
2375
|
-
11
|
|
2376
|
-
];
|
|
2377
|
-
nextAdUrl = this.adRequestQueue.shift();
|
|
2378
|
-
if (!nextAdUrl) return [
|
|
2379
|
-
3,
|
|
2380
|
-
3
|
|
2381
|
-
];
|
|
2382
|
-
if (this.timing.failedVastUrls.has(nextAdUrl)) return [
|
|
2383
|
-
3,
|
|
2384
|
-
3
|
|
2385
|
-
];
|
|
2386
|
-
if (this.timing.isUrlInCooldown(nextAdUrl)) return [
|
|
2387
|
-
3,
|
|
2388
|
-
3
|
|
2389
|
-
];
|
|
2390
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Ad URL available, requesting via HLS ad player");
|
|
2391
|
-
this.isShowingPlaceholder = false;
|
|
2392
|
-
this.host.getAdPlayer().hidePlaceholder();
|
|
2393
|
-
_state.label = 4;
|
|
2394
|
-
case 4:
|
|
2395
|
-
_state.trys.push([
|
|
2396
|
-
4,
|
|
2397
|
-
6,
|
|
2398
|
-
,
|
|
2399
|
-
10
|
|
2400
|
-
]);
|
|
2401
|
-
return [
|
|
2402
|
-
4,
|
|
2403
|
-
this.playSingleAd(nextAdUrl)
|
|
2404
|
-
];
|
|
2405
|
-
case 5:
|
|
2406
|
-
_state.sent();
|
|
2407
|
-
this.timing.consecutiveFailures = 0;
|
|
2408
|
-
return [
|
|
2409
|
-
3,
|
|
2410
|
-
10
|
|
2411
|
-
];
|
|
2510
|
+
throw error;
|
|
2412
2511
|
case 6:
|
|
2413
|
-
error = _state.sent();
|
|
2414
|
-
errorMessage = error.message;
|
|
2415
|
-
if (!errorMessage.includes("ad_duration_exceeds_budget")) return [
|
|
2416
|
-
3,
|
|
2417
|
-
8
|
|
2418
|
-
];
|
|
2419
|
-
return [
|
|
2420
|
-
4,
|
|
2421
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
2422
|
-
];
|
|
2423
|
-
case 7:
|
|
2424
|
-
_state.sent();
|
|
2425
|
-
return [
|
|
2426
|
-
2
|
|
2427
|
-
];
|
|
2428
|
-
case 8:
|
|
2429
|
-
if (!errorMessage.includes("permanently failed") && !errorMessage.includes("in cooldown")) {
|
|
2430
|
-
this.timing.consecutiveFailures++;
|
|
2431
|
-
}
|
|
2432
|
-
return [
|
|
2433
|
-
4,
|
|
2434
|
-
this.tryNextAvailableAdWithRateLimit()
|
|
2435
|
-
];
|
|
2436
|
-
case 9:
|
|
2437
|
-
_state.sent();
|
|
2438
|
-
return [
|
|
2439
|
-
3,
|
|
2440
|
-
10
|
|
2441
|
-
];
|
|
2442
|
-
case 10:
|
|
2443
|
-
return [
|
|
2444
|
-
2
|
|
2445
|
-
];
|
|
2446
|
-
case 11:
|
|
2447
|
-
i++;
|
|
2448
|
-
return [
|
|
2449
|
-
3,
|
|
2450
|
-
1
|
|
2451
|
-
];
|
|
2452
|
-
case 12:
|
|
2453
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Placeholder timeout, ending ad break");
|
|
2454
|
-
this.isShowingPlaceholder = false;
|
|
2455
|
-
this.host.getAdPlayer().hidePlaceholder();
|
|
2456
|
-
this.handleAdPodComplete();
|
|
2457
2512
|
return [
|
|
2458
2513
|
2
|
|
2459
2514
|
];
|
|
@@ -2466,26 +2521,136 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
2466
2521
|
// ───────────────────────────────────────────────────────────────
|
|
2467
2522
|
// Ad break completion
|
|
2468
2523
|
// ───────────────────────────────────────────────────────────────
|
|
2524
|
+
key: "logBreakFunnel",
|
|
2525
|
+
value: function logBreakFunnel(endReason) {
|
|
2526
|
+
var funnel = this.breakFunnel;
|
|
2527
|
+
this.breakFunnel = {};
|
|
2528
|
+
if (Object.keys(funnel).length === 0) return;
|
|
2529
|
+
var count = function count(stage) {
|
|
2530
|
+
var _funnel_stage;
|
|
2531
|
+
return (_funnel_stage = funnel[stage]) !== null && _funnel_stage !== void 0 ? _funnel_stage : 0;
|
|
2532
|
+
};
|
|
2533
|
+
var countPrefix = function countPrefix(prefix) {
|
|
2534
|
+
return Object.keys(funnel).reduce(function(total, stage) {
|
|
2535
|
+
var _funnel_stage;
|
|
2536
|
+
return stage.indexOf(prefix) === 0 ? total + ((_funnel_stage = funnel[stage]) !== null && _funnel_stage !== void 0 ? _funnel_stage : 0) : total;
|
|
2537
|
+
}, 0);
|
|
2538
|
+
};
|
|
2539
|
+
var breakId = this.opportunityEpoch;
|
|
2540
|
+
var requestRetries = count("gam_http_request_retry");
|
|
2541
|
+
var requests = count("gam_http_request_sent") - requestRetries;
|
|
2542
|
+
if (requests > 0 && count("impression_fired") === 0) {
|
|
2543
|
+
console.log("[AdBreak][FUNNEL] break_abandoned_before_start", {
|
|
2544
|
+
breakId: breakId,
|
|
2545
|
+
requests: requests,
|
|
2546
|
+
endReason: endReason
|
|
2547
|
+
});
|
|
2548
|
+
}
|
|
2549
|
+
console.log("[AdBreak][FUNNEL] Break summary", {
|
|
2550
|
+
breakId: breakId,
|
|
2551
|
+
endReason: endReason,
|
|
2552
|
+
opportunities: count("opportunity_created"),
|
|
2553
|
+
vastUrlsGenerated: count("vast_url_generated"),
|
|
2554
|
+
requests: requests,
|
|
2555
|
+
requestRetries: requestRetries,
|
|
2556
|
+
gamResponses: count("gam_response_received"),
|
|
2557
|
+
requestsSuppressed: count("request_suppressed"),
|
|
2558
|
+
duplicates: count("duplicate_request_detected") + count("duplicate_break_start"),
|
|
2559
|
+
filled: count("vast_received"),
|
|
2560
|
+
noFill: count("no_fill"),
|
|
2561
|
+
fillRejected: count("vast_fill_rejected"),
|
|
2562
|
+
gamAdWithoutImpression: count("gam_ad_without_impression"),
|
|
2563
|
+
playbackFailedAfterFill: count("request_outcome:playback_failed"),
|
|
2564
|
+
requestFailed: count("request_failed"),
|
|
2565
|
+
requestAbortedTimeout: count("request_aborted_timeout"),
|
|
2566
|
+
credentialsRetries: count("vast_credentials_retry"),
|
|
2567
|
+
wrapperFailures: count("wrapper_fetch:failure"),
|
|
2568
|
+
noSupportedMedia: count("vast_no_supported_media"),
|
|
2569
|
+
vpaidOnly: count("vast_no_supported_media:vpaid"),
|
|
2570
|
+
audioOnly: count("vast_no_supported_media:audio_only"),
|
|
2571
|
+
mediaFilesEvaluated: count("mediafile_evaluated"),
|
|
2572
|
+
mediaFilesAccepted: count("mediafile_evaluated:accepted"),
|
|
2573
|
+
controllerDestroys: countPrefix("controller_destroy:"),
|
|
2574
|
+
staleCallbacks: count("stale_callback_ignored") + count("stale_request_result_ignored"),
|
|
2575
|
+
tagAllowsAudio: count("tag_allows_audio"),
|
|
2576
|
+
missingImpression: count("vast_missing_impression"),
|
|
2577
|
+
discardedBudget: count("discarded_budget"),
|
|
2578
|
+
mediaCandidates: count("media_candidate:accepted") + count("media_candidate:rejected"),
|
|
2579
|
+
mediaRejected: count("media_candidate:rejected"),
|
|
2580
|
+
mediaFallbacks: count("media_fallback"),
|
|
2581
|
+
playCalled: count("play_called"),
|
|
2582
|
+
playRejected: count("play_rejected"),
|
|
2583
|
+
mutedRetry: count("muted_retry"),
|
|
2584
|
+
startTimeouts: count("play_resolved_but_never_started"),
|
|
2585
|
+
impressions: count("impression_fired"),
|
|
2586
|
+
impressionUrls: count("impression_urls"),
|
|
2587
|
+
trackingRequests: count("tracking_request_created"),
|
|
2588
|
+
trackingNotLoaded: count("tracking_request_settled:error") + count("tracking_request_settled:timeout"),
|
|
2589
|
+
trackingUnexpandedMacros: count("tracking_url_unexpanded_macro"),
|
|
2590
|
+
trackingInvalidUrls: count("tracking_url_invalid"),
|
|
2591
|
+
vastAdFallbacks: count("vast_ad_fallback"),
|
|
2592
|
+
mediaEvents: count("media_event"),
|
|
2593
|
+
quartile25: count("first_quartile"),
|
|
2594
|
+
quartile50: count("midpoint"),
|
|
2595
|
+
quartile75: count("third_quartile"),
|
|
2596
|
+
complete: count("complete"),
|
|
2597
|
+
stoppedBeforeStart: count("stopped_before_start"),
|
|
2598
|
+
stoppedBeforeStartByBreakEnd: count("ad_stopped_before_start"),
|
|
2599
|
+
unexpectedUnmutes: count("unexpected_unmute"),
|
|
2600
|
+
unmuteBlocked: count("unmute_blocked_without_gesture"),
|
|
2601
|
+
visibilityHidden: count("while_hidden"),
|
|
2602
|
+
playbackFailures: count("play_failed") + count("media_error") + count("hls_fatal") + count("stall") + count("decode_failure") + count("media_unsupported"),
|
|
2603
|
+
stages: funnel
|
|
2604
|
+
});
|
|
2605
|
+
}
|
|
2606
|
+
},
|
|
2607
|
+
{
|
|
2469
2608
|
key: "handleAdPodComplete",
|
|
2470
2609
|
value: function handleAdPodComplete() {
|
|
2610
|
+
var reason = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "unspecified";
|
|
2471
2611
|
if (this.debug) {
|
|
2472
|
-
console.log("[StormcloudVideoPlayer] Ad pod complete - cleaning up"
|
|
2612
|
+
console.log("[StormcloudVideoPlayer] Ad pod complete - cleaning up", {
|
|
2613
|
+
reason: reason
|
|
2614
|
+
});
|
|
2473
2615
|
}
|
|
2616
|
+
var previousState = this.slotState;
|
|
2617
|
+
var alreadyEnded = previousState === "IDLE" && !this.inAdBreak;
|
|
2618
|
+
this.setSlotState("ENDING", reason);
|
|
2619
|
+
this.cancelScheduledRequest();
|
|
2620
|
+
var adPlayer = this.host.getAdPlayer();
|
|
2621
|
+
if (previousState === "REQUESTING") {
|
|
2622
|
+
var _adPlayer_abortPendingRequest;
|
|
2623
|
+
(_adPlayer_abortPendingRequest = adPlayer.abortPendingRequest) === null || _adPlayer_abortPendingRequest === void 0 ? void 0 : _adPlayer_abortPendingRequest.call(adPlayer, "VAST request aborted: ad break ended (".concat(reason, ")"));
|
|
2624
|
+
}
|
|
2625
|
+
if (!alreadyEnded) {
|
|
2626
|
+
console.log("[AD-CONTROLLER] stop", {
|
|
2627
|
+
controllerId: this.controllerGeneration,
|
|
2628
|
+
requestId: this.currentRequestId,
|
|
2629
|
+
state: previousState,
|
|
2630
|
+
reason: reason
|
|
2631
|
+
});
|
|
2632
|
+
}
|
|
2633
|
+
this.finalizeRequestDiagnostics(this.currentRequestId, "break_ended:".concat(reason));
|
|
2634
|
+
this.currentRequestId = void 0;
|
|
2474
2635
|
this.timing.resetForBreakEnd();
|
|
2475
|
-
this.
|
|
2636
|
+
this.placeholder.hide();
|
|
2476
2637
|
this.clearPendingAdBreak();
|
|
2477
2638
|
if (this.isShowingPlaceholder) {
|
|
2478
|
-
|
|
2639
|
+
adPlayer.hidePlaceholder();
|
|
2479
2640
|
this.isShowingPlaceholder = false;
|
|
2480
2641
|
}
|
|
2481
|
-
this.adRequestQueue = [];
|
|
2482
2642
|
this.inAdBreak = false;
|
|
2483
2643
|
this.adDetectSentForCurrentBreak = false;
|
|
2484
2644
|
this.cueManager.activeScte35BreakKey = void 0;
|
|
2485
2645
|
this.cueManager.scheduledScte35BreakKey = void 0;
|
|
2486
2646
|
this.adPodQueue = [];
|
|
2487
2647
|
this.showAds = false;
|
|
2488
|
-
this.
|
|
2648
|
+
this.breakSource = void 0;
|
|
2649
|
+
this.followUpBaseVastUrl = void 0;
|
|
2650
|
+
this.unusableResponsesInBreak = 0;
|
|
2651
|
+
adPlayer.stop().catch(function() {});
|
|
2652
|
+
if (!alreadyEnded) this.logBreakFunnel(reason);
|
|
2653
|
+
this.setSlotState("IDLE", "break_complete");
|
|
2489
2654
|
var restoredMuted = this.host.getAdPlayer().getOriginalMutedState();
|
|
2490
2655
|
var restoredVolume = this.host.getAdPlayer().getOriginalVolume();
|
|
2491
2656
|
if (this.host.video.muted !== restoredMuted) {
|
|
@@ -2779,25 +2944,23 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
|
|
|
2779
2944
|
{
|
|
2780
2945
|
key: "handleAdFailure",
|
|
2781
2946
|
value: function handleAdFailure() {
|
|
2782
|
-
|
|
2783
|
-
this.
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
}
|
|
2789
|
-
}
|
|
2790
|
-
if (this.timing.consecutiveFailures >= this.timing.maxConsecutiveFailures) {
|
|
2791
|
-
if (this.debug) console.log("[CONTINUOUS-FETCH] Max consecutive failures reached (".concat(this.timing.consecutiveFailures, "), ending ad break gracefully"));
|
|
2792
|
-
this.handleAdPodComplete();
|
|
2947
|
+
var reason = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "ad_failure";
|
|
2948
|
+
if (!this.inAdBreak) return;
|
|
2949
|
+
if (this.slotState === "REQUESTING" || this.slotState === "ENDING") {
|
|
2950
|
+
this.logOrchestratorFunnel("failure_deferred_to_request", {
|
|
2951
|
+
reason: reason,
|
|
2952
|
+
state: this.slotState
|
|
2953
|
+
});
|
|
2793
2954
|
return;
|
|
2794
2955
|
}
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
this.
|
|
2956
|
+
this.timing.consecutiveFailures++;
|
|
2957
|
+
var diag = this.currentRequestId != null ? this.requestDiagnostics.get(this.currentRequestId) : void 0;
|
|
2958
|
+
if (diag && !diag.failureReason) diag.failureReason = reason;
|
|
2959
|
+
if (this.debug) {
|
|
2960
|
+
console.log("[AdBreak] Ad failure (".concat(reason, "): remaining=").concat(this.timing.getRemainingAdMs(), "ms, consecutiveFailures=").concat(this.timing.consecutiveFailures));
|
|
2800
2961
|
}
|
|
2962
|
+
this.setSlotState("NEEDS_NEXT_AD", reason);
|
|
2963
|
+
this.requestNextAd(reason);
|
|
2801
2964
|
}
|
|
2802
2965
|
}
|
|
2803
2966
|
]);
|