stormcloud-video-player 0.5.6 → 0.5.7

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 (37) hide show
  1. package/README.md +28 -40
  2. package/dist/stormcloud-vp.min.js +1 -1
  3. package/lib/index.cjs +1537 -4636
  4. package/lib/index.cjs.map +1 -1
  5. package/lib/index.d.cts +7 -67
  6. package/lib/index.d.ts +7 -67
  7. package/lib/index.js +1540 -4623
  8. package/lib/index.js.map +1 -1
  9. package/lib/player/StormcloudVideoPlayer.cjs +811 -3880
  10. package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
  11. package/lib/player/StormcloudVideoPlayer.d.cts +3 -37
  12. package/lib/players/HlsPlayer.cjs +811 -3880
  13. package/lib/players/HlsPlayer.cjs.map +1 -1
  14. package/lib/players/HlsPlayer.d.cts +1 -1
  15. package/lib/players/index.cjs +811 -3880
  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 +123 -71
  21. package/lib/sdk/prebidController.cjs.map +1 -1
  22. package/lib/sdk/prebidController.d.cts +2 -2
  23. package/lib/{types-Bwp6-yys.d.cts → types-BOJiWNWa.d.cts} +4 -7
  24. package/lib/ui/StormcloudVideoPlayer.cjs +811 -3890
  25. package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
  26. package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
  27. package/lib/utils/browserCompat.cjs +0 -3
  28. package/lib/utils/browserCompat.cjs.map +1 -1
  29. package/lib/utils/browserCompat.d.cts +0 -1
  30. package/lib/utils/tracking.d.cts +1 -1
  31. package/package.json +1 -1
  32. package/lib/sdk/hlsAdPlayer.cjs +0 -1053
  33. package/lib/sdk/hlsAdPlayer.cjs.map +0 -1
  34. package/lib/sdk/hlsAdPlayer.d.cts +0 -10
  35. package/lib/sdk/ima.cjs +0 -1384
  36. package/lib/sdk/ima.cjs.map +0 -1
  37. 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;
@@ -566,28 +587,6 @@ function createPrebidManager() {
566
587
  });
567
588
  return bids;
