stormcloud-video-player 0.5.2 → 0.5.4
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 +370 -447
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +355 -267
- package/lib/index.d.ts +355 -267
- package/lib/index.js +329 -406
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +96 -178
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/players/FilePlayer.cjs +99 -116
- package/lib/players/FilePlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +148 -230
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.d.cts +1 -1
- package/lib/players/index.cjs +227 -309
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs +17 -9
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.d.cts +1 -1
- package/lib/sdk/ima.cjs +28 -20
- package/lib/sdk/ima.cjs.map +1 -1
- package/lib/sdk/ima.d.cts +1 -1
- package/lib/sdk/prebid.cjs +27 -85
- package/lib/sdk/prebid.cjs.map +1 -1
- package/lib/sdk/prebid.d.cts +6 -3
- package/lib/sdk/prebidController.cjs +35 -108
- package/lib/sdk/prebidController.cjs.map +1 -1
- package/lib/sdk/prebidController.d.cts +3 -2
- package/lib/sdk/vastParser.cjs +19 -11
- 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 +190 -267
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/utils/browserCompat.cjs +11 -11
- package/lib/utils/browserCompat.cjs.map +1 -1
- package/lib/utils/polyfills.cjs +13 -13
- package/lib/utils/polyfills.cjs.map +1 -1
- package/lib/utils/tracking.cjs +19 -11
- 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
|
@@ -66,9 +66,17 @@ function _ts_generator(thisArg, body) {
|
|
|
66
66
|
},
|
|
67
67
|
trys: [],
|
|
68
68
|
ops: []
|
|
69
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
70
|
-
return
|
|
71
|
-
|
|
69
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
70
|
+
return d(g, "next", {
|
|
71
|
+
value: verb(0)
|
|
72
|
+
}), d(g, "throw", {
|
|
73
|
+
value: verb(1)
|
|
74
|
+
}), d(g, "return", {
|
|
75
|
+
value: verb(2)
|
|
76
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
77
|
+
value: function() {
|
|
78
|
+
return this;
|
|
79
|
+
}
|
|
72
80
|
}), g;
|
|
73
81
|
function verb(n) {
|
|
74
82
|
return function(v) {
|
|
@@ -152,20 +160,20 @@ var __defProp = Object.defineProperty;
|
|
|
152
160
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
153
161
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
154
162
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
155
|
-
var __export = function(target, all) {
|
|
163
|
+
var __export = function __export(target, all) {
|
|
156
164
|
for(var name in all)__defProp(target, name, {
|
|
157
165
|
get: all[name],
|
|
158
166
|
enumerable: true
|
|
159
167
|
});
|
|
160
168
|
};
|
|
161
|
-
var __copyProps = function(to, from, except, desc) {
|
|
169
|
+
var __copyProps = function __copyProps(to, from, except, desc) {
|
|
162
170
|
if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
|
|
163
171
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
164
172
|
try {
|
|
165
173
|
var _loop = function() {
|
|
166
174
|
var key = _step.value;
|
|
167
175
|
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
168
|
-
get: function() {
|
|
176
|
+
get: function get() {
|
|
169
177
|
return from[key];
|
|
170
178
|
},
|
|
171
179
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
@@ -189,7 +197,7 @@ var __copyProps = function(to, from, except, desc) {
|
|
|
189
197
|
}
|
|
190
198
|
return to;
|
|
191
199
|
};
|
|
192
|
-
var __toCommonJS = function(mod) {
|
|
200
|
+
var __toCommonJS = function __toCommonJS(mod) {
|
|
193
201
|
return __copyProps(__defProp({}, "__esModule", {
|
|
194
202
|
value: true
|
|
195
203
|
}), mod);
|
|
@@ -197,18 +205,18 @@ var __toCommonJS = function(mod) {
|
|
|
197
205
|
// src/sdk/prebid.ts
|
|
198
206
|
var prebid_exports = {};
|
|
199
207
|
__export(prebid_exports, {
|
|
200
|
-
createPrebidManager: function() {
|
|
208
|
+
createPrebidManager: function createPrebidManager1() {
|
|
201
209
|
return createPrebidManager;
|
|
202
210
|
}
|
|
203
211
|
});
|
|
204
212
|
module.exports = __toCommonJS(prebid_exports);
|
|
205
213
|
var DEFAULT_TIMEOUT_MS = 3e3;
|
|
206
|
-
var
|
|
207
|
-
function createPrebidManager(
|
|
214
|
+
var AUCTION_URL = "https://sspproxy.adstorm.co/openrtb2/auction/adstorm";
|
|
215
|
+
function createPrebidManager() {
|
|
216
|
+
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
217
|
+
var _options_debug;
|
|
208
218
|
var initialized = false;
|
|
209
|
-
var
|
|
210
|
-
var _config_debug;
|
|
211
|
-
var debug = (_config_debug = config.debug) !== null && _config_debug !== void 0 ? _config_debug : false;
|
|
219
|
+
var debug = (_options_debug = options.debug) !== null && _options_debug !== void 0 ? _options_debug : false;
|
|
212
220
|
function log() {
|
|
213
221
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
214
222
|
args[_key] = arguments[_key];
|
|
@@ -229,49 +237,6 @@ function createPrebidManager(config) {
|
|
|
229
237
|
"[Prebid]"
|
|
230
238
|
].concat(_to_consumable_array(args)));
|
|
231
239
|
}
|
|
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
240
|
function parseResponse(data) {
|
|
276
241
|
var bids = [];
|
|
277
242
|
var seatbids = (data === null || data === void 0 ? void 0 : data.seatbid) || [];
|
|
@@ -341,12 +306,6 @@ function createPrebidManager(config) {
|
|
|
341
306
|
function extractVastUrl(bids) {
|
|
342
307
|
if (bids.length === 0) return null;
|
|
343
308
|
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
309
|
if (winner.vastUrl) {
|
|
351
310
|
log("Using cached VAST URL from ".concat(winner.bidder, " ($").concat(winner.cpm.toFixed(2), " ").concat(winner.currency, ")"));
|
|
352
311
|
return winner.vastUrl;
|
|
@@ -368,22 +327,12 @@ function createPrebidManager(config) {
|
|
|
368
327
|
}
|
|
369
328
|
function initialize() {
|
|
370
329
|
return _async_to_generator(function() {
|
|
371
|
-
var _config_ortbRequest;
|
|
372
330
|
return _ts_generator(this, function(_state) {
|
|
373
331
|
if (initialized) return [
|
|
374
332
|
2
|
|
375
333
|
];
|
|
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
334
|
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("; "));
|
|
335
|
+
log("Initialized, auction URL:", AUCTION_URL);
|
|
387
336
|
return [
|
|
388
337
|
2
|
|
389
338
|
];
|
|
@@ -392,17 +341,15 @@ function createPrebidManager(config) {
|
|
|
392
341
|
}
|
|
393
342
|
function requestBids() {
|
|
394
343
|
return _async_to_generator(function() {
|
|
395
|
-
var
|
|
344
|
+
var timeout, controller, timeoutId, _data_ext, _data_ext1, fetchOptions, response, body, data, bids, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, b, error;
|
|
396
345
|
return _ts_generator(this, function(_state) {
|
|
397
346
|
switch(_state.label){
|
|
398
347
|
case 0:
|
|
399
348
|
if (!initialized) {
|
|
400
349
|
throw new Error("Prebid not initialized. Call initialize() first.");
|
|
401
350
|
}
|
|
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);
|
|
351
|
+
timeout = DEFAULT_TIMEOUT_MS;
|
|
352
|
+
log("Fetching auction response from:", AUCTION_URL);
|
|
406
353
|
controller = typeof AbortController !== "undefined" ? new AbortController() : null;
|
|
407
354
|
timeoutId = setTimeout(function() {
|
|
408
355
|
controller === null || controller === void 0 ? void 0 : controller.abort();
|
|
@@ -416,18 +363,14 @@ function createPrebidManager(config) {
|
|
|
416
363
|
7
|
|
417
364
|
]);
|
|
418
365
|
fetchOptions = {
|
|
419
|
-
method: "POST"
|
|
420
|
-
headers: {
|
|
421
|
-
"Content-Type": "application/json"
|
|
422
|
-
},
|
|
423
|
-
body: JSON.stringify(request)
|
|
366
|
+
method: "POST"
|
|
424
367
|
};
|
|
425
368
|
if (controller) {
|
|
426
369
|
fetchOptions.signal = controller.signal;
|
|
427
370
|
}
|
|
428
371
|
return [
|
|
429
372
|
4,
|
|
430
|
-
fetch(
|
|
373
|
+
fetch(AUCTION_URL, fetchOptions)
|
|
431
374
|
];
|
|
432
375
|
case 2:
|
|
433
376
|
response = _state.sent();
|
|
@@ -544,7 +487,6 @@ function createPrebidManager(config) {
|
|
|
544
487
|
}
|
|
545
488
|
function destroy() {
|
|
546
489
|
initialized = false;
|
|
547
|
-
serverUrl = "";
|
|
548
490
|
log("Destroyed");
|
|
549
491
|
}
|
|
550
492
|
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-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 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 };
|
|
@@ -118,9 +118,17 @@ function _ts_generator(thisArg, body) {
|
|
|
118
118
|
},
|
|
119
119
|
trys: [],
|
|
120
120
|
ops: []
|
|
121
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
122
|
-
return
|
|
123
|
-
|
|
121
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
122
|
+
return d(g, "next", {
|
|
123
|
+
value: verb(0)
|
|
124
|
+
}), d(g, "throw", {
|
|
125
|
+
value: verb(1)
|
|
126
|
+
}), d(g, "return", {
|
|
127
|
+
value: verb(2)
|
|
128
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
129
|
+
value: function() {
|
|
130
|
+
return this;
|
|
131
|
+
}
|
|
124
132
|
}), g;
|
|
125
133
|
function verb(n) {
|
|
126
134
|
return function(v) {
|
|
@@ -206,20 +214,20 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
206
214
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
207
215
|
var __getProtoOf = Object.getPrototypeOf;
|
|
208
216
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
209
|
-
var __export = function(target, all) {
|
|
217
|
+
var __export = function __export(target, all) {
|
|
210
218
|
for(var name in all)__defProp(target, name, {
|
|
211
219
|
get: all[name],
|
|
212
220
|
enumerable: true
|
|
213
221
|
});
|
|
214
222
|
};
|
|
215
|
-
var __copyProps = function(to, from, except, desc) {
|
|
223
|
+
var __copyProps = function __copyProps(to, from, except, desc) {
|
|
216
224
|
if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
|
|
217
225
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
218
226
|
try {
|
|
219
227
|
var _loop = function() {
|
|
220
228
|
var key = _step.value;
|
|
221
229
|
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
222
|
-
get: function() {
|
|
230
|
+
get: function get() {
|
|
223
231
|
return from[key];
|
|
224
232
|
},
|
|
225
233
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
@@ -243,7 +251,7 @@ var __copyProps = function(to, from, except, desc) {
|
|
|
243
251
|
}
|
|
244
252
|
return to;
|
|
245
253
|
};
|
|
246
|
-
var __toESM = function(mod, isNodeMode, target) {
|
|
254
|
+
var __toESM = function __toESM(mod, isNodeMode, target) {
|
|
247
255
|
return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
|
|
248
256
|
// file that has been converted to a CommonJS file using a Babel-
|
|
249
257
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
@@ -253,7 +261,7 @@ var __toESM = function(mod, isNodeMode, target) {
|
|
|
253
261
|
enumerable: true
|
|
254
262
|
}) : target, mod);
|
|
255
263
|
};
|
|
256
|
-
var __toCommonJS = function(mod) {
|
|
264
|
+
var __toCommonJS = function __toCommonJS(mod) {
|
|
257
265
|
return __copyProps(__defProp({}, "__esModule", {
|
|
258
266
|
value: true
|
|
259
267
|
}), mod);
|
|
@@ -261,7 +269,7 @@ var __toCommonJS = function(mod) {
|
|
|
261
269
|
// src/sdk/prebidController.ts
|
|
262
270
|
var prebidController_exports = {};
|
|
263
271
|
__export(prebidController_exports, {
|
|
264
|
-
createPrebidController: function() {
|
|
272
|
+
createPrebidController: function createPrebidController1() {
|
|
265
273
|
return createPrebidController;
|
|
266
274
|
}
|
|
267
275
|
});
|
|
@@ -466,12 +474,12 @@ function fireTrackingPixels(urls, sessionId, licenseKey) {
|
|
|
466
474
|
}
|
|
467
475
|
// src/sdk/prebid.ts
|
|
468
476
|
var DEFAULT_TIMEOUT_MS = 3e3;
|
|
469
|
-
var
|
|
470
|
-
function createPrebidManager(
|
|
477
|
+
var AUCTION_URL = "https://sspproxy.adstorm.co/openrtb2/auction/adstorm";
|
|
478
|
+
function createPrebidManager() {
|
|
479
|
+
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
480
|
+
var _options_debug;
|
|
471
481
|
var initialized = false;
|
|
472
|
-
var
|
|
473
|
-
var _config_debug;
|
|
474
|
-
var debug = (_config_debug = config.debug) !== null && _config_debug !== void 0 ? _config_debug : false;
|
|
482
|
+
var debug = (_options_debug = options.debug) !== null && _options_debug !== void 0 ? _options_debug : false;
|
|
475
483
|
function log() {
|
|
476
484
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
477
485
|
args[_key] = arguments[_key];
|
|
@@ -492,49 +500,6 @@ function createPrebidManager(config) {
|
|
|
492
500
|
"[Prebid]"
|
|
493
501
|
].concat(_to_consumable_array(args)));
|
|
494
502
|
}
|
|
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
503
|
function parseResponse(data) {
|
|
539
504
|
var bids = [];
|
|
540
505
|
var seatbids = (data === null || data === void 0 ? void 0 : data.seatbid) || [];
|
|
@@ -604,12 +569,6 @@ function createPrebidManager(config) {
|
|
|
604
569
|
function extractVastUrl(bids) {
|
|
605
570
|
if (bids.length === 0) return null;
|
|
606
571
|
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
572
|
if (winner.vastUrl) {
|
|
614
573
|
log("Using cached VAST URL from ".concat(winner.bidder, " ($").concat(winner.cpm.toFixed(2), " ").concat(winner.currency, ")"));
|
|
615
574
|
return winner.vastUrl;
|
|
@@ -631,22 +590,12 @@ function createPrebidManager(config) {
|
|
|
631
590
|
}
|
|
632
591
|
function initialize() {
|
|
633
592
|
return _async_to_generator(function() {
|
|
634
|
-
var _config_ortbRequest;
|
|
635
593
|
return _ts_generator(this, function(_state) {
|
|
636
594
|
if (initialized) return [
|
|
637
595
|
2
|
|
638
596
|
];
|
|
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
597
|
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("; "));
|
|
598
|
+
log("Initialized, auction URL:", AUCTION_URL);
|
|
650
599
|
return [
|
|
651
600
|
2
|
|
652
601
|
];
|
|
@@ -655,17 +604,15 @@ function createPrebidManager(config) {
|
|
|
655
604
|
}
|
|
656
605
|
function requestBids() {
|
|
657
606
|
return _async_to_generator(function() {
|
|
658
|
-
var
|
|
607
|
+
var timeout, controller, timeoutId, _data_ext, _data_ext1, fetchOptions, response, body, data, bids, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, b, error;
|
|
659
608
|
return _ts_generator(this, function(_state) {
|
|
660
609
|
switch(_state.label){
|
|
661
610
|
case 0:
|
|
662
611
|
if (!initialized) {
|
|
663
612
|
throw new Error("Prebid not initialized. Call initialize() first.");
|
|
664
613
|
}
|
|
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);
|
|
614
|
+
timeout = DEFAULT_TIMEOUT_MS;
|
|
615
|
+
log("Fetching auction response from:", AUCTION_URL);
|
|
669
616
|
controller = typeof AbortController !== "undefined" ? new AbortController() : null;
|
|
670
617
|
timeoutId = setTimeout(function() {
|
|
671
618
|
controller === null || controller === void 0 ? void 0 : controller.abort();
|
|
@@ -679,18 +626,14 @@ function createPrebidManager(config) {
|
|
|
679
626
|
7
|
|
680
627
|
]);
|
|
681
628
|
fetchOptions = {
|
|
682
|
-
method: "POST"
|
|
683
|
-
headers: {
|
|
684
|
-
"Content-Type": "application/json"
|
|
685
|
-
},
|
|
686
|
-
body: JSON.stringify(request)
|
|
629
|
+
method: "POST"
|
|
687
630
|
};
|
|
688
631
|
if (controller) {
|
|
689
632
|
fetchOptions.signal = controller.signal;
|
|
690
633
|
}
|
|
691
634
|
return [
|
|
692
635
|
4,
|
|
693
|
-
fetch(
|
|
636
|
+
fetch(AUCTION_URL, fetchOptions)
|
|
694
637
|
];
|
|
695
638
|
case 2:
|
|
696
639
|
response = _state.sent();
|
|
@@ -807,7 +750,6 @@ function createPrebidManager(config) {
|
|
|
807
750
|
}
|
|
808
751
|
function destroy() {
|
|
809
752
|
initialized = false;
|
|
810
|
-
serverUrl = "";
|
|
811
753
|
log("Destroyed");
|
|
812
754
|
}
|
|
813
755
|
return {
|
|
@@ -823,7 +765,7 @@ function createPrebidManager(config) {
|
|
|
823
765
|
// src/sdk/prebidController.ts
|
|
824
766
|
var import_hls = __toESM(require("hls.js"), 1);
|
|
825
767
|
var LOG = "[PrebidController]";
|
|
826
|
-
function createPrebidController(contentVideo,
|
|
768
|
+
function createPrebidController(contentVideo, options) {
|
|
827
769
|
var adPlaying = false;
|
|
828
770
|
var originalMutedState = false;
|
|
829
771
|
var originalVolume = Math.max(0, Math.min(1, contentVideo.volume || 1));
|
|
@@ -837,11 +779,9 @@ function createPrebidController(contentVideo, prebidConfig, options) {
|
|
|
837
779
|
var sessionId;
|
|
838
780
|
var destroyed = false;
|
|
839
781
|
var trackingFired = createEmptyTrackingState();
|
|
840
|
-
var
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
debug: prebidDebug
|
|
844
|
-
}));
|
|
782
|
+
var prebidManager = createPrebidManager((options === null || options === void 0 ? void 0 : options.debug) !== void 0 ? {
|
|
783
|
+
debug: options.debug
|
|
784
|
+
} : {});
|
|
845
785
|
var prebidInitialized = false;
|
|
846
786
|
function emit(event, payload) {
|
|
847
787
|
var set = listeners.get(event);
|
|
@@ -1040,6 +980,8 @@ function createPrebidController(contentVideo, prebidConfig, options) {
|
|
|
1040
980
|
adContainerEl.style.display = "none";
|
|
1041
981
|
adContainerEl.style.pointerEvents = "none";
|
|
1042
982
|
}
|
|
983
|
+
contentVideo.style.visibility = "visible";
|
|
984
|
+
contentVideo.style.opacity = "1";
|
|
1043
985
|
if (options === null || options === void 0 ? void 0 : options.continueLiveStreamDuringAds) {
|
|
1044
986
|
if (contentVideo.paused) {
|
|
1045
987
|
console.log("".concat(LOG, " Content video paused in live mode, resuming playback"));
|
|
@@ -1064,19 +1006,12 @@ function createPrebidController(contentVideo, prebidConfig, options) {
|
|
|
1064
1006
|
}
|
|
1065
1007
|
function ensurePrebidInitialized() {
|
|
1066
1008
|
return _async_to_generator(function() {
|
|
1067
|
-
var _prebidConfig_ortbRequest_imp, _prebidConfig_ortbRequest;
|
|
1068
1009
|
return _ts_generator(this, function(_state) {
|
|
1069
1010
|
switch(_state.label){
|
|
1070
1011
|
case 0:
|
|
1071
1012
|
if (prebidInitialized) return [
|
|
1072
1013
|
2
|
|
1073
1014
|
];
|
|
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
1015
|
return [
|
|
1081
1016
|
4,
|
|
1082
1017
|
prebidManager.initialize()
|
|
@@ -1094,7 +1029,7 @@ function createPrebidController(contentVideo, prebidConfig, options) {
|
|
|
1094
1029
|
}
|
|
1095
1030
|
function runPrebidAuction() {
|
|
1096
1031
|
return _async_to_generator(function() {
|
|
1097
|
-
var bids,
|
|
1032
|
+
var bids, winner;
|
|
1098
1033
|
return _ts_generator(this, function(_state) {
|
|
1099
1034
|
switch(_state.label){
|
|
1100
1035
|
case 0:
|
|
@@ -1117,15 +1052,7 @@ function createPrebidController(contentVideo, prebidConfig, options) {
|
|
|
1117
1052
|
null
|
|
1118
1053
|
];
|
|
1119
1054
|
}
|
|
1120
|
-
cpmFloor = (_prebidConfig_cpmFloor = prebidConfig.cpmFloor) !== null && _prebidConfig_cpmFloor !== void 0 ? _prebidConfig_cpmFloor : 0;
|
|
1121
1055
|
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
1056
|
console.log("".concat(LOG, " Winning bid: ").concat(winner.bidder, " $").concat(winner.cpm.toFixed(2), " ").concat(winner.currency));
|
|
1130
1057
|
if (winner.vastXml) {
|
|
1131
1058
|
console.log("".concat(LOG, " Parsing VAST XML from bid response (inline)"));
|