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.
- package/dist/stormcloud-vp.min.js +2 -2
- package/lib/index.cjs +80 -1038
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +0 -3
- package/lib/index.d.ts +0 -3
- package/lib/index.js +80 -1039
- package/lib/index.js.map +1 -1
- package/lib/player/AdBreakOrchestrator.cjs +59 -483
- package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
- package/lib/player/AdBreakOrchestrator.d.cts +9 -7
- package/lib/player/AdConfigManager.cjs +12 -53
- package/lib/player/AdConfigManager.cjs.map +1 -1
- package/lib/player/AdConfigManager.d.cts +4 -5
- package/lib/player/AdTimingService.d.cts +1 -1
- package/lib/player/HlsEngine.d.cts +1 -1
- package/lib/player/PlayerControls.d.cts +1 -1
- package/lib/player/Scte35CueManager.d.cts +1 -1
- package/lib/player/Scte35Parser.d.cts +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +80 -1038
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +1 -3
- package/lib/player/playerTypes.d.cts +1 -1
- package/lib/players/HlsPlayer.cjs +80 -1038
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.d.cts +1 -1
- package/lib/players/index.cjs +80 -1038
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.d.cts +1 -1
- package/lib/{types-Xgz2_W1C.d.cts → types-CSHvCbhZ.d.cts} +0 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +80 -1038
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/utils/tracking.d.cts +1 -1
- package/lib/utils/vastMacros.cjs +10 -15
- package/lib/utils/vastMacros.cjs.map +1 -1
- package/lib/utils/vastMacros.d.cts +0 -1
- package/package.json +1 -1
- package/lib/player/AdPreloadPool.cjs +0 -673
- package/lib/player/AdPreloadPool.cjs.map +0 -1
- package/lib/player/AdPreloadPool.d.cts +0 -37
|
@@ -1,673 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
3
|
-
try {
|
|
4
|
-
var info = gen[key](arg);
|
|
5
|
-
var value = info.value;
|
|
6
|
-
} catch (error) {
|
|
7
|
-
reject(error);
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
if (info.done) {
|
|
11
|
-
resolve(value);
|
|
12
|
-
} else {
|
|
13
|
-
Promise.resolve(value).then(_next, _throw);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function _async_to_generator(fn) {
|
|
17
|
-
return function() {
|
|
18
|
-
var self = this, args = arguments;
|
|
19
|
-
return new Promise(function(resolve, reject) {
|
|
20
|
-
var gen = fn.apply(self, args);
|
|
21
|
-
function _next(value) {
|
|
22
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
23
|
-
}
|
|
24
|
-
function _throw(err) {
|
|
25
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
26
|
-
}
|
|
27
|
-
_next(undefined);
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
function _class_call_check(instance, Constructor) {
|
|
32
|
-
if (!(instance instanceof Constructor)) {
|
|
33
|
-
throw new TypeError("Cannot call a class as a function");
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
function _defineProperties(target, props) {
|
|
37
|
-
for(var i = 0; i < props.length; i++){
|
|
38
|
-
var descriptor = props[i];
|
|
39
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
40
|
-
descriptor.configurable = true;
|
|
41
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
42
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
function _create_class(Constructor, protoProps, staticProps) {
|
|
46
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
47
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
48
|
-
return Constructor;
|
|
49
|
-
}
|
|
50
|
-
function _instanceof(left, right) {
|
|
51
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
52
|
-
return !!right[Symbol.hasInstance](left);
|
|
53
|
-
} else {
|
|
54
|
-
return left instanceof right;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function _type_of(obj) {
|
|
58
|
-
"@swc/helpers - typeof";
|
|
59
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
60
|
-
}
|
|
61
|
-
function _ts_generator(thisArg, body) {
|
|
62
|
-
var f, y, t, _ = {
|
|
63
|
-
label: 0,
|
|
64
|
-
sent: function() {
|
|
65
|
-
if (t[0] & 1) throw t[1];
|
|
66
|
-
return t[1];
|
|
67
|
-
},
|
|
68
|
-
trys: [],
|
|
69
|
-
ops: []
|
|
70
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
71
|
-
return d(g, "next", {
|
|
72
|
-
value: verb(0)
|
|
73
|
-
}), d(g, "throw", {
|
|
74
|
-
value: verb(1)
|
|
75
|
-
}), d(g, "return", {
|
|
76
|
-
value: verb(2)
|
|
77
|
-
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
78
|
-
value: function() {
|
|
79
|
-
return this;
|
|
80
|
-
}
|
|
81
|
-
}), g;
|
|
82
|
-
function verb(n) {
|
|
83
|
-
return function(v) {
|
|
84
|
-
return step([
|
|
85
|
-
n,
|
|
86
|
-
v
|
|
87
|
-
]);
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
function step(op) {
|
|
91
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
92
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
93
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
94
|
-
if (y = 0, t) op = [
|
|
95
|
-
op[0] & 2,
|
|
96
|
-
t.value
|
|
97
|
-
];
|
|
98
|
-
switch(op[0]){
|
|
99
|
-
case 0:
|
|
100
|
-
case 1:
|
|
101
|
-
t = op;
|
|
102
|
-
break;
|
|
103
|
-
case 4:
|
|
104
|
-
_.label++;
|
|
105
|
-
return {
|
|
106
|
-
value: op[1],
|
|
107
|
-
done: false
|
|
108
|
-
};
|
|
109
|
-
case 5:
|
|
110
|
-
_.label++;
|
|
111
|
-
y = op[1];
|
|
112
|
-
op = [
|
|
113
|
-
0
|
|
114
|
-
];
|
|
115
|
-
continue;
|
|
116
|
-
case 7:
|
|
117
|
-
op = _.ops.pop();
|
|
118
|
-
_.trys.pop();
|
|
119
|
-
continue;
|
|
120
|
-
default:
|
|
121
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
122
|
-
_ = 0;
|
|
123
|
-
continue;
|
|
124
|
-
}
|
|
125
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
126
|
-
_.label = op[1];
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
130
|
-
_.label = t[1];
|
|
131
|
-
t = op;
|
|
132
|
-
break;
|
|
133
|
-
}
|
|
134
|
-
if (t && _.label < t[2]) {
|
|
135
|
-
_.label = t[2];
|
|
136
|
-
_.ops.push(op);
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
if (t[2]) _.ops.pop();
|
|
140
|
-
_.trys.pop();
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
op = body.call(thisArg, _);
|
|
144
|
-
} catch (e) {
|
|
145
|
-
op = [
|
|
146
|
-
6,
|
|
147
|
-
e
|
|
148
|
-
];
|
|
149
|
-
y = 0;
|
|
150
|
-
} finally{
|
|
151
|
-
f = t = 0;
|
|
152
|
-
}
|
|
153
|
-
if (op[0] & 5) throw op[1];
|
|
154
|
-
return {
|
|
155
|
-
value: op[0] ? op[1] : void 0,
|
|
156
|
-
done: true
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
var __defProp = Object.defineProperty;
|
|
161
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
162
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
163
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
164
|
-
var __export = function __export(target, all) {
|
|
165
|
-
for(var name in all)__defProp(target, name, {
|
|
166
|
-
get: all[name],
|
|
167
|
-
enumerable: true
|
|
168
|
-
});
|
|
169
|
-
};
|
|
170
|
-
var __copyProps = function __copyProps(to, from, except, desc) {
|
|
171
|
-
if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
|
|
172
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
173
|
-
try {
|
|
174
|
-
var _loop = function() {
|
|
175
|
-
var key = _step.value;
|
|
176
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
177
|
-
get: function get() {
|
|
178
|
-
return from[key];
|
|
179
|
-
},
|
|
180
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
181
|
-
});
|
|
182
|
-
};
|
|
183
|
-
for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
184
|
-
} catch (err) {
|
|
185
|
-
_didIteratorError = true;
|
|
186
|
-
_iteratorError = err;
|
|
187
|
-
} finally{
|
|
188
|
-
try {
|
|
189
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
190
|
-
_iterator.return();
|
|
191
|
-
}
|
|
192
|
-
} finally{
|
|
193
|
-
if (_didIteratorError) {
|
|
194
|
-
throw _iteratorError;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
return to;
|
|
200
|
-
};
|
|
201
|
-
var __toCommonJS = function __toCommonJS(mod) {
|
|
202
|
-
return __copyProps(__defProp({}, "__esModule", {
|
|
203
|
-
value: true
|
|
204
|
-
}), mod);
|
|
205
|
-
};
|
|
206
|
-
// src/player/AdPreloadPool.ts
|
|
207
|
-
var AdPreloadPool_exports = {};
|
|
208
|
-
__export(AdPreloadPool_exports, {
|
|
209
|
-
AdPreloadPool: function AdPreloadPool1() {
|
|
210
|
-
return AdPreloadPool;
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
module.exports = __toCommonJS(AdPreloadPool_exports);
|
|
214
|
-
var AdPreloadPool = /*#__PURE__*/ function() {
|
|
215
|
-
function AdPreloadPool(deps) {
|
|
216
|
-
_class_call_check(this, AdPreloadPool);
|
|
217
|
-
this.pool = [];
|
|
218
|
-
this.maxPoolSize = 2;
|
|
219
|
-
this.poolActive = false;
|
|
220
|
-
this.loopRunning = false;
|
|
221
|
-
this.deps = deps;
|
|
222
|
-
}
|
|
223
|
-
_create_class(AdPreloadPool, [
|
|
224
|
-
{
|
|
225
|
-
key: "active",
|
|
226
|
-
get: function get() {
|
|
227
|
-
return this.poolActive;
|
|
228
|
-
},
|
|
229
|
-
set: function set(value) {
|
|
230
|
-
this.poolActive = value;
|
|
231
|
-
}
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
key: "isLoopRunning",
|
|
235
|
-
get: function get() {
|
|
236
|
-
return this.loopRunning;
|
|
237
|
-
}
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
key: "startPreloadPool",
|
|
241
|
-
value: function startPreloadPool(baseVastUrl, initialUrls) {
|
|
242
|
-
var startLoopImmediately = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
|
|
243
|
-
if (this.poolActive) {
|
|
244
|
-
if (this.deps.debug) {
|
|
245
|
-
console.log("[PRELOAD-POOL] Already active, skipping duplicate start");
|
|
246
|
-
}
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
this.poolActive = true;
|
|
250
|
-
if (this.deps.debug) {
|
|
251
|
-
console.log("[PRELOAD-POOL] Starting preload pool EARLY (target size: ".concat(this.maxPoolSize, ")"));
|
|
252
|
-
console.log("[PRELOAD-POOL] Ad break hasn't started yet, but preloading ads in advance");
|
|
253
|
-
}
|
|
254
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
255
|
-
try {
|
|
256
|
-
for(var _iterator = initialUrls[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
257
|
-
var url = _step.value;
|
|
258
|
-
if (this.pool.length < this.maxPoolSize) {
|
|
259
|
-
this.preloadAdIntoPool(url);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
} catch (err) {
|
|
263
|
-
_didIteratorError = true;
|
|
264
|
-
_iteratorError = err;
|
|
265
|
-
} finally{
|
|
266
|
-
try {
|
|
267
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
268
|
-
_iterator.return();
|
|
269
|
-
}
|
|
270
|
-
} finally{
|
|
271
|
-
if (_didIteratorError) {
|
|
272
|
-
throw _iteratorError;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
if (startLoopImmediately) {
|
|
277
|
-
this.preloadPoolLoop(baseVastUrl);
|
|
278
|
-
} else if (this.deps.debug) {
|
|
279
|
-
console.log("[PRELOAD-POOL] Pre-break mode: preloaded once, waiting for SCTE start to continue fetching");
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
},
|
|
283
|
-
{
|
|
284
|
-
key: "preloadAdIntoPool",
|
|
285
|
-
value: function preloadAdIntoPool(vastUrl) {
|
|
286
|
-
return _async_to_generator(function() {
|
|
287
|
-
var _this, timing, epoch, loadPromise;
|
|
288
|
-
return _ts_generator(this, function(_state) {
|
|
289
|
-
_this = this;
|
|
290
|
-
timing = this.deps.timing;
|
|
291
|
-
if (timing.isGamInCooldown()) {
|
|
292
|
-
if (this.deps.debug) {
|
|
293
|
-
console.log("[CIRCUIT-BREAKER] GAM in cooldown, skipping preload");
|
|
294
|
-
}
|
|
295
|
-
return [
|
|
296
|
-
2
|
|
297
|
-
];
|
|
298
|
-
}
|
|
299
|
-
if (this.pool.some(function(entry) {
|
|
300
|
-
return entry.vastUrl === vastUrl;
|
|
301
|
-
}) || timing.failedVastUrls.has(vastUrl) || timing.isUrlInCooldown(vastUrl)) {
|
|
302
|
-
return [
|
|
303
|
-
2
|
|
304
|
-
];
|
|
305
|
-
}
|
|
306
|
-
if (this.pool.length >= this.maxPoolSize) {
|
|
307
|
-
return [
|
|
308
|
-
2
|
|
309
|
-
];
|
|
310
|
-
}
|
|
311
|
-
if (this.deps.debug) {
|
|
312
|
-
console.log("[PRELOAD-POOL] Preloading ad into pool: ".concat(vastUrl));
|
|
313
|
-
}
|
|
314
|
-
epoch = timing.adBreakEpoch;
|
|
315
|
-
loadPromise = function() {
|
|
316
|
-
return _async_to_generator(function() {
|
|
317
|
-
var _this, hasAdError, adErrorPayload, errorListenerCleanup, _preloadAd_getLoadedAdDuration, continueLiveStreamDuringAds, preloadAd, errorListener, isNoFill, poolEntry, loadedDuration, lateErrorListener, _poolEntry_durationSeconds, error;
|
|
318
|
-
return _ts_generator(this, function(_state) {
|
|
319
|
-
switch(_state.label){
|
|
320
|
-
case 0:
|
|
321
|
-
_this = this;
|
|
322
|
-
hasAdError = false;
|
|
323
|
-
adErrorPayload = null;
|
|
324
|
-
errorListenerCleanup = null;
|
|
325
|
-
_state.label = 1;
|
|
326
|
-
case 1:
|
|
327
|
-
_state.trys.push([
|
|
328
|
-
1,
|
|
329
|
-
5,
|
|
330
|
-
,
|
|
331
|
-
6
|
|
332
|
-
]);
|
|
333
|
-
continueLiveStreamDuringAds = this.deps.shouldContinueLiveStreamDuringAds();
|
|
334
|
-
preloadAd = this.deps.createAdPlayer(continueLiveStreamDuringAds);
|
|
335
|
-
preloadAd.initialize();
|
|
336
|
-
errorListener = function errorListener(payload) {
|
|
337
|
-
hasAdError = true;
|
|
338
|
-
adErrorPayload = payload;
|
|
339
|
-
};
|
|
340
|
-
preloadAd.on("ad_error", errorListener);
|
|
341
|
-
errorListenerCleanup = function errorListenerCleanup() {
|
|
342
|
-
return preloadAd.off("ad_error", errorListener);
|
|
343
|
-
};
|
|
344
|
-
return [
|
|
345
|
-
4,
|
|
346
|
-
timing.enforceGlobalRateLimit()
|
|
347
|
-
];
|
|
348
|
-
case 2:
|
|
349
|
-
_state.sent();
|
|
350
|
-
return [
|
|
351
|
-
4,
|
|
352
|
-
preloadAd.requestAds(vastUrl)
|
|
353
|
-
];
|
|
354
|
-
case 3:
|
|
355
|
-
_state.sent();
|
|
356
|
-
preloadAd.pause();
|
|
357
|
-
return [
|
|
358
|
-
4,
|
|
359
|
-
new Promise(function(resolve) {
|
|
360
|
-
return setTimeout(resolve, 1500);
|
|
361
|
-
})
|
|
362
|
-
];
|
|
363
|
-
case 4:
|
|
364
|
-
_state.sent();
|
|
365
|
-
preloadAd.pause();
|
|
366
|
-
if (hasAdError) {
|
|
367
|
-
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;
|
|
368
|
-
if (errorListenerCleanup) {
|
|
369
|
-
errorListenerCleanup();
|
|
370
|
-
}
|
|
371
|
-
preloadAd.destroy();
|
|
372
|
-
timing.recordGamNoFill();
|
|
373
|
-
if (isNoFill) {
|
|
374
|
-
if (this.deps.debug) {
|
|
375
|
-
console.log("[PRELOAD-POOL] Ad preload returned no-fill: ".concat(vastUrl));
|
|
376
|
-
}
|
|
377
|
-
timing.temporaryFailureUrls.set(vastUrl, Date.now());
|
|
378
|
-
} else {
|
|
379
|
-
if (this.deps.debug) {
|
|
380
|
-
console.log("[PRELOAD-POOL] Ad preload failed with error: ".concat(vastUrl), adErrorPayload);
|
|
381
|
-
}
|
|
382
|
-
if (adErrorPayload && !timing.isTemporaryAdError(adErrorPayload)) {
|
|
383
|
-
timing.failedVastUrls.add(vastUrl);
|
|
384
|
-
} else {
|
|
385
|
-
timing.temporaryFailureUrls.set(vastUrl, Date.now());
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
return [
|
|
389
|
-
2
|
|
390
|
-
];
|
|
391
|
-
}
|
|
392
|
-
if (!this.poolActive || epoch !== timing.adBreakEpoch) {
|
|
393
|
-
if (this.deps.debug) {
|
|
394
|
-
console.log("[PRELOAD-POOL] Discarding preloaded ad - break ended during fetch");
|
|
395
|
-
}
|
|
396
|
-
if (errorListenerCleanup) {
|
|
397
|
-
errorListenerCleanup();
|
|
398
|
-
}
|
|
399
|
-
try {
|
|
400
|
-
preloadAd.destroy();
|
|
401
|
-
} catch (unused) {}
|
|
402
|
-
return [
|
|
403
|
-
2
|
|
404
|
-
];
|
|
405
|
-
}
|
|
406
|
-
poolEntry = {
|
|
407
|
-
vastUrl: vastUrl,
|
|
408
|
-
adController: preloadAd,
|
|
409
|
-
loadedAt: Date.now(),
|
|
410
|
-
isReady: true,
|
|
411
|
-
loadPromise: Promise.resolve()
|
|
412
|
-
};
|
|
413
|
-
loadedDuration = (_preloadAd_getLoadedAdDuration = preloadAd.getLoadedAdDuration) === null || _preloadAd_getLoadedAdDuration === void 0 ? void 0 : _preloadAd_getLoadedAdDuration.call(preloadAd);
|
|
414
|
-
if (loadedDuration != null && loadedDuration > 0) {
|
|
415
|
-
poolEntry.durationSeconds = loadedDuration;
|
|
416
|
-
}
|
|
417
|
-
lateErrorListener = function lateErrorListener(payload) {
|
|
418
|
-
var index = _this.pool.findIndex(function(entry) {
|
|
419
|
-
return entry.vastUrl === vastUrl;
|
|
420
|
-
});
|
|
421
|
-
if (index >= 0) {
|
|
422
|
-
_this.pool.splice(index, 1);
|
|
423
|
-
if (_this.deps.debug) {
|
|
424
|
-
console.log("[PRELOAD-POOL] Late error detected, removed from pool: ".concat(vastUrl), payload);
|
|
425
|
-
}
|
|
426
|
-
try {
|
|
427
|
-
preloadAd.destroy();
|
|
428
|
-
} catch (unused) {}
|
|
429
|
-
}
|
|
430
|
-
};
|
|
431
|
-
preloadAd.on("ad_error", lateErrorListener);
|
|
432
|
-
this.pool.push(poolEntry);
|
|
433
|
-
if (this.deps.debug) {
|
|
434
|
-
;
|
|
435
|
-
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)"));
|
|
436
|
-
}
|
|
437
|
-
if (errorListenerCleanup) {
|
|
438
|
-
errorListenerCleanup();
|
|
439
|
-
}
|
|
440
|
-
return [
|
|
441
|
-
3,
|
|
442
|
-
6
|
|
443
|
-
];
|
|
444
|
-
case 5:
|
|
445
|
-
error = _state.sent();
|
|
446
|
-
if (errorListenerCleanup) {
|
|
447
|
-
errorListenerCleanup();
|
|
448
|
-
}
|
|
449
|
-
timing.recordGamNoFill();
|
|
450
|
-
if (this.deps.debug) {
|
|
451
|
-
console.warn("[PRELOAD-POOL] Failed to preload ad: ".concat(vastUrl), error);
|
|
452
|
-
}
|
|
453
|
-
if (_instanceof(error, Error) && !timing.isTemporaryAdError(error)) {
|
|
454
|
-
timing.failedVastUrls.add(vastUrl);
|
|
455
|
-
} else if (_instanceof(error, Error) && timing.isTemporaryAdError(error)) {
|
|
456
|
-
timing.temporaryFailureUrls.set(vastUrl, Date.now());
|
|
457
|
-
}
|
|
458
|
-
return [
|
|
459
|
-
3,
|
|
460
|
-
6
|
|
461
|
-
];
|
|
462
|
-
case 6:
|
|
463
|
-
return [
|
|
464
|
-
2
|
|
465
|
-
];
|
|
466
|
-
}
|
|
467
|
-
});
|
|
468
|
-
}).call(_this);
|
|
469
|
-
}();
|
|
470
|
-
loadPromise.catch(function() {});
|
|
471
|
-
return [
|
|
472
|
-
2
|
|
473
|
-
];
|
|
474
|
-
});
|
|
475
|
-
}).call(this);
|
|
476
|
-
}
|
|
477
|
-
},
|
|
478
|
-
{
|
|
479
|
-
key: "preloadPoolLoop",
|
|
480
|
-
value: function preloadPoolLoop(baseVastUrl) {
|
|
481
|
-
return _async_to_generator(function() {
|
|
482
|
-
var epoch, newUrls, newUrl;
|
|
483
|
-
return _ts_generator(this, function(_state) {
|
|
484
|
-
switch(_state.label){
|
|
485
|
-
case 0:
|
|
486
|
-
if (this.loopRunning) {
|
|
487
|
-
return [
|
|
488
|
-
2
|
|
489
|
-
];
|
|
490
|
-
}
|
|
491
|
-
this.loopRunning = true;
|
|
492
|
-
epoch = this.deps.timing.adBreakEpoch;
|
|
493
|
-
if (this.deps.debug) {
|
|
494
|
-
console.log("[PRELOAD-POOL] Starting continuous preload loop");
|
|
495
|
-
}
|
|
496
|
-
_state.label = 1;
|
|
497
|
-
case 1:
|
|
498
|
-
if (!(this.poolActive && epoch === this.deps.timing.adBreakEpoch)) return [
|
|
499
|
-
3,
|
|
500
|
-
10
|
|
501
|
-
];
|
|
502
|
-
if (this.deps.timing.isGamInCooldown()) {
|
|
503
|
-
if (this.deps.debug) {
|
|
504
|
-
console.log("[CIRCUIT-BREAKER] GAM in cooldown, stopping preload pool loop");
|
|
505
|
-
}
|
|
506
|
-
return [
|
|
507
|
-
3,
|
|
508
|
-
10
|
|
509
|
-
];
|
|
510
|
-
}
|
|
511
|
-
if (!(!this.deps.isInAdBreak() && this.pool.length >= this.maxPoolSize)) return [
|
|
512
|
-
3,
|
|
513
|
-
3
|
|
514
|
-
];
|
|
515
|
-
return [
|
|
516
|
-
4,
|
|
517
|
-
new Promise(function(resolve) {
|
|
518
|
-
return setTimeout(resolve, 2e3);
|
|
519
|
-
})
|
|
520
|
-
];
|
|
521
|
-
case 2:
|
|
522
|
-
_state.sent();
|
|
523
|
-
return [
|
|
524
|
-
3,
|
|
525
|
-
1
|
|
526
|
-
];
|
|
527
|
-
case 3:
|
|
528
|
-
if (!this.deps.isInAdBreak() && this.deps.getPendingAdBreak() === null) {
|
|
529
|
-
if (this.deps.debug) {
|
|
530
|
-
console.log("[PRELOAD-POOL] Ad break cancelled, stopping preload pool");
|
|
531
|
-
}
|
|
532
|
-
return [
|
|
533
|
-
3,
|
|
534
|
-
10
|
|
535
|
-
];
|
|
536
|
-
}
|
|
537
|
-
_state.label = 4;
|
|
538
|
-
case 4:
|
|
539
|
-
if (!(this.pool.length < this.maxPoolSize)) return [
|
|
540
|
-
3,
|
|
541
|
-
8
|
|
542
|
-
];
|
|
543
|
-
if (!this.poolActive || epoch !== this.deps.timing.adBreakEpoch || this.deps.timing.isGamInCooldown()) {
|
|
544
|
-
return [
|
|
545
|
-
3,
|
|
546
|
-
8
|
|
547
|
-
];
|
|
548
|
-
}
|
|
549
|
-
if (this.deps.isInAdBreak() && !this.deps.timing.hasTimeToStartAnotherAd()) {
|
|
550
|
-
if (this.deps.debug) {
|
|
551
|
-
console.log("[PRELOAD-POOL] Not enough ad break time left, stopping preload");
|
|
552
|
-
}
|
|
553
|
-
return [
|
|
554
|
-
3,
|
|
555
|
-
8
|
|
556
|
-
];
|
|
557
|
-
}
|
|
558
|
-
newUrls = this.deps.generateVastUrlsWithCorrelators(baseVastUrl, 1);
|
|
559
|
-
newUrl = newUrls[0];
|
|
560
|
-
if (!(newUrl && !this.deps.timing.failedVastUrls.has(newUrl) && !this.deps.timing.isUrlInCooldown(newUrl))) return [
|
|
561
|
-
3,
|
|
562
|
-
6
|
|
563
|
-
];
|
|
564
|
-
return [
|
|
565
|
-
4,
|
|
566
|
-
this.preloadAdIntoPool(newUrl)
|
|
567
|
-
];
|
|
568
|
-
case 5:
|
|
569
|
-
_state.sent();
|
|
570
|
-
_state.label = 6;
|
|
571
|
-
case 6:
|
|
572
|
-
return [
|
|
573
|
-
4,
|
|
574
|
-
new Promise(function(resolve) {
|
|
575
|
-
return setTimeout(resolve, 1e3);
|
|
576
|
-
})
|
|
577
|
-
];
|
|
578
|
-
case 7:
|
|
579
|
-
_state.sent();
|
|
580
|
-
return [
|
|
581
|
-
3,
|
|
582
|
-
4
|
|
583
|
-
];
|
|
584
|
-
case 8:
|
|
585
|
-
return [
|
|
586
|
-
4,
|
|
587
|
-
new Promise(function(resolve) {
|
|
588
|
-
return setTimeout(resolve, 2e3);
|
|
589
|
-
})
|
|
590
|
-
];
|
|
591
|
-
case 9:
|
|
592
|
-
_state.sent();
|
|
593
|
-
return [
|
|
594
|
-
3,
|
|
595
|
-
1
|
|
596
|
-
];
|
|
597
|
-
case 10:
|
|
598
|
-
this.loopRunning = false;
|
|
599
|
-
if (this.deps.debug) {
|
|
600
|
-
console.log("[PRELOAD-POOL] Preload loop ended");
|
|
601
|
-
}
|
|
602
|
-
return [
|
|
603
|
-
2
|
|
604
|
-
];
|
|
605
|
-
}
|
|
606
|
-
});
|
|
607
|
-
}).call(this);
|
|
608
|
-
}
|
|
609
|
-
},
|
|
610
|
-
{
|
|
611
|
-
key: "getPreloadedAd",
|
|
612
|
-
value: function getPreloadedAd() {
|
|
613
|
-
if (this.pool.length === 0) {
|
|
614
|
-
return null;
|
|
615
|
-
}
|
|
616
|
-
var entry = this.pool.shift();
|
|
617
|
-
if (!entry || !entry.isReady) {
|
|
618
|
-
return null;
|
|
619
|
-
}
|
|
620
|
-
if (this.deps.debug) {
|
|
621
|
-
console.log("[PRELOAD-POOL] Using preloaded ad from pool (".concat(this.pool.length, " remaining)"));
|
|
622
|
-
}
|
|
623
|
-
return {
|
|
624
|
-
vastUrl: entry.vastUrl,
|
|
625
|
-
adController: entry.adController
|
|
626
|
-
};
|
|
627
|
-
}
|
|
628
|
-
},
|
|
629
|
-
{
|
|
630
|
-
key: "stop",
|
|
631
|
-
value: function stop() {
|
|
632
|
-
this.poolActive = false;
|
|
633
|
-
this.loopRunning = false;
|
|
634
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
635
|
-
try {
|
|
636
|
-
for(var _iterator = this.pool[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
637
|
-
var entry = _step.value;
|
|
638
|
-
try {
|
|
639
|
-
entry.adController.destroy();
|
|
640
|
-
} catch (error) {
|
|
641
|
-
if (this.deps.debug) {
|
|
642
|
-
console.warn("[PRELOAD-POOL] Error destroying preloaded controller:", error);
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
} catch (err) {
|
|
647
|
-
_didIteratorError = true;
|
|
648
|
-
_iteratorError = err;
|
|
649
|
-
} finally{
|
|
650
|
-
try {
|
|
651
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
652
|
-
_iterator.return();
|
|
653
|
-
}
|
|
654
|
-
} finally{
|
|
655
|
-
if (_didIteratorError) {
|
|
656
|
-
throw _iteratorError;
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
this.pool = [];
|
|
661
|
-
if (this.deps.debug) {
|
|
662
|
-
console.log("[PRELOAD-POOL] Preload pool stopped and cleaned up");
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
]);
|
|
667
|
-
return AdPreloadPool;
|
|
668
|
-
}();
|
|
669
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
670
|
-
0 && (module.exports = {
|
|
671
|
-
AdPreloadPool: AdPreloadPool
|
|
672
|
-
});
|
|
673
|
-
//# sourceMappingURL=AdPreloadPool.cjs.map
|