stormcloud-video-player 0.5.6 → 0.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +28 -40
  2. package/dist/stormcloud-vp.min.js +1 -1
  3. package/lib/index.cjs +2122 -5135
  4. package/lib/index.cjs.map +1 -1
  5. package/lib/index.d.cts +9 -67
  6. package/lib/index.d.ts +9 -67
  7. package/lib/index.js +2146 -5143
  8. package/lib/index.js.map +1 -1
  9. package/lib/player/StormcloudVideoPlayer.cjs +879 -3862
  10. package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
  11. package/lib/player/StormcloudVideoPlayer.d.cts +5 -37
  12. package/lib/players/HlsPlayer.cjs +879 -3862
  13. package/lib/players/HlsPlayer.cjs.map +1 -1
  14. package/lib/players/HlsPlayer.d.cts +1 -1
  15. package/lib/players/index.cjs +879 -3862
  16. package/lib/players/index.cjs.map +1 -1
  17. package/lib/sdk/prebid.cjs +114 -43
  18. package/lib/sdk/prebid.cjs.map +1 -1
  19. package/lib/sdk/prebid.d.cts +1 -1
  20. package/lib/sdk/prebidController.cjs +127 -77
  21. package/lib/sdk/prebidController.cjs.map +1 -1
  22. package/lib/sdk/prebidController.d.cts +2 -2
  23. package/lib/sdk/vastParser.cjs +3 -5
  24. package/lib/sdk/vastParser.cjs.map +1 -1
  25. package/lib/sdk/vastParser.d.cts +1 -1
  26. package/lib/{types-Bwp6-yys.d.cts → types-BOJiWNWa.d.cts} +4 -7
  27. package/lib/ui/StormcloudVideoPlayer.cjs +879 -3872
  28. package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
  29. package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
  30. package/lib/utils/browserCompat.cjs +0 -3
  31. package/lib/utils/browserCompat.cjs.map +1 -1
  32. package/lib/utils/browserCompat.d.cts +0 -1
  33. package/lib/utils/tracking.d.cts +1 -1
  34. package/package.json +1 -1
  35. package/lib/sdk/hlsAdPlayer.cjs +0 -1053
  36. package/lib/sdk/hlsAdPlayer.cjs.map +0 -1
  37. package/lib/sdk/hlsAdPlayer.d.cts +0 -10
  38. package/lib/sdk/ima.cjs +0 -1384
  39. package/lib/sdk/ima.cjs.map +0 -1
  40. package/lib/sdk/ima.d.cts +0 -12
@@ -36,6 +36,13 @@ function _async_to_generator(fn) {
36
36
  });
37
37
  };
38
38
  }
39
+ function _instanceof(left, right) {
40
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
41
+ return !!right[Symbol.hasInstance](left);
42
+ } else {
43
+ return left instanceof right;
44
+ }
45
+ }
39
46
  function _iterable_to_array(iter) {
40
47
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
41
48
  }
@@ -156,6 +163,20 @@ function _ts_generator(thisArg, body) {
156
163
  };
157
164
  }
158
165
  }
166
+ function _ts_values(o) {
167
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
168
+ if (m) return m.call(o);
169
+ if (o && typeof o.length === "number") return {
170
+ next: function() {
171
+ if (o && i >= o.length) o = void 0;
172
+ return {
173
+ value: o && o[i++],
174
+ done: !o
175
+ };
176
+ }
177
+ };
178
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
179
+ }
159
180
  var __defProp = Object.defineProperty;
160
181
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
161
182
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -303,28 +324,6 @@ function createPrebidManager() {
303
324
  });
304
325
  return bids;
305
326
  }
