stormcloud-video-player 0.5.2 → 0.5.3
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 +1 -1
- package/lib/index.cjs +23 -118
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +7 -47
- package/lib/index.d.ts +7 -47
- package/lib/index.js +23 -118
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +20 -111
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/players/FilePlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +20 -111
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.d.cts +1 -1
- package/lib/players/index.cjs +20 -111
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.d.cts +1 -1
- package/lib/sdk/ima.cjs.map +1 -1
- package/lib/sdk/ima.d.cts +1 -1
- package/lib/sdk/prebid.cjs +11 -77
- package/lib/sdk/prebid.cjs.map +1 -1
- package/lib/sdk/prebid.d.cts +6 -3
- package/lib/sdk/prebidController.cjs +16 -99
- package/lib/sdk/prebidController.cjs.map +1 -1
- package/lib/sdk/prebidController.d.cts +3 -2
- package/lib/sdk/vastParser.cjs.map +1 -1
- package/lib/{types-g2d4Akez.d.cts → types-CRi_KrjM.d.cts} +1 -45
- package/lib/ui/StormcloudVideoPlayer.cjs +23 -118
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/utils/browserCompat.cjs.map +1 -1
- package/lib/utils/polyfills.cjs.map +1 -1
- package/lib/utils/tracking.cjs.map +1 -1
- package/lib/utils/tracking.d.cts +1 -1
- package/package.json +1 -1
package/lib/sdk/prebid.cjs
CHANGED
|
@@ -203,12 +203,12 @@ __export(prebid_exports, {
|
|
|
203
203
|
});
|
|
204
204
|
module.exports = __toCommonJS(prebid_exports);
|
|
205
205
|
var DEFAULT_TIMEOUT_MS = 3e3;
|
|
206
|
-
var
|
|
207
|
-
function createPrebidManager(
|
|
206
|
+
var AUCTION_URL = "https://sspproxy.adstorm.co/openrtb2/auction/adstorm";
|
|
207
|
+
function createPrebidManager() {
|
|
208
|
+
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
208
209
|
var initialized = false;
|
|
209
|
-
var
|
|
210
|
-
var
|
|
211
|
-
var debug = (_config_debug = config.debug) !== null && _config_debug !== void 0 ? _config_debug : false;
|
|
210
|
+
var _options_debug;
|
|
211
|
+
var debug = (_options_debug = options.debug) !== null && _options_debug !== void 0 ? _options_debug : false;
|
|
212
212
|
function log() {
|
|
213
213
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
214
214
|
args[_key] = arguments[_key];
|
|
@@ -229,49 +229,6 @@ function createPrebidManager(config) {
|
|
|
229
229
|
"[Prebid]"
|
|
230
230
|
].concat(_to_consumable_array(args)));
|
|
231
231
|
}
|
|
232
|
-
function resolveServerUrl() {
|
|
233
|
-
var _config_ortbRequest_ext_prebid_server, _config_ortbRequest_ext_prebid, _config_ortbRequest_ext, _config_ortbRequest;
|
|
234
|
-
if (config.serverUrl) {
|
|
235
|
-
return config.serverUrl.replace(/\/$/, "");
|
|
236
|
-
}
|
|
237
|
-
var extUrl = (_config_ortbRequest = config.ortbRequest) === null || _config_ortbRequest === void 0 ? void 0 : (_config_ortbRequest_ext = _config_ortbRequest.ext) === null || _config_ortbRequest_ext === void 0 ? void 0 : (_config_ortbRequest_ext_prebid = _config_ortbRequest_ext.prebid) === null || _config_ortbRequest_ext_prebid === void 0 ? void 0 : (_config_ortbRequest_ext_prebid_server = _config_ortbRequest_ext_prebid.server) === null || _config_ortbRequest_ext_prebid_server === void 0 ? void 0 : _config_ortbRequest_ext_prebid_server.externalurl;
|
|
238
|
-
if (typeof extUrl === "string" && extUrl.length > 0) {
|
|
239
|
-
return extUrl.replace(/\/$/, "");
|
|
240
|
-
}
|
|
241
|
-
throw new Error("Prebid Server URL not configured. Provide serverUrl in PrebidConfig or ext.prebid.server.externalurl in the OpenRTB request.");
|
|
242
|
-
}
|
|
243
|
-
function buildRequest() {
|
|
244
|
-
var req = JSON.parse(JSON.stringify(config.ortbRequest));
|
|
245
|
-
req.id = "".concat(req.id || "prebid", "-").concat(Date.now(), "-").concat(Math.random().toString(36).slice(2, 8));
|
|
246
|
-
if (!req.ext) req.ext = {};
|
|
247
|
-
if (!req.ext.prebid) req.ext.prebid = {};
|
|
248
|
-
if (!req.ext.prebid.cache) req.ext.prebid.cache = {};
|
|
249
|
-
if (!req.ext.prebid.cache.vastxml) req.ext.prebid.cache.vastxml = {};
|
|
250
|
-
if (!req.ext.prebid.targeting) {
|
|
251
|
-
req.ext.prebid.targeting = {
|
|
252
|
-
includewinners: true,
|
|
253
|
-
includebidderkeys: false
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
if (!req.device) req.device = {};
|
|
257
|
-
if (typeof navigator !== "undefined") {
|
|
258
|
-
if (!req.device.ua) req.device.ua = navigator.userAgent;
|
|
259
|
-
if (!req.device.language) {
|
|
260
|
-
req.device.language = (navigator.language || "").split("-")[0] || "en";
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
if (typeof window !== "undefined") {
|
|
264
|
-
var _window_screen, _window_screen1;
|
|
265
|
-
if (!req.device.w) req.device.w = ((_window_screen = window.screen) === null || _window_screen === void 0 ? void 0 : _window_screen.width) || window.innerWidth;
|
|
266
|
-
if (!req.device.h) req.device.h = ((_window_screen1 = window.screen) === null || _window_screen1 === void 0 ? void 0 : _window_screen1.height) || window.innerHeight;
|
|
267
|
-
}
|
|
268
|
-
if (!req.site) req.site = {};
|
|
269
|
-
if (typeof window !== "undefined") {
|
|
270
|
-
if (!req.site.page) req.site.page = window.location.href;
|
|
271
|
-
if (!req.site.domain) req.site.domain = window.location.hostname;
|
|
272
|
-
}
|
|
273
|
-
return req;
|
|
274
|
-
}
|
|
275
232
|
function parseResponse(data) {
|
|
276
233
|
var bids = [];
|
|
277
234
|
var seatbids = (data === null || data === void 0 ? void 0 : data.seatbid) || [];
|
|
@@ -341,12 +298,6 @@ function createPrebidManager(config) {
|
|
|
341
298
|
function extractVastUrl(bids) {
|
|
342
299
|
if (bids.length === 0) return null;
|
|
343
300
|
var winner = bids[0];
|
|
344
|
-
var _config_cpmFloor;
|
|
345
|
-
var cpmFloor = (_config_cpmFloor = config.cpmFloor) !== null && _config_cpmFloor !== void 0 ? _config_cpmFloor : 0;
|
|
346
|
-
if (cpmFloor > 0 && winner.cpm < cpmFloor) {
|
|
347
|
-
log("Winning bid $".concat(winner.cpm.toFixed(2), " below CPM floor $").concat(cpmFloor.toFixed(2), ", rejecting"));
|
|
348
|
-
return null;
|
|
349
|
-
}
|
|
350
301
|
if (winner.vastUrl) {
|
|
351
302
|
log("Using cached VAST URL from ".concat(winner.bidder, " ($").concat(winner.cpm.toFixed(2), " ").concat(winner.currency, ")"));
|
|
352
303
|
return winner.vastUrl;
|
|
@@ -368,22 +319,12 @@ function createPrebidManager(config) {
|
|
|
368
319
|
}
|
|
369
320
|
function initialize() {
|
|
370
321
|
return _async_to_generator(function() {
|
|
371
|
-
var _config_ortbRequest;
|
|
372
322
|
return _ts_generator(this, function(_state) {
|
|
373
323
|
if (initialized) return [
|
|
374
324
|
2
|
|
375
325
|
];
|
|
376
|
-
serverUrl = resolveServerUrl();
|
|
377
|
-
if (!((_config_ortbRequest = config.ortbRequest) === null || _config_ortbRequest === void 0 ? void 0 : _config_ortbRequest.imp) || config.ortbRequest.imp.length === 0) {
|
|
378
|
-
throw new Error("No impressions (imp) defined in the OpenRTB request.");
|
|
379
|
-
}
|
|
380
326
|
initialized = true;
|
|
381
|
-
log("Initialized
|
|
382
|
-
log("Bidders:", config.ortbRequest.imp.map(function(imp) {
|
|
383
|
-
var _imp_ext_prebid, _imp_ext;
|
|
384
|
-
var bidders = (_imp_ext = imp.ext) === null || _imp_ext === void 0 ? void 0 : (_imp_ext_prebid = _imp_ext.prebid) === null || _imp_ext_prebid === void 0 ? void 0 : _imp_ext_prebid.bidder;
|
|
385
|
-
return bidders ? Object.keys(bidders).join(", ") : "none";
|
|
386
|
-
}).join("; "));
|
|
327
|
+
log("Initialized, auction URL:", AUCTION_URL);
|
|
387
328
|
return [
|
|
388
329
|
2
|
|
389
330
|
];
|
|
@@ -392,17 +333,15 @@ function createPrebidManager(config) {
|
|
|
392
333
|
}
|
|
393
334
|
function requestBids() {
|
|
394
335
|
return _async_to_generator(function() {
|
|
395
|
-
var
|
|
336
|
+
var timeout, controller, timeoutId, _data_ext, _data_ext1, fetchOptions, response, body, data, bids, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, b, error;
|
|
396
337
|
return _ts_generator(this, function(_state) {
|
|
397
338
|
switch(_state.label){
|
|
398
339
|
case 0:
|
|
399
340
|
if (!initialized) {
|
|
400
341
|
throw new Error("Prebid not initialized. Call initialize() first.");
|
|
401
342
|
}
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
timeout = (_ref = (_config_timeout = config.timeout) !== null && _config_timeout !== void 0 ? _config_timeout : config.ortbRequest.tmax) !== null && _ref !== void 0 ? _ref : DEFAULT_TIMEOUT_MS;
|
|
405
|
-
log("Sending auction request to:", auctionUrl);
|
|
343
|
+
timeout = DEFAULT_TIMEOUT_MS;
|
|
344
|
+
log("Fetching auction response from:", AUCTION_URL);
|
|
406
345
|
controller = typeof AbortController !== "undefined" ? new AbortController() : null;
|
|
407
346
|
timeoutId = setTimeout(function() {
|
|
408
347
|
controller === null || controller === void 0 ? void 0 : controller.abort();
|
|
@@ -416,18 +355,14 @@ function createPrebidManager(config) {
|
|
|
416
355
|
7
|
|
417
356
|
]);
|
|
418
357
|
fetchOptions = {
|
|
419
|
-
method: "POST"
|
|
420
|
-
headers: {
|
|
421
|
-
"Content-Type": "application/json"
|
|
422
|
-
},
|
|
423
|
-
body: JSON.stringify(request)
|
|
358
|
+
method: "POST"
|
|
424
359
|
};
|
|
425
360
|
if (controller) {
|
|
426
361
|
fetchOptions.signal = controller.signal;
|
|
427
362
|
}
|
|
428
363
|
return [
|
|
429
364
|
4,
|
|
430
|
-
fetch(
|
|
365
|
+
fetch(AUCTION_URL, fetchOptions)
|
|
431
366
|
];
|
|
432
367
|
case 2:
|
|
433
368
|
response = _state.sent();
|
|
@@ -544,7 +479,6 @@ function createPrebidManager(config) {
|
|
|
544
479
|
}
|
|
545
480
|
function destroy() {
|
|
546
481
|
initialized = false;
|
|
547
|
-
serverUrl = "";
|
|
548
482
|
log("Destroyed");
|
|
549
483
|
}
|
|
550
484
|
return {
|
package/lib/sdk/prebid.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/ubuntu24/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
|
|
1
|
+
{"version":3,"sources":["/home/ubuntu24/Dev/stormcloud-vp/lib/sdk/prebid.cjs"],"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBACIA,KAAAA,KAAYC,OAAOC,cAAc,CAAA;wBACjCC;;4BAAAA,UAAmBF,OAAOG,wBAAwB;;;;;;;;QAEtD,EAAIC,eAAeJ,OAAOK,SAAS,CAACC,cAAc;;IAClD,EAAIC,OAAAA,IAAW,SAACC,QAAQC;QACtB,IAAK,IAAIC,MAAAA,EAAQD,IACfV,UAAUS,QAAQE,MAAM;YAAEC,KAAKF,GAAG,CAACC,KAAK;UAAEE,YAAY;MAAK,KAAA;QAC/D,YAAA;qBACIC,cAAc,SAACC,IAAIC,MAAMC,QAAQC;QACnC,IAAIF,QAAQ,CAAA,OAAOA,qCAAP,SAAOA,KAAG,MAAM,YAAY,OAAOA,SAAS,YAAY;yBAC7D,kCAAA,2BAAA;;;oBAAA,IAAIG,MAAJ;kBACH,IAAI,CAACd,aAAae,IAAI,CAACL,IAAII,QAAQA,QAAQF,QACzCjB,UAAUe,IAAII,KAAK;oBAAEP,KAAK;+BAAMI,IAAI,CAACG,IAAI,qBAAA;;2CAAEN,YAAY,CAAEK,CAAAA,OAAOf,iBAAiBa,MAAMG,IAAG,KAAMD,KAAKL,UAAU;iBAAC","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"]}
|
package/lib/sdk/prebid.d.cts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { P as
|
|
1
|
+
import { P as PrebidManager } from '../types-CRi_KrjM.cjs';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
interface PrebidManagerOptions {
|
|
4
|
+
debug?: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare function createPrebidManager(options?: PrebidManagerOptions): PrebidManager;
|
|
4
7
|
|
|
5
|
-
export { createPrebidManager };
|
|
8
|
+
export { type PrebidManagerOptions, createPrebidManager };
|
|
@@ -466,12 +466,12 @@ function fireTrackingPixels(urls, sessionId, licenseKey) {
|
|
|
466
466
|
}
|
|
467
467
|
// src/sdk/prebid.ts
|
|
468
468
|
var DEFAULT_TIMEOUT_MS = 3e3;
|
|
469
|
-
var
|
|
470
|
-
function createPrebidManager(
|
|
469
|
+
var AUCTION_URL = "https://sspproxy.adstorm.co/openrtb2/auction/adstorm";
|
|
470
|
+
function createPrebidManager() {
|
|
471
|
+
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
471
472
|
var initialized = false;
|
|
472
|
-
var
|
|
473
|
-
var
|
|
474
|
-
var debug = (_config_debug = config.debug) !== null && _config_debug !== void 0 ? _config_debug : false;
|
|
473
|
+
var _options_debug;
|
|
474
|
+
var debug = (_options_debug = options.debug) !== null && _options_debug !== void 0 ? _options_debug : false;
|
|
475
475
|
function log() {
|
|
476
476
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
477
477
|
args[_key] = arguments[_key];
|
|
@@ -492,49 +492,6 @@ function createPrebidManager(config) {
|
|
|
492
492
|
"[Prebid]"
|
|
493
493
|
].concat(_to_consumable_array(args)));
|
|
494
494
|
}
|
|
495
|
-
function resolveServerUrl() {
|
|
496
|
-
var _config_ortbRequest_ext_prebid_server, _config_ortbRequest_ext_prebid, _config_ortbRequest_ext, _config_ortbRequest;
|
|
497
|
-
if (config.serverUrl) {
|
|
498
|
-
return config.serverUrl.replace(/\/$/, "");
|
|
499
|
-
}
|
|
500
|
-
var extUrl = (_config_ortbRequest = config.ortbRequest) === null || _config_ortbRequest === void 0 ? void 0 : (_config_ortbRequest_ext = _config_ortbRequest.ext) === null || _config_ortbRequest_ext === void 0 ? void 0 : (_config_ortbRequest_ext_prebid = _config_ortbRequest_ext.prebid) === null || _config_ortbRequest_ext_prebid === void 0 ? void 0 : (_config_ortbRequest_ext_prebid_server = _config_ortbRequest_ext_prebid.server) === null || _config_ortbRequest_ext_prebid_server === void 0 ? void 0 : _config_ortbRequest_ext_prebid_server.externalurl;
|
|
501
|
-
if (typeof extUrl === "string" && extUrl.length > 0) {
|
|
502
|
-
return extUrl.replace(/\/$/, "");
|
|
503
|
-
}
|
|
504
|
-
throw new Error("Prebid Server URL not configured. Provide serverUrl in PrebidConfig or ext.prebid.server.externalurl in the OpenRTB request.");
|
|
505
|
-
}
|
|
506
|
-
function buildRequest() {
|
|
507
|
-
var req = JSON.parse(JSON.stringify(config.ortbRequest));
|
|
508
|
-
req.id = "".concat(req.id || "prebid", "-").concat(Date.now(), "-").concat(Math.random().toString(36).slice(2, 8));
|
|
509
|
-
if (!req.ext) req.ext = {};
|
|
510
|
-
if (!req.ext.prebid) req.ext.prebid = {};
|
|
511
|
-
if (!req.ext.prebid.cache) req.ext.prebid.cache = {};
|
|
512
|
-
if (!req.ext.prebid.cache.vastxml) req.ext.prebid.cache.vastxml = {};
|
|
513
|
-
if (!req.ext.prebid.targeting) {
|
|
514
|
-
req.ext.prebid.targeting = {
|
|
515
|
-
includewinners: true,
|
|
516
|
-
includebidderkeys: false
|
|
517
|
-
};
|
|
518
|
-
}
|
|
519
|
-
if (!req.device) req.device = {};
|
|
520
|
-
if (typeof navigator !== "undefined") {
|
|
521
|
-
if (!req.device.ua) req.device.ua = navigator.userAgent;
|
|
522
|
-
if (!req.device.language) {
|
|
523
|
-
req.device.language = (navigator.language || "").split("-")[0] || "en";
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
if (typeof window !== "undefined") {
|
|
527
|
-
var _window_screen, _window_screen1;
|
|
528
|
-
if (!req.device.w) req.device.w = ((_window_screen = window.screen) === null || _window_screen === void 0 ? void 0 : _window_screen.width) || window.innerWidth;
|
|
529
|
-
if (!req.device.h) req.device.h = ((_window_screen1 = window.screen) === null || _window_screen1 === void 0 ? void 0 : _window_screen1.height) || window.innerHeight;
|
|
530
|
-
}
|
|
531
|
-
if (!req.site) req.site = {};
|
|
532
|
-
if (typeof window !== "undefined") {
|
|
533
|
-
if (!req.site.page) req.site.page = window.location.href;
|
|
534
|
-
if (!req.site.domain) req.site.domain = window.location.hostname;
|
|
535
|
-
}
|
|
536
|
-
return req;
|
|
537
|
-
}
|
|
538
495
|
function parseResponse(data) {
|
|
539
496
|
var bids = [];
|
|
540
497
|
var seatbids = (data === null || data === void 0 ? void 0 : data.seatbid) || [];
|
|
@@ -604,12 +561,6 @@ function createPrebidManager(config) {
|
|
|
604
561
|
function extractVastUrl(bids) {
|
|
605
562
|
if (bids.length === 0) return null;
|
|
606
563
|
var winner = bids[0];
|
|
607
|
-
var _config_cpmFloor;
|
|
608
|
-
var cpmFloor = (_config_cpmFloor = config.cpmFloor) !== null && _config_cpmFloor !== void 0 ? _config_cpmFloor : 0;
|
|
609
|
-
if (cpmFloor > 0 && winner.cpm < cpmFloor) {
|
|
610
|
-
log("Winning bid $".concat(winner.cpm.toFixed(2), " below CPM floor $").concat(cpmFloor.toFixed(2), ", rejecting"));
|
|
611
|
-
return null;
|
|
612
|
-
}
|
|
613
564
|
if (winner.vastUrl) {
|
|
614
565
|
log("Using cached VAST URL from ".concat(winner.bidder, " ($").concat(winner.cpm.toFixed(2), " ").concat(winner.currency, ")"));
|
|
615
566
|
return winner.vastUrl;
|
|
@@ -631,22 +582,12 @@ function createPrebidManager(config) {
|
|
|
631
582
|
}
|
|
632
583
|
function initialize() {
|
|
633
584
|
return _async_to_generator(function() {
|
|
634
|
-
var _config_ortbRequest;
|
|
635
585
|
return _ts_generator(this, function(_state) {
|
|
636
586
|
if (initialized) return [
|
|
637
587
|
2
|
|
638
588
|
];
|
|
639
|
-
serverUrl = resolveServerUrl();
|
|
640
|
-
if (!((_config_ortbRequest = config.ortbRequest) === null || _config_ortbRequest === void 0 ? void 0 : _config_ortbRequest.imp) || config.ortbRequest.imp.length === 0) {
|
|
641
|
-
throw new Error("No impressions (imp) defined in the OpenRTB request.");
|
|
642
|
-
}
|
|
643
589
|
initialized = true;
|
|
644
|
-
log("Initialized
|
|
645
|
-
log("Bidders:", config.ortbRequest.imp.map(function(imp) {
|
|
646
|
-
var _imp_ext_prebid, _imp_ext;
|
|
647
|
-
var bidders = (_imp_ext = imp.ext) === null || _imp_ext === void 0 ? void 0 : (_imp_ext_prebid = _imp_ext.prebid) === null || _imp_ext_prebid === void 0 ? void 0 : _imp_ext_prebid.bidder;
|
|
648
|
-
return bidders ? Object.keys(bidders).join(", ") : "none";
|
|
649
|
-
}).join("; "));
|
|
590
|
+
log("Initialized, auction URL:", AUCTION_URL);
|
|
650
591
|
return [
|
|
651
592
|
2
|
|
652
593
|
];
|
|
@@ -655,17 +596,15 @@ function createPrebidManager(config) {
|
|
|
655
596
|
}
|
|
656
597
|
function requestBids() {
|
|
657
598
|
return _async_to_generator(function() {
|
|
658
|
-
var
|
|
599
|
+
var timeout, controller, timeoutId, _data_ext, _data_ext1, fetchOptions, response, body, data, bids, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, b, error;
|
|
659
600
|
return _ts_generator(this, function(_state) {
|
|
660
601
|
switch(_state.label){
|
|
661
602
|
case 0:
|
|
662
603
|
if (!initialized) {
|
|
663
604
|
throw new Error("Prebid not initialized. Call initialize() first.");
|
|
664
605
|
}
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
timeout = (_ref = (_config_timeout = config.timeout) !== null && _config_timeout !== void 0 ? _config_timeout : config.ortbRequest.tmax) !== null && _ref !== void 0 ? _ref : DEFAULT_TIMEOUT_MS;
|
|
668
|
-
log("Sending auction request to:", auctionUrl);
|
|
606
|
+
timeout = DEFAULT_TIMEOUT_MS;
|
|
607
|
+
log("Fetching auction response from:", AUCTION_URL);
|
|
669
608
|
controller = typeof AbortController !== "undefined" ? new AbortController() : null;
|
|
670
609
|
timeoutId = setTimeout(function() {
|
|
671
610
|
controller === null || controller === void 0 ? void 0 : controller.abort();
|
|
@@ -679,18 +618,14 @@ function createPrebidManager(config) {
|
|
|
679
618
|
7
|
|
680
619
|
]);
|
|
681
620
|
fetchOptions = {
|
|
682
|
-
method: "POST"
|
|
683
|
-
headers: {
|
|
684
|
-
"Content-Type": "application/json"
|
|
685
|
-
},
|
|
686
|
-
body: JSON.stringify(request)
|
|
621
|
+
method: "POST"
|
|
687
622
|
};
|
|
688
623
|
if (controller) {
|
|
689
624
|
fetchOptions.signal = controller.signal;
|
|
690
625
|
}
|
|
691
626
|
return [
|
|
692
627
|
4,
|
|
693
|
-
fetch(
|
|
628
|
+
fetch(AUCTION_URL, fetchOptions)
|
|
694
629
|
];
|
|
695
630
|
case 2:
|
|
696
631
|
response = _state.sent();
|
|
@@ -807,7 +742,6 @@ function createPrebidManager(config) {
|
|
|
807
742
|
}
|
|
808
743
|
function destroy() {
|
|
809
744
|
initialized = false;
|
|
810
|
-
serverUrl = "";
|
|
811
745
|
log("Destroyed");
|
|
812
746
|
}
|
|
813
747
|
return {
|
|
@@ -823,7 +757,7 @@ function createPrebidManager(config) {
|
|
|
823
757
|
// src/sdk/prebidController.ts
|
|
824
758
|
var import_hls = __toESM(require("hls.js"), 1);
|
|
825
759
|
var LOG = "[PrebidController]";
|
|
826
|
-
function createPrebidController(contentVideo,
|
|
760
|
+
function createPrebidController(contentVideo, options) {
|
|
827
761
|
var adPlaying = false;
|
|
828
762
|
var originalMutedState = false;
|
|
829
763
|
var originalVolume = Math.max(0, Math.min(1, contentVideo.volume || 1));
|
|
@@ -837,11 +771,9 @@ function createPrebidController(contentVideo, prebidConfig, options) {
|
|
|
837
771
|
var sessionId;
|
|
838
772
|
var destroyed = false;
|
|
839
773
|
var trackingFired = createEmptyTrackingState();
|
|
840
|
-
var
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
debug: prebidDebug
|
|
844
|
-
}));
|
|
774
|
+
var prebidManager = createPrebidManager((options === null || options === void 0 ? void 0 : options.debug) !== void 0 ? {
|
|
775
|
+
debug: options.debug
|
|
776
|
+
} : {});
|
|
845
777
|
var prebidInitialized = false;
|
|
846
778
|
function emit(event, payload) {
|
|
847
779
|
var set = listeners.get(event);
|
|
@@ -1064,19 +996,12 @@ function createPrebidController(contentVideo, prebidConfig, options) {
|
|
|
1064
996
|
}
|
|
1065
997
|
function ensurePrebidInitialized() {
|
|
1066
998
|
return _async_to_generator(function() {
|
|
1067
|
-
var _prebidConfig_ortbRequest_imp, _prebidConfig_ortbRequest;
|
|
1068
999
|
return _ts_generator(this, function(_state) {
|
|
1069
1000
|
switch(_state.label){
|
|
1070
1001
|
case 0:
|
|
1071
1002
|
if (prebidInitialized) return [
|
|
1072
1003
|
2
|
|
1073
1004
|
];
|
|
1074
|
-
if (prebidConfig.enabled === false) {
|
|
1075
|
-
throw new Error("Prebid is disabled in config");
|
|
1076
|
-
}
|
|
1077
|
-
if (!((_prebidConfig_ortbRequest = prebidConfig.ortbRequest) === null || _prebidConfig_ortbRequest === void 0 ? void 0 : (_prebidConfig_ortbRequest_imp = _prebidConfig_ortbRequest.imp) === null || _prebidConfig_ortbRequest_imp === void 0 ? void 0 : _prebidConfig_ortbRequest_imp.length)) {
|
|
1078
|
-
throw new Error("No impressions configured in ortbRequest");
|
|
1079
|
-
}
|
|
1080
1005
|
return [
|
|
1081
1006
|
4,
|
|
1082
1007
|
prebidManager.initialize()
|
|
@@ -1094,7 +1019,7 @@ function createPrebidController(contentVideo, prebidConfig, options) {
|
|
|
1094
1019
|
}
|
|
1095
1020
|
function runPrebidAuction() {
|
|
1096
1021
|
return _async_to_generator(function() {
|
|
1097
|
-
var bids,
|
|
1022
|
+
var bids, winner;
|
|
1098
1023
|
return _ts_generator(this, function(_state) {
|
|
1099
1024
|
switch(_state.label){
|
|
1100
1025
|
case 0:
|
|
@@ -1117,15 +1042,7 @@ function createPrebidController(contentVideo, prebidConfig, options) {
|
|
|
1117
1042
|
null
|
|
1118
1043
|
];
|
|
1119
1044
|
}
|
|
1120
|
-
cpmFloor = (_prebidConfig_cpmFloor = prebidConfig.cpmFloor) !== null && _prebidConfig_cpmFloor !== void 0 ? _prebidConfig_cpmFloor : 0;
|
|
1121
1045
|
winner = bids[0];
|
|
1122
|
-
if (cpmFloor > 0 && winner.cpm < cpmFloor) {
|
|
1123
|
-
console.log("".concat(LOG, " Winning bid $").concat(winner.cpm.toFixed(2), " below CPM floor $").concat(cpmFloor.toFixed(2), ", rejecting"));
|
|
1124
|
-
return [
|
|
1125
|
-
2,
|
|
1126
|
-
null
|
|
1127
|
-
];
|
|
1128
|
-
}
|
|
1129
1046
|
console.log("".concat(LOG, " Winning bid: ").concat(winner.bidder, " $").concat(winner.cpm.toFixed(2), " ").concat(winner.currency));
|
|
1130
1047
|
if (winner.vastXml) {
|
|
1131
1048
|
console.log("".concat(LOG, " Parsing VAST XML from bid response (inline)"));
|