568
589
  }
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
590
  function initialize() {
592
591
  return _async_to_generator(function() {
593
592
  return _ts_generator(this, function(_state) {
@@ -711,38 +710,110 @@ function createPrebidManager() {
711
710
  });
712
711
  })();
713
712
  }
714
- function getVastUrl() {
713
+ var REQUEST_BIDS_MAX_RETRIES = 3;
714
+ var REQUEST_BIDS_BACKOFF_MS = 1500;
715
+ function requestBidsUntilResponse() {
715
716
  return _async_to_generator(function() {
716
- var bids, error;
717
+ var _loop, lastError, attempt, _ret;
717
718
  return _ts_generator(this, function(_state) {
718
719
  switch(_state.label){
719
720
  case 0:
720
- _state.trys.push([
721
- 0,
722
- 2,
723
- ,
724
- 3
725
- ]);
726
- return [
727
- 4,
728
- requestBids()
729
- ];
721
+ _loop = function(attempt) {
722
+ var bids, err, delay;
723
+ return _ts_generator(this, function(_state) {
724
+ switch(_state.label){
725
+ case 0:
726
+ _state.trys.push([
727
+ 0,
728
+ 2,
729
+ ,
730
+ 3
731
+ ]);
732
+ return [
733
+ 4,
734
+ requestBids()
735
+ ];
736
+ case 1:
737
+ bids = _state.sent();
738
+ if (bids.length > 0) {
739
+ log("requestBidsUntilResponse: got ".concat(bids.length, " bid(s) on attempt ").concat(attempt));
740
+ return [
741
+ 2,
742
+ {
743
+ v: bids
744
+ }
745
+ ];
746
+ }
747
+ log("requestBidsUntilResponse: no bids on attempt ".concat(attempt, "/").concat(REQUEST_BIDS_MAX_RETRIES));
748
+ return [
749
+ 3,
750
+ 3
751
+ ];
752
+ case 2:
753
+ err = _state.sent();
754
+ lastError = err;
755
+ warn("requestBidsUntilResponse: attempt ".concat(attempt, "/").concat(REQUEST_BIDS_MAX_RETRIES, " failed:"), err);
756
+ return [
757
+ 3,
758
+ 3
759
+ ];
760
+ case 3:
761
+ if (!(attempt < REQUEST_BIDS_MAX_RETRIES)) return [
762
+ 3,
763
+ 5
764
+ ];
765
+ delay = REQUEST_BIDS_BACKOFF_MS * attempt;
766
+ log("requestBidsUntilResponse: waiting ".concat(delay, "ms before retry"));
767
+ return [
768
+ 4,
769
+ new Promise(function(resolve) {
770
+ return setTimeout(resolve, delay);
771
+ })
772
+ ];
773
+ case 4:
774
+ _state.sent();
775
+ _state.label = 5;
776
+ case 5:
777
+ return [
778
+ 2
779
+ ];
780
+ }
781
+ });
782
+ };
783
+ if (!initialized) {
784
+ throw new Error("Prebid not initialized. Call initialize() first.");
785
+ }
786
+ attempt = 1;
787
+ _state.label = 1;
730
788
  case 1:
731
- bids = _state.sent();
789
+ if (!(attempt <= REQUEST_BIDS_MAX_RETRIES)) return [
790
+ 3,
791
+ 4
792
+ ];
732
793
  return [
733
- 2,
734
- extractVastUrl(bids)
794
+ 5,
795
+ _ts_values(_loop(attempt))
735
796
  ];
736
797
  case 2:
737
- error = _state.sent();
738
- warn("Failed to get VAST URL:", error);
739
- return [
798
+ _ret = _state.sent();
799
+ if (_type_of(_ret) === "object") return [
740
800
  2,
741
- null
801
+ _ret.v
742
802
  ];
803
+ _state.label = 3;
743
804
  case 3:
805
+ attempt++;
744
806
  return [
745
- 2
807
+ 3,
808
+ 1
809
+ ];
810
+ case 4:
811
+ if (_instanceof(lastError, Error)) {
812
+ throw lastError;
813
+ }
814
+ return [
815
+ 2,
816
+ []
746
817
  ];
747
818
  }
748
819
  });
@@ -755,7 +826,7 @@ function createPrebidManager() {
755
826
  return {
756
827
  initialize: initialize,
757
828
  requestBids: requestBids,
758
- getVastUrl: getVastUrl,
829
+ requestBidsUntilResponse: requestBidsUntilResponse,
759
830
  destroy: destroy,
760
831
  get isInitialized () {
761
832
  return initialized;
@@ -1042,12 +1113,12 @@ function createPrebidController(contentVideo, options) {
1042
1113
  _state.sent();
1043
1114
  return [
1044
1115
  4,
1045
- prebidManager.requestBids()
1116
+ prebidManager.requestBidsUntilResponse()
1046
1117
  ];
1047
1118
  case 2:
1048
1119
  bids = _state.sent();
1049
1120
  if (bids.length === 0) {
1050
- console.warn("".concat(LOG, " No bids received from Prebid Server"));
1121
+ console.warn("".concat(LOG, " No bids received from Prebid Server after retries"));
1051
1122
  return [
1052
1123
  2,
1053
1124
  null
@@ -1154,7 +1225,7 @@ function createPrebidController(contentVideo, options) {
1154
1225
  adContainerEl = container;
1155
1226
  }
1156
1227
  },
1157
- requestAds: function requestAds(vastTagUrl) {
1228
+ requestAds: function requestAds() {
1158
1229
  return _async_to_generator(function() {
1159
1230
  var ad, error;
1160
1231
  return _ts_generator(this, function(_state) {
@@ -1166,7 +1237,7 @@ function createPrebidController(contentVideo, options) {
1166
1237
  Promise.reject(new Error("Controller has been destroyed"))
1167
1238
  ];
1168
1239
  }
1169
- console.log("".concat(LOG, " requestAds called:"), vastTagUrl || "(empty - will run Prebid auction)");
1240
+ console.log("".concat(LOG, " requestAds called (Prebid auction with retry until response)"));
1170
1241
  if (adPlaying) {
1171
1242
  console.warn("".concat(LOG, " Cannot request new ads while an ad is playing"));
1172
1243
  return [
@@ -1178,36 +1249,17 @@ function createPrebidController(contentVideo, options) {
1178
1249
  case 1:
1179
1250
  _state.trys.push([
1180
1251
  1,
1181
- 6,
1252
+ 3,
1182
1253
  ,
1183
- 7
1254
+ 4
1184
1255
  ]);
1185
1256
  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
1257
  return [
1204
1258
  4,
1205
1259
  runPrebidAuction()
1206
1260
  ];
1207
- case 4:
1261
+ case 2:
1208
1262
  ad = _state.sent();
1209
- _state.label = 5;
1210
- case 5:
1211
1263
  if (!ad) {
1212
1264
  console.warn("".concat(LOG, " No ads available"));
1213
1265
  emit("ad_error");
@@ -1224,7 +1276,7 @@ function createPrebidController(contentVideo, options) {
1224
1276
  2,
1225
1277
  Promise.resolve()
1226
1278
  ];
1227
- case 6:
1279
+ case 3:
1228
1280
  error = _state.sent();
1229
1281
  console.error("".concat(LOG, " Error requesting ads:"), error);
1230
1282
  emit("ad_error");
@@ -1232,7 +1284,7 @@ function createPrebidController(contentVideo, options) {
1232
1284
  2,
1233
1285
  Promise.reject(error)
1234
1286
  ];
1235
- case 7:
1287
+ case 4:
1236
1288
  return [
1237
1289
  2
1238
1290
  ];