306
- function extractVastUrl(bids) {
307
- if (bids.length === 0) return null;
308
- var winner = bids[0];
309
- if (winner.vastUrl) {
310
- log("Using cached VAST URL from ".concat(winner.bidder, " ($").concat(winner.cpm.toFixed(2), " ").concat(winner.currency, ")"));
311
- return winner.vastUrl;
312
- }
313
- if (winner.vastXml) {
314
- log("Creating blob URL from VAST XML (".concat(winner.bidder, ", $").concat(winner.cpm.toFixed(2), ")"));
315
- try {
316
- var blob = new Blob([
317
- winner.vastXml
318
- ], {
319
- type: "text/xml"
320
- });
321
- return URL.createObjectURL(blob);
322
- } catch (error) {
323
- warn("Failed to create blob URL from VAST XML:", error);
324
- }
325
- }
326
- return null;
327
- }
328
327
  function initialize() {
329
328
  return _async_to_generator(function() {
330
329
  return _ts_generator(this, function(_state) {
@@ -448,38 +447,110 @@ function createPrebidManager() {
448
447
  });
449
448
  })();
450
449
  }
451
- function getVastUrl() {
450
+ var REQUEST_BIDS_MAX_RETRIES = 3;
451
+ var REQUEST_BIDS_BACKOFF_MS = 1500;
452
+ function requestBidsUntilResponse() {
452
453
  return _async_to_generator(function() {
453
- var bids, error;
454
+ var _loop, lastError, attempt, _ret;
454
455
  return _ts_generator(this, function(_state) {
455
456
  switch(_state.label){
456
457
  case 0:
457
- _state.trys.push([
458
- 0,
459
- 2,
460
- ,
461
- 3
462
- ]);
463
- return [
464
- 4,
465
- requestBids()
466
- ];
458
+ _loop = function(attempt) {
459
+ var bids, err, delay;
460
+ return _ts_generator(this, function(_state) {
461
+ switch(_state.label){
462
+ case 0:
463
+ _state.trys.push([
464
+ 0,
465
+ 2,
466
+ ,
467
+ 3
468
+ ]);
469
+ return [
470
+ 4,
471
+ requestBids()
472
+ ];
473
+ case 1:
474
+ bids = _state.sent();
475
+ if (bids.length > 0) {
476
+ log("requestBidsUntilResponse: got ".concat(bids.length, " bid(s) on attempt ").concat(attempt));
477
+ return [
478
+ 2,
479
+ {
480
+ v: bids
481
+ }
482
+ ];
483
+ }
484
+ log("requestBidsUntilResponse: no bids on attempt ".concat(attempt, "/").concat(REQUEST_BIDS_MAX_RETRIES));
485
+ return [
486
+ 3,
487
+ 3
488
+ ];
489
+ case 2:
490
+ err = _state.sent();
491
+ lastError = err;
492
+ warn("requestBidsUntilResponse: attempt ".concat(attempt, "/").concat(REQUEST_BIDS_MAX_RETRIES, " failed:"), err);
493
+ return [
494
+ 3,
495
+ 3
496
+ ];
497
+ case 3:
498
+ if (!(attempt < REQUEST_BIDS_MAX_RETRIES)) return [
499
+ 3,
500
+ 5
501
+ ];
502
+ delay = REQUEST_BIDS_BACKOFF_MS * attempt;
503
+ log("requestBidsUntilResponse: waiting ".concat(delay, "ms before retry"));
504
+ return [
505
+ 4,
506
+ new Promise(function(resolve) {
507
+ return setTimeout(resolve, delay);
508
+ })
509
+ ];
510
+ case 4:
511
+ _state.sent();
512
+ _state.label = 5;
513
+ case 5:
514
+ return [
515
+ 2
516
+ ];
517
+ }
518
+ });
519
+ };
520
+ if (!initialized) {
521
+ throw new Error("Prebid not initialized. Call initialize() first.");
522
+ }
523
+ attempt = 1;
524
+ _state.label = 1;
467
525
  case 1:
468
- bids = _state.sent();
526
+ if (!(attempt <= REQUEST_BIDS_MAX_RETRIES)) return [
527
+ 3,
528
+ 4
529
+ ];
469
530
  return [
470
- 2,
471
- extractVastUrl(bids)
531
+ 5,
532
+ _ts_values(_loop(attempt))
472
533
  ];
473
534
  case 2:
474
- error = _state.sent();
475
- warn("Failed to get VAST URL:", error);
476
- return [
535
+ _ret = _state.sent();
536
+ if (_type_of(_ret) === "object") return [
477
537
  2,
478
- null
538
+ _ret.v
479
539
  ];
540
+ _state.label = 3;
480
541
  case 3:
542
+ attempt++;
481
543
  return [
482
- 2
544
+ 3,
545
+ 1
546
+ ];
547
+ case 4:
548
+ if (_instanceof(lastError, Error)) {
549
+ throw lastError;
550
+ }
551
+ return [
552
+ 2,
553
+ []
483
554
  ];
484
555
  }
485
556
  });
@@ -492,7 +563,7 @@ function createPrebidManager() {
492
563
  return {
493
564
  initialize: initialize,
494
565
  requestBids: requestBids,
495
- getVastUrl: getVastUrl,
566
+ requestBidsUntilResponse: requestBidsUntilResponse,
496
567
  destroy: destroy,
497
568
  get isInitialized () {
498
569
  return initialized;
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/ubuntu24-new/Dev/stormcloud-vp/lib/sdk/prebid.cjs"],"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACA,EAAIA,KAAAA,OAAYC,OAAOC,cAAc;oBACjCC,mBAAmBF,OAAOG,wBAAwB;qBAClDC,oBAAoBJ,OAAOK,mBAAmB;QAC9CC,eAAeN,OAAOO,SAAS,CAACC,cAAc;iBAC9CC,WAAW,kBAACC,QAAQC;QACtB,IAAK,IAAIC,QAAQD,KACfZ,UAAUW,QAAQE,MAAM;cAAEC,KAAKF,GAAG,CAACC,KAAK;YAAEE,YAAY;MAAK;AAC/D;AACA,IAAIC,cAAc,qBAACC,IAAIC,MAAMC,QAAQC,IAAAA;IACnC,CAAA,CAAA,EAAIF,KAAAA,GAAQ,CAAA,GAAA,GAAA,CAAOA,qCAAP,SAAOA,KAAG,MAAM,YAAY,OAAOA,SAAS,YAAY;mCAC7D,kCAAA,2BAAA","sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// src/sdk/prebid.ts\nvar prebid_exports = {};\n__export(prebid_exports, {\n createPrebidManager: () => createPrebidManager\n});\nmodule.exports = __toCommonJS(prebid_exports);\nvar DEFAULT_TIMEOUT_MS = 3e3;\nvar AUCTION_URL = \"https://sspproxy.adstorm.co/openrtb2/auction/adstorm\";\nfunction createPrebidManager(options = {}) {\n let initialized = false;\n const debug = options.debug ?? false;\n function log(...args) {\n if (debug) {\n console.log(\"[Prebid]\", ...args);\n }\n }\n function warn(...args) {\n console.warn(\"[Prebid]\", ...args);\n }\n function parseResponse(data) {\n const bids = [];\n const seatbids = data?.seatbid || [];\n const currency = data?.cur || \"USD\";\n for (const seatbid of seatbids) {\n const seat = seatbid.seat || \"unknown\";\n const bidArray = seatbid.bid || [];\n for (const bid of bidArray) {\n const cacheUrl = bid.ext?.prebid?.cache?.vastXml?.url;\n const vastXml = bid.adm || void 0;\n const bidResponse = {\n bidder: seat,\n cpm: bid.price || 0,\n width: bid.w || 0,\n height: bid.h || 0,\n adId: bid.id || \"\",\n impId: bid.impid || \"\",\n creativeId: bid.crid || \"\",\n currency\n };\n if (cacheUrl) bidResponse.vastUrl = cacheUrl;\n if (vastXml) bidResponse.vastXml = vastXml;\n if (bid.adomain) bidResponse.adomain = bid.adomain;\n bids.push(bidResponse);\n }\n }\n bids.sort((a, b) => b.cpm - a.cpm);\n return bids;\n }\n function extractVastUrl(bids) {\n if (bids.length === 0) return null;\n const winner = bids[0];\n if (winner.vastUrl) {\n log(\n `Using cached VAST URL from ${winner.bidder} ($${winner.cpm.toFixed(2)} ${winner.currency})`\n );\n return winner.vastUrl;\n }\n if (winner.vastXml) {\n log(\n `Creating blob URL from VAST XML (${winner.bidder}, $${winner.cpm.toFixed(2)})`\n );\n try {\n const blob = new Blob([winner.vastXml], { type: \"text/xml\" });\n return URL.createObjectURL(blob);\n } catch (error) {\n warn(\"Failed to create blob URL from VAST XML:\", error);\n }\n }\n return null;\n }\n async function initialize() {\n if (initialized) return;\n initialized = true;\n log(\"Initialized, auction URL:\", AUCTION_URL);\n }\n async function requestBids() {\n if (!initialized) {\n throw new Error(\"Prebid not initialized. Call initialize() first.\");\n }\n const timeout = DEFAULT_TIMEOUT_MS;\n log(\"Fetching auction response from:\", AUCTION_URL);\n const controller = typeof AbortController !== \"undefined\" ? new AbortController() : null;\n const timeoutId = setTimeout(() => {\n controller?.abort();\n }, timeout + 2e3);\n try {\n const fetchOptions = {\n method: \"POST\"\n };\n if (controller) {\n fetchOptions.signal = controller.signal;\n }\n const response = await fetch(AUCTION_URL, fetchOptions);\n clearTimeout(timeoutId);\n if (!response.ok) {\n const body = await response.text().catch(() => \"\");\n throw new Error(\n `Prebid Server returned HTTP ${response.status}: ${body.slice(0, 200)}`\n );\n }\n const data = await response.json();\n if (debug && data?.ext?.responsetimemillis) {\n log(\"Bidder response times:\", data.ext.responsetimemillis);\n }\n if (debug && data?.ext?.errors) {\n warn(\"Auction errors:\", data.ext.errors);\n }\n const bids = parseResponse(data);\n log(`Received ${bids.length} bid(s)`);\n if (debug) {\n for (const b of bids) {\n log(\n ` ${b.bidder}: $${b.cpm.toFixed(2)} ${b.currency} ${b.width}x${b.height}` + (b.vastUrl ? \" [cached VAST]\" : \"\") + (b.vastXml && !b.vastUrl ? \" [VAST XML]\" : \"\")\n );\n }\n }\n return bids;\n } catch (error) {\n clearTimeout(timeoutId);\n if (error?.name === \"AbortError\") {\n warn(`Auction request timed out after ${timeout + 2e3}ms`);\n return [];\n }\n throw error;\n }\n }\n async function getVastUrl() {\n try {\n const bids = await requestBids();\n return extractVastUrl(bids);\n } catch (error) {\n warn(\"Failed to get VAST URL:\", error);\n return null;\n }\n }\n function destroy() {\n initialized = false;\n log(\"Destroyed\");\n }\n return {\n initialize,\n requestBids,\n getVastUrl,\n destroy,\n get isInitialized() {\n return initialized;\n }\n };\n}\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n createPrebidManager\n});\n"]}
1
+ {"version":3,"sources":["/home/ubuntu24-new/Dev/stormcloud-vp/lib/sdk/prebid.cjs"],"names":[],"mappings":"AAAA","sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// src/sdk/prebid.ts\nvar prebid_exports = {};\n__export(prebid_exports, {\n createPrebidManager: () => createPrebidManager\n});\nmodule.exports = __toCommonJS(prebid_exports);\nvar DEFAULT_TIMEOUT_MS = 3e3;\nvar AUCTION_URL = \"https://sspproxy.adstorm.co/openrtb2/auction/adstorm\";\nfunction createPrebidManager(options = {}) {\n let initialized = false;\n const debug = options.debug ?? false;\n function log(...args) {\n if (debug) {\n console.log(\"[Prebid]\", ...args);\n }\n }\n function warn(...args) {\n console.warn(\"[Prebid]\", ...args);\n }\n function parseResponse(data) {\n const bids = [];\n const seatbids = data?.seatbid || [];\n const currency = data?.cur || \"USD\";\n for (const seatbid of seatbids) {\n const seat = seatbid.seat || \"unknown\";\n const bidArray = seatbid.bid || [];\n for (const bid of bidArray) {\n const cacheUrl = bid.ext?.prebid?.cache?.vastXml?.url;\n const vastXml = bid.adm || void 0;\n const bidResponse = {\n bidder: seat,\n cpm: bid.price || 0,\n width: bid.w || 0,\n height: bid.h || 0,\n adId: bid.id || \"\",\n impId: bid.impid || \"\",\n creativeId: bid.crid || \"\",\n currency\n };\n if (cacheUrl) bidResponse.vastUrl = cacheUrl;\n if (vastXml) bidResponse.vastXml = vastXml;\n if (bid.adomain) bidResponse.adomain = bid.adomain;\n bids.push(bidResponse);\n }\n }\n bids.sort((a, b) => b.cpm - a.cpm);\n return bids;\n }\n async function initialize() {\n if (initialized) return;\n initialized = true;\n log(\"Initialized, auction URL:\", AUCTION_URL);\n }\n async function requestBids() {\n if (!initialized) {\n throw new Error(\"Prebid not initialized. Call initialize() first.\");\n }\n const timeout = DEFAULT_TIMEOUT_MS;\n log(\"Fetching auction response from:\", AUCTION_URL);\n const controller = typeof AbortController !== \"undefined\" ? new AbortController() : null;\n const timeoutId = setTimeout(() => {\n controller?.abort();\n }, timeout + 2e3);\n try {\n const fetchOptions = {\n method: \"POST\"\n };\n if (controller) {\n fetchOptions.signal = controller.signal;\n }\n const response = await fetch(AUCTION_URL, fetchOptions);\n clearTimeout(timeoutId);\n if (!response.ok) {\n const body = await response.text().catch(() => \"\");\n throw new Error(\n `Prebid Server returned HTTP ${response.status}: ${body.slice(0, 200)}`\n );\n }\n const data = await response.json();\n if (debug && data?.ext?.responsetimemillis) {\n log(\"Bidder response times:\", data.ext.responsetimemillis);\n }\n if (debug && data?.ext?.errors) {\n warn(\"Auction errors:\", data.ext.errors);\n }\n const bids = parseResponse(data);\n log(`Received ${bids.length} bid(s)`);\n if (debug) {\n for (const b of bids) {\n log(\n ` ${b.bidder}: $${b.cpm.toFixed(2)} ${b.currency} ${b.width}x${b.height}` + (b.vastUrl ? \" [cached VAST]\" : \"\") + (b.vastXml && !b.vastUrl ? \" [VAST XML]\" : \"\")\n );\n }\n }\n return bids;\n } catch (error) {\n clearTimeout(timeoutId);\n if (error?.name === \"AbortError\") {\n warn(`Auction request timed out after ${timeout + 2e3}ms`);\n return [];\n }\n throw error;\n }\n }\n const REQUEST_BIDS_MAX_RETRIES = 3;\n const REQUEST_BIDS_BACKOFF_MS = 1500;\n async function requestBidsUntilResponse() {\n if (!initialized) {\n throw new Error(\"Prebid not initialized. Call initialize() first.\");\n }\n let lastError;\n for (let attempt = 1; attempt <= REQUEST_BIDS_MAX_RETRIES; attempt++) {\n try {\n const bids = await requestBids();\n if (bids.length > 0) {\n log(`requestBidsUntilResponse: got ${bids.length} bid(s) on attempt ${attempt}`);\n return bids;\n }\n log(`requestBidsUntilResponse: no bids on attempt ${attempt}/${REQUEST_BIDS_MAX_RETRIES}`);\n } catch (err) {\n lastError = err;\n warn(`requestBidsUntilResponse: attempt ${attempt}/${REQUEST_BIDS_MAX_RETRIES} failed:`, err);\n }\n if (attempt < REQUEST_BIDS_MAX_RETRIES) {\n const delay = REQUEST_BIDS_BACKOFF_MS * attempt;\n log(`requestBidsUntilResponse: waiting ${delay}ms before retry`);\n await new Promise((resolve) => setTimeout(resolve, delay));\n }\n }\n if (lastError instanceof Error) {\n throw lastError;\n }\n return [];\n }\n function destroy() {\n initialized = false;\n log(\"Destroyed\");\n }\n return {\n initialize,\n requestBids,\n requestBidsUntilResponse,\n destroy,\n get isInitialized() {\n return initialized;\n }\n };\n}\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n createPrebidManager\n});\n"]}
@@ -1,4 +1,4 @@
1
- import { P as PrebidManager } from '../types-Bwp6-yys.cjs';
1
+ import { P as PrebidManager } from '../types-BOJiWNWa.cjs';
2
2
 
3
3
  interface PrebidManagerOptions {
4
4
  debug?: boolean;
@@ -49,6 +49,13 @@ function _define_property(obj, key, value) {
49
49
  }
50
50
  return obj;
51
51
  }
52
+ function _instanceof(left, right) {
53
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
54
+ return !!right[Symbol.hasInstance](left);
55
+ } else {
56
+ return left instanceof right;
57
+ }
58
+ }
52
59
  function _iterable_to_array(iter) {
53
60
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
54
61
  }
@@ -208,6 +215,20 @@ function _ts_generator(thisArg, body) {
208
215
  };
209
216
  }
210
217
  }
218
+ function _ts_values(o) {
219
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
220
+ if (m) return m.call(o);
221
+ if (o && typeof o.length === "number") return {
222
+ next: function() {
223
+ if (o && i >= o.length) o = void 0;
224
+ return {
225
+ value: o && o[i++],
226
+ done: !o
227
+ };
228
+ }
229
+ };
230
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
231
+ }
211
232
  var __create = Object.create;
212
233
  var __defProp = Object.defineProperty;
213
234
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -452,8 +473,8 @@ function createEmptyTrackingState() {
452
473
  complete: false
453
474
  };
454
475
  }
455
- function fireTrackingPixels(urls, sessionId, licenseKey) {
456
- var logPrefix = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "[VastParser]";
476
+ function fireTrackingPixels(urls, sessionId) {
477
+ var logPrefix = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "[VastParser]";
457
478
  if (!urls || urls.length === 0) return;
458
479
  urls.forEach(function(url) {
459
480
  try {
@@ -461,10 +482,8 @@ function fireTrackingPixels(urls, sessionId, licenseKey) {
461
482
  if (sessionId) {
462
483
  trackingUrl = "".concat(trackingUrl).concat(trackingUrl.includes("?") ? "&" : "?", "session_id=").concat(sessionId);
463
484
  }
464
- if (licenseKey) {
465
- trackingUrl = "".concat(trackingUrl).concat(trackingUrl.includes("?") ? "&" : "?", "license_key=").concat(licenseKey);
466
- }
467
485
  var img = new Image(1, 1);
486
+ img.onerror = function() {};
468
487
  img.src = trackingUrl;
469
488
  console.log("".concat(logPrefix, " Fired tracking pixel: ").concat(trackingUrl));
470
489
  } catch (error) {
@@ -566,28 +585,6 @@ function createPrebidManager() {
566
585
  });
567
586
  return bids;
568
587
  }
569
- function extractVastUrl(bids) {
570
- if (bids.length === 0) return null;
571
- var winner = bids[0];
572
- if (winner.vastUrl) {
573
- log("Using cached VAST URL from ".concat(winner.bidder, " ($").concat(winner.cpm.toFixed(2), " ").concat(winner.currency, ")"));
574
- return winner.vastUrl;
575
- }
576
- if (winner.vastXml) {
577
- log("Creating blob URL from VAST XML (".concat(winner.bidder, ", $").concat(winner.cpm.toFixed(2), ")"));
578
- try {
579
- var blob = new Blob([
580
- winner.vastXml
581
- ], {
582
- type: "text/xml"
583
- });
584
- return URL.createObjectURL(blob);
585
- } catch (error) {
586
- warn("Failed to create blob URL from VAST XML:", error);
587
- }
588
- }
589
- return null;
590
- }
591
588
  function initialize() {
592
589
  return _async_to_generator(function() {
593
590
  return _ts_generator(this, function(_state) {
@@ -711,38 +708,110 @@ function createPrebidManager() {
711
708
  });
712
709
  })();
713
710
  }
714
- function getVastUrl() {
711
+ var REQUEST_BIDS_MAX_RETRIES = 3;
712
+ var REQUEST_BIDS_BACKOFF_MS = 1500;
713
+ function requestBidsUntilResponse() {
715
714
  return _async_to_generator(function() {
716
- var bids, error;
715
+ var _loop, lastError, attempt, _ret;
717
716
  return _ts_generator(this, function(_state) {
718
717
  switch(_state.label){
719
718
  case 0:
720
- _state.trys.push([
721
- 0,
722
- 2,
723
- ,
724
- 3
725
- ]);
726
- return [
727
- 4,
728
- requestBids()
729
- ];
719
+ _loop = function(attempt) {
720
+ var bids, err, delay;
721
+ return _ts_generator(this, function(_state) {
722
+ switch(_state.label){
723
+ case 0:
724
+ _state.trys.push([
725
+ 0,
726
+ 2,
727
+ ,
728
+ 3
729
+ ]);
730
+ return [
731
+ 4,
732
+ requestBids()
733
+ ];
734
+ case 1:
735
+ bids = _state.sent();
736
+ if (bids.length > 0) {
737
+ log("requestBidsUntilResponse: got ".concat(bids.length, " bid(s) on attempt ").concat(attempt));
738
+ return [
739
+ 2,
740
+ {
741
+ v: bids
742
+ }
743
+ ];
744
+ }
745
+ log("requestBidsUntilResponse: no bids on attempt ".concat(attempt, "/").concat(REQUEST_BIDS_MAX_RETRIES));
746
+ return [
747
+ 3,
748
+ 3
749
+ ];
750
+ case 2:
751
+ err = _state.sent();
752
+ lastError = err;
753
+ warn("requestBidsUntilResponse: attempt ".concat(attempt, "/").concat(REQUEST_BIDS_MAX_RETRIES, " failed:"), err);
754
+ return [
755
+ 3,
756
+ 3
757
+ ];
758
+ case 3:
759
+ if (!(attempt < REQUEST_BIDS_MAX_RETRIES)) return [
760
+ 3,
761
+ 5
762
+ ];
763
+ delay = REQUEST_BIDS_BACKOFF_MS * attempt;
764
+ log("requestBidsUntilResponse: waiting ".concat(delay, "ms before retry"));
765
+ return [
766
+ 4,
767
+ new Promise(function(resolve) {
768
+ return setTimeout(resolve, delay);
769
+ })
770
+ ];
771
+ case 4:
772
+ _state.sent();
773
+ _state.label = 5;
774
+ case 5:
775
+ return [
776
+ 2
777
+ ];
778
+ }
779
+ });
780
+ };
781
+ if (!initialized) {
782
+ throw new Error("Prebid not initialized. Call initialize() first.");
783
+ }
784
+ attempt = 1;
785
+ _state.label = 1;
730
786
  case 1:
731
- bids = _state.sent();
787
+ if (!(attempt <= REQUEST_BIDS_MAX_RETRIES)) return [
788
+ 3,
789
+ 4
790
+ ];
732
791
  return [
733
- 2,
734
- extractVastUrl(bids)
792
+ 5,
793
+ _ts_values(_loop(attempt))
735
794
  ];
736
795
  case 2:
737
- error = _state.sent();
738
- warn("Failed to get VAST URL:", error);
739
- return [
796
+ _ret = _state.sent();
797
+ if (_type_of(_ret) === "object") return [
740
798
  2,
741
- null
799
+ _ret.v
742
800
  ];
801
+ _state.label = 3;
743
802
  case 3:
803
+ attempt++;
744
804
  return [
745
- 2
805
+ 3,
806
+ 1
807
+ ];
808
+ case 4:
809
+ if (_instanceof(lastError, Error)) {
810
+ throw lastError;
811
+ }
812
+ return [
813
+ 2,
814
+ []
746
815
  ];
747
816
  }
748
817
  });
@@ -755,7 +824,7 @@ function createPrebidManager() {
755
824
  return {
756
825
  initialize: initialize,
757
826
  requestBids: requestBids,
758
- getVastUrl: getVastUrl,
827
+ requestBidsUntilResponse: requestBidsUntilResponse,
759
828
  destroy: destroy,
760
829
  get isInitialized () {
761
830
  return initialized;
@@ -815,7 +884,7 @@ function createPrebidController(contentVideo, options) {
815
884
  return "session-".concat(Date.now(), "-").concat(Math.random().toString(36).substr(2, 9));
816
885
  }
817
886
  function fireTrackingPixels2(urls) {
818
- fireTrackingPixels(urls, sessionId, licenseKey, LOG);
887
+ fireTrackingPixels(urls, sessionId, LOG);
819
888
  }
820
889
  function getMainStreamQuality() {
821
890
  if (!mainHlsInstance || !mainHlsInstance.levels) {
@@ -1042,12 +1111,12 @@ function createPrebidController(contentVideo, options) {
1042
1111
  _state.sent();
1043
1112
  return [
1044
1113
  4,
1045
- prebidManager.requestBids()
1114
+ prebidManager.requestBidsUntilResponse()
1046
1115
  ];
1047
1116
  case 2:
1048
1117
  bids = _state.sent();
1049
1118
  if (bids.length === 0) {
1050
- console.warn("".concat(LOG, " No bids received from Prebid Server"));
1119
+ console.warn("".concat(LOG, " No bids received from Prebid Server after retries"));
1051
1120
  return [
1052
1121
  2,
1053
1122
  null
@@ -1154,7 +1223,7 @@ function createPrebidController(contentVideo, options) {
1154
1223
  adContainerEl = container;
1155
1224
  }
1156
1225
  },
1157
- requestAds: function requestAds(vastTagUrl) {
1226
+ requestAds: function requestAds() {
1158
1227
  return _async_to_generator(function() {
1159
1228
  var ad, error;
1160
1229
  return _ts_generator(this, function(_state) {
@@ -1166,7 +1235,7 @@ function createPrebidController(contentVideo, options) {
1166
1235
  Promise.reject(new Error("Controller has been destroyed"))
1167
1236
  ];
1168
1237
  }
1169
- console.log("".concat(LOG, " requestAds called:"), vastTagUrl || "(empty - will run Prebid auction)");
1238
+ console.log("".concat(LOG, " requestAds called (Prebid auction with retry until response)"));
1170
1239
  if (adPlaying) {
1171
1240
  console.warn("".concat(LOG, " Cannot request new ads while an ad is playing"));
1172
1241
  return [
@@ -1178,36 +1247,17 @@ function createPrebidController(contentVideo, options) {
1178
1247
  case 1:
1179
1248
  _state.trys.push([
1180
1249
  1,
1181
- 6,
1250
+ 3,
1182
1251
  ,
1183
- 7
1252
+ 4
1184
1253
  ]);
1185
1254
  sessionId = generateSessionId();
1186
- if (!(vastTagUrl && vastTagUrl.length > 0)) return [
1187
- 3,
1188
- 3
1189
- ];
1190
- console.log("".concat(LOG, " Fetching VAST from provided URL"));
1191
- return [
1192
- 4,
1193
- fetchAndParseVastAd(vastTagUrl, "mp4-first", LOG)
1194
- ];
1195
- case 2:
1196
- ad = _state.sent();
1197
- return [
1198
- 3,
1199
- 5
1200
- ];
1201
- case 3:
1202
- console.log("".concat(LOG, " Running Prebid Server auction"));
1203
1255
  return [
1204
1256
  4,
1205
1257
  runPrebidAuction()
1206
1258
  ];
1207
- case 4:
1259
+ case 2:
1208
1260
  ad = _state.sent();
1209
- _state.label = 5;
1210
- case 5:
1211
1261
  if (!ad) {
1212
1262
  console.warn("".concat(LOG, " No ads available"));
1213
1263
  emit("ad_error");
@@ -1224,7 +1274,7 @@ function createPrebidController(contentVideo, options) {
1224
1274
  2,
1225
1275
  Promise.resolve()
1226
1276
  ];
1227
- case 6:
1277
+ case 3:
1228
1278
  error = _state.sent();
1229
1279
  console.error("".concat(LOG, " Error requesting ads:"), error);
1230
1280
  emit("ad_error");
@@ -1232,7 +1282,7 @@ function createPrebidController(contentVideo, options) {
1232
1282
  2,
1233
1283
  Promise.reject(error)
1234
1284
  ];
1235
- case 7:
1285
+ case 4:
1236
1286
  return [
1237
1287
  2
1238
1288
  ];