stormcloud-video-player 0.8.73 → 0.8.75
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/README.md +10 -70
- package/dist/stormcloud-vp.min.js +1 -1
- package/lib/Player.d.cts +2 -1
- package/lib/StormcloudPlayer.cjs +988 -273
- package/lib/StormcloudPlayer.cjs.map +1 -1
- package/lib/StormcloudPlayer.d.cts +1 -0
- package/lib/index.cjs +999 -278
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +1 -0
- package/lib/index.d.ts +40 -3
- package/lib/index.js +992 -279
- package/lib/index.js.map +1 -1
- package/lib/player/AdBreakOrchestrator.cjs +767 -67
- package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
- package/lib/player/AdBreakOrchestrator.d.cts +7 -9
- package/lib/player/AdConfigManager.cjs +315 -62
- package/lib/player/AdConfigManager.cjs.map +1 -1
- package/lib/player/AdConfigManager.d.cts +7 -12
- package/lib/player/AdTimingService.cjs +37 -1
- package/lib/player/AdTimingService.cjs.map +1 -1
- package/lib/player/AdTimingService.d.cts +8 -1
- package/lib/player/EdgePodRequest.d.cts +1 -0
- package/lib/player/FloorLadder.d.cts +1 -0
- package/lib/player/HlsEngine.d.cts +1 -0
- package/lib/player/OptimizedPodRequest.cjs +719 -0
- package/lib/player/OptimizedPodRequest.cjs.map +1 -0
- package/lib/player/OptimizedPodRequest.d.cts +101 -0
- package/lib/player/PlayerControls.d.cts +1 -0
- package/lib/player/Scte35CueManager.d.cts +1 -0
- package/lib/player/Scte35Parser.d.cts +1 -0
- package/lib/player/StormcloudVideoPlayer.cjs +988 -273
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +1 -0
- package/lib/player/playerTypes.d.cts +1 -0
- package/lib/players/HlsPlayer.cjs +988 -273
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.d.cts +1 -0
- package/lib/players/index.cjs +988 -273
- package/lib/players/index.cjs.map +1 -1
- package/lib/props.d.cts +1 -0
- package/lib/sdk/hlsAdPlayer.cjs +316 -51
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.d.cts +3 -1
- package/lib/sdk/pal.cjs +108 -83
- package/lib/sdk/pal.cjs.map +1 -1
- package/lib/sdk/pal.d.cts +1 -0
- package/lib/types.d.cts +9 -2
- package/lib/ui/StormcloudVideoPlayer.cjs +991 -278
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.d.cts +1 -0
- package/lib/utils/ctvVastSignals.cjs +9 -7
- package/lib/utils/ctvVastSignals.cjs.map +1 -1
- package/lib/utils/tracking.cjs +17 -3
- package/lib/utils/tracking.cjs.map +1 -1
- package/lib/utils/tracking.d.cts +2 -1
- package/lib/utils/vastEnvironmentSignals.cjs +9 -7
- package/lib/utils/vastEnvironmentSignals.cjs.map +1 -1
- package/lib/utils/vastMacros.cjs +251 -10
- package/lib/utils/vastMacros.cjs.map +1 -1
- package/lib/utils/vastMacros.d.cts +13 -4
- package/package.json +5 -3
|
@@ -4,6 +4,7 @@ import { AdTimingService } from './AdTimingService.cjs';
|
|
|
4
4
|
import { AdConfigManager } from './AdConfigManager.cjs';
|
|
5
5
|
import { Scte35CueManager } from './Scte35CueManager.cjs';
|
|
6
6
|
import { PlaceholderLayer } from './PlaceholderLayer.cjs';
|
|
7
|
+
import './OptimizedPodRequest.cjs';
|
|
7
8
|
import '../sdk/pal.cjs';
|
|
8
9
|
import '../utils/vastMacros.cjs';
|
|
9
10
|
import './playerTypes.cjs';
|
|
@@ -21,8 +22,8 @@ interface AdBreakOrchestratorHost {
|
|
|
21
22
|
reloadLiveStream(): void;
|
|
22
23
|
recoverMediaError(): void;
|
|
23
24
|
requiresMediaPipelineResetAfterAds(): boolean;
|
|
24
|
-
generatePodVastUrl(baseUrl: string
|
|
25
|
-
|
|
25
|
+
generatePodVastUrl(baseUrl: string): string;
|
|
26
|
+
completeGamRequestSignals(url: string): Promise<string>;
|
|
26
27
|
getEdgePodBaseUrl(): string | undefined;
|
|
27
28
|
getFloorSnapshot(position: AdPosition): OpportunityFloor | undefined;
|
|
28
29
|
onAdClick(): void;
|
|
@@ -88,12 +89,6 @@ declare class AdBreakOrchestrator {
|
|
|
88
89
|
private isLiveBreak;
|
|
89
90
|
private canRequestEdge;
|
|
90
91
|
private markEdgeExhausted;
|
|
91
|
-
/**
|
|
92
|
-
* Builds the next Edge request from the budget left right now, or marks Edge
|
|
93
|
-
* exhausted for this break. Synchronous on purpose: callers must reach the
|
|
94
|
-
* REQUESTING state in the same tick so a second completion event cannot race
|
|
95
|
-
* in a parallel request.
|
|
96
|
-
*/
|
|
97
92
|
private prepareEdgePodRequest;
|
|
98
93
|
private runEdgePod;
|
|
99
94
|
private continueAfterEdgeOutcome;
|
|
@@ -112,7 +107,10 @@ declare class AdBreakOrchestrator {
|
|
|
112
107
|
private recordRequestFailure;
|
|
113
108
|
private recordRequestDiagnostic;
|
|
114
109
|
private finalizeRequestDiagnostics;
|
|
115
|
-
private
|
|
110
|
+
private createGamDispatchFinalizer;
|
|
111
|
+
private logPodDispatch;
|
|
112
|
+
private recordPodResponseDiagnostics;
|
|
113
|
+
private handlePodRequestNotSent;
|
|
116
114
|
private opportunityFloorFields;
|
|
117
115
|
private requestFloorFields;
|
|
118
116
|
private applyOpportunityFloor;
|
|
@@ -328,21 +328,20 @@ var ANDROID_ID_TYPES = /* @__PURE__ */ new Set([
|
|
|
328
328
|
"adid"
|
|
329
329
|
]);
|
|
330
330
|
function resolveVastEnvironmentSignals(isCtv) {
|
|
331
|
-
var _ref;
|
|
332
331
|
var bridgeSignals = readNativeBridgeSignals();
|
|
333
332
|
var platformDevice = readPlatformNativeDeviceId();
|
|
334
|
-
var
|
|
333
|
+
var bridgeDeviceId = validDeviceId(bridgeSignals.deviceId);
|
|
334
|
+
var realDeviceId = bridgeDeviceId || (isCtv ? validDeviceId(readStoredDeviceId()) : void 0) || validDeviceId(platformDevice.deviceId);
|
|
335
335
|
var deviceId = realDeviceId;
|
|
336
|
-
var deviceIdType = bridgeSignals.deviceIdType || readStoredString("deviceIdType") || readStoredString("idtype") || platformDevice.deviceIdType || inferDeviceIdType();
|
|
337
|
-
var platformLat =
|
|
338
|
-
var limitAdTracking = deviceId != null ?
|
|
336
|
+
var deviceIdType = (bridgeDeviceId ? bridgeSignals.deviceIdType : void 0) || readStoredString("deviceIdType") || readStoredString("idtype") || platformDevice.deviceIdType || inferDeviceIdType();
|
|
337
|
+
var platformLat = bridgeDeviceId ? bridgeSignals.limitAdTracking : platformDevice.limitAdTracking;
|
|
338
|
+
var limitAdTracking = deviceId != null ? platformLat !== null && platformLat !== void 0 ? platformLat : readStoredLimitAdTracking() : void 0;
|
|
339
339
|
if (!deviceId && isCtv) {
|
|
340
340
|
var dpid = getOrCreateStoredUuid(PLAYER_ID_STORAGE_KEY);
|
|
341
341
|
if (dpid) {
|
|
342
|
-
var _ref1;
|
|
343
342
|
deviceId = dpid;
|
|
344
343
|
deviceIdType = "dpid";
|
|
345
|
-
limitAdTracking =
|
|
344
|
+
limitAdTracking = platformLat !== null && platformLat !== void 0 ? platformLat : readStoredLimitAdTracking();
|
|
346
345
|
}
|
|
347
346
|
}
|
|
348
347
|
var deviceTypeHint = resolveDeviceTypeHint(isCtv);
|
|
@@ -707,6 +706,9 @@ function isMacroPlaceholder(value) {
|
|
|
707
706
|
var t = value.trim();
|
|
708
707
|
return !t || /^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%)$/.test(t) || /^(unknown|null|undefined|none|n\/a|\$\{[^}]+\})$/i.test(t) || ZEROED_AD_ID_PATTERNS.has(t.toLowerCase());
|
|
709
708
|
}
|
|
709
|
+
function validDeviceId(value) {
|
|
710
|
+
return value && !isMacroPlaceholder(value) ? value : void 0;
|
|
711
|
+
}
|
|
710
712
|
function isZeroedAdId(value) {
|
|
711
713
|
return ZEROED_AD_ID_PATTERNS.has(value.trim().toLowerCase());
|
|
712
714
|
}
|
|
@@ -1239,6 +1241,192 @@ function ensureVideoAdType(rawUrl) {
|
|
|
1239
1241
|
return rawUrl;
|
|
1240
1242
|
}
|
|
1241
1243
|
}
|
|
1244
|
+
var SCVP_MACRO_DETECT = /\[SCVP-|%5BSCVP-|\(SCVP-|%28SCVP-/i;
|
|
1245
|
+
var SCVP_MACRO_PATTERN = /\[SCVP-([A-Z0-9-]+)\]|\(SCVP-([A-Z0-9-]+)\)/gi;
|
|
1246
|
+
var SCVP_WHOLE_VALUE_PATTERN = /^\s*(?:\[SCVP-([A-Z0-9-]+)\]|\(SCVP-([A-Z0-9-]+)\))\s*$/i;
|
|
1247
|
+
var NESTED_QUERY_PARAM_KEYS = /* @__PURE__ */ new Set([
|
|
1248
|
+
"cust_params"
|
|
1249
|
+
]);
|
|
1250
|
+
var SCVP_POD_MACROS = /* @__PURE__ */ new Set([
|
|
1251
|
+
"PMND",
|
|
1252
|
+
"PMXD",
|
|
1253
|
+
"PMAD"
|
|
1254
|
+
]);
|
|
1255
|
+
function hasScvpMacros(url) {
|
|
1256
|
+
return !!url && SCVP_MACRO_DETECT.test(url);
|
|
1257
|
+
}
|
|
1258
|
+
function safeDecode(value) {
|
|
1259
|
+
try {
|
|
1260
|
+
return decodeURIComponent(value.replace(/\+/g, " "));
|
|
1261
|
+
} catch (unused) {
|
|
1262
|
+
return value;
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
function findScvpMacroNames(url) {
|
|
1266
|
+
if (!url) return [];
|
|
1267
|
+
var names = /* @__PURE__ */ new Set();
|
|
1268
|
+
var text = url;
|
|
1269
|
+
for(var pass = 0; pass < 3; pass++){
|
|
1270
|
+
text.replace(SCVP_MACRO_PATTERN, function(_m, bracketName, parenName) {
|
|
1271
|
+
names.add(String(bracketName || parenName).toUpperCase());
|
|
1272
|
+
return "";
|
|
1273
|
+
});
|
|
1274
|
+
var decoded = safeDecode(text);
|
|
1275
|
+
if (decoded === text) break;
|
|
1276
|
+
text = decoded;
|
|
1277
|
+
}
|
|
1278
|
+
return Array.from(names);
|
|
1279
|
+
}
|
|
1280
|
+
function resolveScvpMacroValues(ctx) {
|
|
1281
|
+
var _ctx_deviceId, _ctx_deviceIdType, _ctx_consent, _ctx_consent1, _ctx_consent2;
|
|
1282
|
+
var values = /* @__PURE__ */ new Map();
|
|
1283
|
+
var set = function set(name, value) {
|
|
1284
|
+
if (value == null) return;
|
|
1285
|
+
var str = String(value).trim();
|
|
1286
|
+
if (str) values.set(name, str);
|
|
1287
|
+
};
|
|
1288
|
+
var toFlag = function toFlag(value) {
|
|
1289
|
+
return value == null ? void 0 : value ? "1" : "0";
|
|
1290
|
+
};
|
|
1291
|
+
var deviceId = (_ctx_deviceId = ctx.deviceId) === null || _ctx_deviceId === void 0 ? void 0 : _ctx_deviceId.trim();
|
|
1292
|
+
var deviceIdType = deviceId ? ((_ctx_deviceIdType = ctx.deviceIdType) === null || _ctx_deviceIdType === void 0 ? void 0 : _ctx_deviceIdType.trim()) || inferDeviceIdType() : void 0;
|
|
1293
|
+
if (deviceId && deviceIdType) {
|
|
1294
|
+
var _toFlag;
|
|
1295
|
+
set("RDID", deviceId);
|
|
1296
|
+
set("IDTYPE", deviceIdType);
|
|
1297
|
+
set("IS-LAT", (_toFlag = toFlag(ctx.limitAdTracking)) !== null && _toFlag !== void 0 ? _toFlag : "0");
|
|
1298
|
+
}
|
|
1299
|
+
set("SID", ctx.sessionId);
|
|
1300
|
+
set("DTH", ctx.deviceTypeHint);
|
|
1301
|
+
set("GIVN", ctx.palNonce);
|
|
1302
|
+
set("CT-TI", ctx.programTitle);
|
|
1303
|
+
set("CT-CH", ctx.channelName);
|
|
1304
|
+
set("POD", ctx.pod);
|
|
1305
|
+
set("CORRELATOR", ctx.correlator);
|
|
1306
|
+
set("SCOR", ctx.streamCorrelator);
|
|
1307
|
+
set("VPMUTE", toFlag(ctx.adWillPlayMuted));
|
|
1308
|
+
if (ctx.adWillAutoPlay != null) {
|
|
1309
|
+
set("VPA", ctx.adWillAutoPlay ? "auto" : "click");
|
|
1310
|
+
}
|
|
1311
|
+
set("GDPR", (_ctx_consent = ctx.consent) === null || _ctx_consent === void 0 ? void 0 : _ctx_consent.gdpr);
|
|
1312
|
+
set("GDPR-CONSENT", (_ctx_consent1 = ctx.consent) === null || _ctx_consent1 === void 0 ? void 0 : _ctx_consent1.gdprConsent);
|
|
1313
|
+
set("US-PRIVACY", (_ctx_consent2 = ctx.consent) === null || _ctx_consent2 === void 0 ? void 0 : _ctx_consent2.usPrivacy);
|
|
1314
|
+
return values;
|
|
1315
|
+
}
|
|
1316
|
+
var keepNone = function keepNone() {
|
|
1317
|
+
return false;
|
|
1318
|
+
};
|
|
1319
|
+
function substituteScvpParams(params, values, unresolved, keep, nested) {
|
|
1320
|
+
var out = [];
|
|
1321
|
+
var replaceMacro = function replaceMacro(match, bracketName, parenName) {
|
|
1322
|
+
var name = String(bracketName || parenName).toUpperCase();
|
|
1323
|
+
var value = values.get(name);
|
|
1324
|
+
if (value != null) return value;
|
|
1325
|
+
if (keep(name)) return match;
|
|
1326
|
+
unresolved.add(name);
|
|
1327
|
+
return "";
|
|
1328
|
+
};
|
|
1329
|
+
params.forEach(function(value, key) {
|
|
1330
|
+
var whole = value.match(SCVP_WHOLE_VALUE_PATTERN);
|
|
1331
|
+
if (whole) {
|
|
1332
|
+
var name = String(whole[1] || whole[2]).toUpperCase();
|
|
1333
|
+
var resolved = values.get(name);
|
|
1334
|
+
if (resolved != null) {
|
|
1335
|
+
out.push([
|
|
1336
|
+
key,
|
|
1337
|
+
resolved
|
|
1338
|
+
]);
|
|
1339
|
+
} else if (keep(name)) {
|
|
1340
|
+
out.push([
|
|
1341
|
+
key,
|
|
1342
|
+
value
|
|
1343
|
+
]);
|
|
1344
|
+
} else {
|
|
1345
|
+
unresolved.add(name);
|
|
1346
|
+
}
|
|
1347
|
+
return;
|
|
1348
|
+
}
|
|
1349
|
+
if (!SCVP_MACRO_DETECT.test(value)) {
|
|
1350
|
+
out.push([
|
|
1351
|
+
key,
|
|
1352
|
+
value
|
|
1353
|
+
]);
|
|
1354
|
+
return;
|
|
1355
|
+
}
|
|
1356
|
+
if (!nested && NESTED_QUERY_PARAM_KEYS.has(key)) {
|
|
1357
|
+
var inner = substituteScvpParams(new URLSearchParams(value), values, unresolved, keep, true);
|
|
1358
|
+
if (inner.length > 0) {
|
|
1359
|
+
out.push([
|
|
1360
|
+
key,
|
|
1361
|
+
inner.map(function(param) {
|
|
1362
|
+
var _param = _sliced_to_array(param, 2), k = _param[0], v = _param[1];
|
|
1363
|
+
return "".concat(encodeURIComponent(k), "=").concat(encodeURIComponent(v));
|
|
1364
|
+
}).join("&")
|
|
1365
|
+
]);
|
|
1366
|
+
}
|
|
1367
|
+
return;
|
|
1368
|
+
}
|
|
1369
|
+
out.push([
|
|
1370
|
+
key,
|
|
1371
|
+
value.replace(SCVP_MACRO_PATTERN, replaceMacro)
|
|
1372
|
+
]);
|
|
1373
|
+
});
|
|
1374
|
+
return out;
|
|
1375
|
+
}
|
|
1376
|
+
function substituteScvpMacros(baseUrl, values) {
|
|
1377
|
+
var keep = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : keepNone;
|
|
1378
|
+
var unresolved = /* @__PURE__ */ new Set();
|
|
1379
|
+
var url;
|
|
1380
|
+
try {
|
|
1381
|
+
url = new URL(normalizeVastTagUrl(baseUrl));
|
|
1382
|
+
} catch (unused) {
|
|
1383
|
+
var replaced = baseUrl.replace(SCVP_MACRO_PATTERN, function(match, bracketName, parenName) {
|
|
1384
|
+
var name = String(bracketName || parenName).toUpperCase();
|
|
1385
|
+
var value = values.get(name);
|
|
1386
|
+
if (value != null) return encodeURIComponent(value);
|
|
1387
|
+
if (keep(name)) return match;
|
|
1388
|
+
unresolved.add(name);
|
|
1389
|
+
return "";
|
|
1390
|
+
});
|
|
1391
|
+
return {
|
|
1392
|
+
url: replaced,
|
|
1393
|
+
unresolved: Array.from(unresolved)
|
|
1394
|
+
};
|
|
1395
|
+
}
|
|
1396
|
+
var entries = substituteScvpParams(url.searchParams, values, unresolved, keep, false);
|
|
1397
|
+
var search = new URLSearchParams();
|
|
1398
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1399
|
+
try {
|
|
1400
|
+
for(var _iterator = entries[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1401
|
+
var _step_value = _sliced_to_array(_step.value, 2), key = _step_value[0], value = _step_value[1];
|
|
1402
|
+
search.append(key, value);
|
|
1403
|
+
}
|
|
1404
|
+
} catch (err) {
|
|
1405
|
+
_didIteratorError = true;
|
|
1406
|
+
_iteratorError = err;
|
|
1407
|
+
} finally{
|
|
1408
|
+
try {
|
|
1409
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1410
|
+
_iterator.return();
|
|
1411
|
+
}
|
|
1412
|
+
} finally{
|
|
1413
|
+
if (_didIteratorError) {
|
|
1414
|
+
throw _iteratorError;
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
url.search = search.toString();
|
|
1419
|
+
return {
|
|
1420
|
+
url: url.toString(),
|
|
1421
|
+
unresolved: Array.from(unresolved)
|
|
1422
|
+
};
|
|
1423
|
+
}
|
|
1424
|
+
function applyScvpMacros(baseUrl, ctx) {
|
|
1425
|
+
var deferred = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : /* @__PURE__ */ new Set();
|
|
1426
|
+
return substituteScvpMacros(baseUrl, resolveScvpMacroValues(ctx), function(name) {
|
|
1427
|
+
return deferred.has(name);
|
|
1428
|
+
});
|
|
1429
|
+
}
|
|
1242
1430
|
function applyVastMacros(baseUrl, ctx) {
|
|
1243
1431
|
var expandedUrl = expandInlineMacroPlaceholders(baseUrl, ctx);
|
|
1244
1432
|
var url;
|
|
@@ -1280,15 +1468,6 @@ function applyVastMacros(baseUrl, ctx) {
|
|
|
1280
1468
|
}
|
|
1281
1469
|
params.delete("ppos");
|
|
1282
1470
|
params.delete("lip");
|
|
1283
|
-
if (ctx.podMinDurationMs != null) {
|
|
1284
|
-
params.set("pmnd", String(Math.max(0, Math.round(ctx.podMinDurationMs))));
|
|
1285
|
-
}
|
|
1286
|
-
if (ctx.podMaxDurationMs != null) {
|
|
1287
|
-
params.set("pmxd", String(Math.max(0, Math.round(ctx.podMaxDurationMs))));
|
|
1288
|
-
}
|
|
1289
|
-
if (ctx.podMaxAds != null) {
|
|
1290
|
-
params.set("pmad", String(Math.max(1, Math.round(ctx.podMaxAds))));
|
|
1291
|
-
}
|
|
1292
1471
|
var existingUrl = params.get("url") || "";
|
|
1293
1472
|
if (EXAMPLE_COM_URL.test(existingUrl)) {
|
|
1294
1473
|
params.delete("url");
|
|
@@ -1380,6 +1559,25 @@ function replaceCorrelatorFallback(baseUrl, correlator) {
|
|
|
1380
1559
|
var sep = baseUrl.includes("?") ? "&" : "?";
|
|
1381
1560
|
return "".concat(baseUrl).concat(sep, "correlator=").concat(correlator);
|
|
1382
1561
|
}
|
|
1562
|
+
// src/player/OptimizedPodRequest.ts
|
|
1563
|
+
var DEFAULT_REQUEST_SAFETY_MS = 1500;
|
|
1564
|
+
function nonNegativeInt(value) {
|
|
1565
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.floor(value) : void 0;
|
|
1566
|
+
}
|
|
1567
|
+
function positiveInt(value) {
|
|
1568
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 1 ? Math.floor(value) : void 0;
|
|
1569
|
+
}
|
|
1570
|
+
function resolveAdPodConfig(config) {
|
|
1571
|
+
var _config_adPodConfig, _nonNegativeInt, _nonNegativeInt1, _positiveInt;
|
|
1572
|
+
var pod = (_config_adPodConfig = config.adPodConfig) !== null && _config_adPodConfig !== void 0 ? _config_adPodConfig : {};
|
|
1573
|
+
return {
|
|
1574
|
+
requestSafetyMs: (_nonNegativeInt = nonNegativeInt(pod.requestSafetyMs)) !== null && _nonNegativeInt !== void 0 ? _nonNegativeInt : DEFAULT_REQUEST_SAFETY_MS,
|
|
1575
|
+
minPodDurationMs: (_nonNegativeInt1 = nonNegativeInt(pod.minPodDurationMs)) !== null && _nonNegativeInt1 !== void 0 ? _nonNegativeInt1 : 0,
|
|
1576
|
+
maxAdsPerBreak: pod.maxAdsPerBreak === void 0 ? positiveInt(config.podMaxAds) : positiveInt(pod.maxAdsPerBreak),
|
|
1577
|
+
maxPodDurationMs: (_positiveInt = positiveInt(pod.maxPodDurationMs)) !== null && _positiveInt !== void 0 ? _positiveInt : positiveInt(config.podMaxDurationMs),
|
|
1578
|
+
exactDuration: config.podExactDuration === true
|
|
1579
|
+
};
|
|
1580
|
+
}
|
|
1383
1581
|
// src/utils/devUrl.ts
|
|
1384
1582
|
var PRIVATE_HOST_PATTERNS = [
|
|
1385
1583
|
/^localhost$/i,
|
|
@@ -1496,7 +1694,14 @@ function ingestPlayerTracking(licenseKey, channel, body) {
|
|
|
1496
1694
|
// src/utils/tracking.ts
|
|
1497
1695
|
var cachedBrowserId = null;
|
|
1498
1696
|
function buildAnalyticsContext(config) {
|
|
1697
|
+
var _config_contentNetwork, _config_channelName, _config_programTitle;
|
|
1499
1698
|
var context = {};
|
|
1699
|
+
var contentNetwork = (_config_contentNetwork = config.contentNetwork) === null || _config_contentNetwork === void 0 ? void 0 : _config_contentNetwork.trim();
|
|
1700
|
+
var contentChannel = (_config_channelName = config.channelName) === null || _config_channelName === void 0 ? void 0 : _config_channelName.trim();
|
|
1701
|
+
var contentTitle = (_config_programTitle = config.programTitle) === null || _config_programTitle === void 0 ? void 0 : _config_programTitle.trim();
|
|
1702
|
+
if (contentNetwork) context.contentNetwork = contentNetwork;
|
|
1703
|
+
if (contentChannel) context.contentChannel = contentChannel;
|
|
1704
|
+
if (contentTitle) context.contentTitle = contentTitle;
|
|
1500
1705
|
if (config.debugAdTiming) {
|
|
1501
1706
|
context.debugAdTiming = true;
|
|
1502
1707
|
}
|
|
@@ -1913,6 +2118,21 @@ function sendHeartbeat(_0) {
|
|
|
1913
2118
|
}).apply(this, arguments);
|
|
1914
2119
|
}
|
|
1915
2120
|
// src/player/AdConfigManager.ts
|
|
2121
|
+
function withDeferredPodParams(rawUrl, deferNonce) {
|
|
2122
|
+
try {
|
|
2123
|
+
var url = new URL(rawUrl);
|
|
2124
|
+
url.searchParams.set("pmnd", "[SCVP-PMND]");
|
|
2125
|
+
url.searchParams.set("pmxd", "[SCVP-PMXD]");
|
|
2126
|
+
url.searchParams.set("pmad", "[SCVP-PMAD]");
|
|
2127
|
+
if (deferNonce && !url.searchParams.get("givn")) {
|
|
2128
|
+
url.searchParams.delete("paln");
|
|
2129
|
+
url.searchParams.set("givn", "[SCVP-GIVN]");
|
|
2130
|
+
}
|
|
2131
|
+
return url.toString();
|
|
2132
|
+
} catch (unused) {
|
|
2133
|
+
return rawUrl;
|
|
2134
|
+
}
|
|
2135
|
+
}
|
|
1916
2136
|
var AdConfigManager = /*#__PURE__*/ function() {
|
|
1917
2137
|
function AdConfigManager(config, video) {
|
|
1918
2138
|
_class_call_check(this, AdConfigManager);
|
|
@@ -1923,8 +2143,8 @@ var AdConfigManager = /*#__PURE__*/ function() {
|
|
|
1923
2143
|
this.podCounter = 0;
|
|
1924
2144
|
this.podAssignedByPrefetch = false;
|
|
1925
2145
|
this.lastHeartbeatTime = 0;
|
|
1926
|
-
this.
|
|
1927
|
-
this.
|
|
2146
|
+
this.defaultEdgePodMaxAds = 6;
|
|
2147
|
+
this.palNonceDispatchWaitMs = 1500;
|
|
1928
2148
|
this.config = config;
|
|
1929
2149
|
this.video = video;
|
|
1930
2150
|
}
|
|
@@ -1952,7 +2172,7 @@ var AdConfigManager = /*#__PURE__*/ function() {
|
|
|
1952
2172
|
key: "fetchAdConfiguration",
|
|
1953
2173
|
value: function fetchAdConfiguration() {
|
|
1954
2174
|
return _async_to_generator(function() {
|
|
1955
|
-
var _data_response_ima_publisherdeskima, _data_response_ima, _data_response, _data_response_options_vast_cue_tones, _data_response_options_vast, _data_response_options, _data_response1,
|
|
2175
|
+
var _data_response_ima_publisherdeskima, _data_response_ima, _data_response, _data_response_options_vast_cue_tones, _data_response_options_vast, _data_response_options, _data_response1, apiUrl, headers, response, data, imaPayload, decodedPayload, numberAds;
|
|
1956
2176
|
return _ts_generator(this, function(_state) {
|
|
1957
2177
|
switch(_state.label){
|
|
1958
2178
|
case 0:
|
|
@@ -1973,28 +2193,6 @@ var AdConfigManager = /*#__PURE__*/ function() {
|
|
|
1973
2193
|
2
|
|
1974
2194
|
];
|
|
1975
2195
|
case 2:
|
|
1976
|
-
vastMode = this.config.vastMode || "default";
|
|
1977
|
-
if (this.debug) {
|
|
1978
|
-
console.log("[StormcloudVideoPlayer] VAST mode:", vastMode);
|
|
1979
|
-
}
|
|
1980
|
-
if (vastMode === "adstorm") {
|
|
1981
|
-
if (!this.config.licenseKey) {
|
|
1982
|
-
if (this.debug) {
|
|
1983
|
-
console.warn("[StormcloudVideoPlayer] AdStorm mode requires a license key");
|
|
1984
|
-
}
|
|
1985
|
-
return [
|
|
1986
|
-
2
|
|
1987
|
-
];
|
|
1988
|
-
}
|
|
1989
|
-
vastEndpoint = "https://adstorm.co/api-adstorm-dev/adstorm/vast/".concat(this.config.licenseKey);
|
|
1990
|
-
this.apiVastTagUrl = vastEndpoint;
|
|
1991
|
-
if (this.debug) {
|
|
1992
|
-
console.log("[StormcloudVideoPlayer] Using AdStorm VAST endpoint (adstorm mode):", vastEndpoint);
|
|
1993
|
-
}
|
|
1994
|
-
return [
|
|
1995
|
-
2
|
|
1996
|
-
];
|
|
1997
|
-
}
|
|
1998
2196
|
if (this.config.vastTagUrl) {
|
|
1999
2197
|
this.apiVastTagUrl = normalizeVastTagUrl(this.config.vastTagUrl);
|
|
2000
2198
|
if (this.debug) {
|
|
@@ -2004,7 +2202,7 @@ var AdConfigManager = /*#__PURE__*/ function() {
|
|
|
2004
2202
|
2
|
|
2005
2203
|
];
|
|
2006
2204
|
}
|
|
2007
|
-
apiUrl = "https://
|
|
2205
|
+
apiUrl = "https://edge.stormcloudhub.com/api/v1/adstorm/ads/web";
|
|
2008
2206
|
if (this.debug) {
|
|
2009
2207
|
console.log("[StormcloudVideoPlayer] Fetching ad configuration from:", apiUrl);
|
|
2010
2208
|
}
|
|
@@ -2351,16 +2549,16 @@ var AdConfigManager = /*#__PURE__*/ function() {
|
|
|
2351
2549
|
}
|
|
2352
2550
|
},
|
|
2353
2551
|
{
|
|
2354
|
-
key: "
|
|
2355
|
-
value: function
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2552
|
+
key: "resolveAdPodConfig",
|
|
2553
|
+
value: function resolveAdPodConfig1() {
|
|
2554
|
+
return resolveAdPodConfig(this.config);
|
|
2555
|
+
}
|
|
2556
|
+
},
|
|
2557
|
+
{
|
|
2558
|
+
key: "resolveEdgeMaxAds",
|
|
2559
|
+
value: function resolveEdgeMaxAds() {
|
|
2560
|
+
var _this_resolveAdPodConfig_maxAdsPerBreak;
|
|
2561
|
+
return (_this_resolveAdPodConfig_maxAdsPerBreak = this.resolveAdPodConfig().maxAdsPerBreak) !== null && _this_resolveAdPodConfig_maxAdsPerBreak !== void 0 ? _this_resolveAdPodConfig_maxAdsPerBreak : this.apiNumberAds && this.apiNumberAds > 0 ? this.apiNumberAds : this.defaultEdgePodMaxAds;
|
|
2364
2562
|
}
|
|
2365
2563
|
},
|
|
2366
2564
|
{
|
|
@@ -2377,17 +2575,13 @@ var AdConfigManager = /*#__PURE__*/ function() {
|
|
|
2377
2575
|
},
|
|
2378
2576
|
{
|
|
2379
2577
|
key: "generatePodVastUrl",
|
|
2380
|
-
value: function generatePodVastUrl(baseUrl,
|
|
2381
|
-
var _podParams_maxDurationMs;
|
|
2578
|
+
value: function generatePodVastUrl(baseUrl, adPlayer, palNonce, inAdBreak) {
|
|
2382
2579
|
var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
|
|
2383
2580
|
var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest);
|
|
2384
|
-
var
|
|
2581
|
+
var macroContext = _object_spread_props(_object_spread({
|
|
2385
2582
|
correlator: this.viewCorrelator,
|
|
2386
2583
|
streamCorrelator: this.streamCorrelator,
|
|
2387
2584
|
pod: this.podCounter > 0 ? this.podCounter : void 0,
|
|
2388
|
-
podMaxAds: podParams.maxAds,
|
|
2389
|
-
podMinDurationMs: podParams.minDurationMs,
|
|
2390
|
-
podMaxDurationMs: podParams.maxDurationMs,
|
|
2391
2585
|
isCtv: envSignals.isCtv,
|
|
2392
2586
|
pageUrl: !envSignals.isCtv && typeof window !== "undefined" ? toDevSafeUrl(window.location.href) : void 0,
|
|
2393
2587
|
adWillPlayMuted: adWillPlayMuted,
|
|
@@ -2403,13 +2597,72 @@ var AdConfigManager = /*#__PURE__*/ function() {
|
|
|
2403
2597
|
} : {}, this.config.channelName ? {
|
|
2404
2598
|
channelName: this.config.channelName
|
|
2405
2599
|
} : {}), {
|
|
2406
|
-
consent: this.consentSignals
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2600
|
+
consent: this.consentSignals,
|
|
2601
|
+
palNonce: palNonce.getCurrentNonce() || void 0
|
|
2602
|
+
});
|
|
2603
|
+
var nonceReady = !!macroContext.palNonce;
|
|
2604
|
+
var finalUrl;
|
|
2605
|
+
if (hasScvpMacros(baseUrl)) {
|
|
2606
|
+
var deferred = new Set(SCVP_POD_MACROS);
|
|
2607
|
+
if (!nonceReady) deferred.add("GIVN");
|
|
2608
|
+
var _applyScvpMacros = applyScvpMacros(baseUrl, macroContext, deferred), url = _applyScvpMacros.url, unresolved = _applyScvpMacros.unresolved;
|
|
2609
|
+
if (unresolved.length > 0) {
|
|
2610
|
+
console.warn("[StormcloudVideoPlayer] Unresolved SCVP macros (removed from request):", unresolved.join(", "));
|
|
2611
|
+
}
|
|
2612
|
+
finalUrl = ensureVideoAdType(url);
|
|
2613
|
+
} else {
|
|
2614
|
+
finalUrl = withDeferredPodParams(palNonce.injectNonce(ensureVideoAdType(applyVastMacros(baseUrl, macroContext))), !nonceReady);
|
|
2615
|
+
}
|
|
2616
|
+
console.log("[StormcloudVideoPlayer] Prepared optimized-pod request URL (pod=".concat(this.podCounter, "; pmnd/pmxd/pmad resolved at dispatch):"), finalUrl);
|
|
2410
2617
|
return finalUrl;
|
|
2411
2618
|
}
|
|
2412
2619
|
},
|
|
2620
|
+
{
|
|
2621
|
+
key: "completeDeferredRequestSignals",
|
|
2622
|
+
value: function completeDeferredRequestSignals(url, palNonce) {
|
|
2623
|
+
return _async_to_generator(function() {
|
|
2624
|
+
var nonce, _tmp;
|
|
2625
|
+
return _ts_generator(this, function(_state) {
|
|
2626
|
+
switch(_state.label){
|
|
2627
|
+
case 0:
|
|
2628
|
+
if (findScvpMacroNames(url).indexOf("GIVN") === -1) return [
|
|
2629
|
+
2,
|
|
2630
|
+
url
|
|
2631
|
+
];
|
|
2632
|
+
_tmp = palNonce.getCurrentNonce();
|
|
2633
|
+
if (_tmp) return [
|
|
2634
|
+
3,
|
|
2635
|
+
2
|
|
2636
|
+
];
|
|
2637
|
+
return [
|
|
2638
|
+
4,
|
|
2639
|
+
palNonce.waitForNonce(this.palNonceDispatchWaitMs)
|
|
2640
|
+
];
|
|
2641
|
+
case 1:
|
|
2642
|
+
_tmp = _state.sent();
|
|
2643
|
+
_state.label = 2;
|
|
2644
|
+
case 2:
|
|
2645
|
+
nonce = _tmp;
|
|
2646
|
+
if (!nonce) return [
|
|
2647
|
+
2,
|
|
2648
|
+
url
|
|
2649
|
+
];
|
|
2650
|
+
return [
|
|
2651
|
+
2,
|
|
2652
|
+
substituteScvpMacros(url, /* @__PURE__ */ new Map([
|
|
2653
|
+
[
|
|
2654
|
+
"GIVN",
|
|
2655
|
+
nonce
|
|
2656
|
+
]
|
|
2657
|
+
]), function(name) {
|
|
2658
|
+
return name !== "GIVN";
|
|
2659
|
+
}).url
|
|
2660
|
+
];
|
|
2661
|
+
}
|
|
2662
|
+
});
|
|
2663
|
+
}).call(this);
|
|
2664
|
+
}
|
|
2665
|
+
},
|
|
2413
2666
|
{
|
|
2414
2667
|
// --- Tracking ---
|
|
2415
2668
|
key: "initializeTracking",
|