stormcloud-video-player 0.8.18 → 0.8.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +67 -83
  2. package/dist/stormcloud-vp.min.js +1 -1
  3. package/lib/index.cjs +635 -346
  4. package/lib/index.cjs.map +1 -1
  5. package/lib/index.d.cts +1 -1
  6. package/lib/index.d.ts +1 -1
  7. package/lib/index.js +635 -346
  8. package/lib/index.js.map +1 -1
  9. package/lib/player/AdBreakOrchestrator.cjs +11 -11
  10. package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
  11. package/lib/player/AdBreakOrchestrator.d.cts +3 -3
  12. package/lib/player/{VmapManager.cjs → AdConfigManager.cjs} +503 -214
  13. package/lib/player/AdConfigManager.cjs.map +1 -0
  14. package/lib/player/{VmapManager.d.cts → AdConfigManager.d.cts} +2 -2
  15. package/lib/player/StormcloudVideoPlayer.cjs +635 -346
  16. package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
  17. package/lib/player/StormcloudVideoPlayer.d.cts +1 -1
  18. package/lib/players/HlsPlayer.cjs +635 -346
  19. package/lib/players/HlsPlayer.cjs.map +1 -1
  20. package/lib/players/index.cjs +635 -346
  21. package/lib/players/index.cjs.map +1 -1
  22. package/lib/ui/StormcloudVideoPlayer.cjs +635 -346
  23. package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
  24. package/lib/utils/ctvVastSignals.cjs +92 -33
  25. package/lib/utils/ctvVastSignals.cjs.map +1 -1
  26. package/lib/utils/ctvVastSignals.d.cts +1 -13
  27. package/lib/utils/vastEnvironmentSignals.cjs +439 -0
  28. package/lib/utils/vastEnvironmentSignals.cjs.map +1 -0
  29. package/lib/utils/vastEnvironmentSignals.d.cts +16 -0
  30. package/lib/utils/vastMacros.cjs +299 -25
  31. package/lib/utils/vastMacros.cjs.map +1 -1
  32. package/lib/utils/vastMacros.d.cts +3 -1
  33. package/package.json +1 -1
  34. package/lib/player/VmapManager.cjs.map +0 -1
package/lib/index.js CHANGED
@@ -2318,22 +2318,326 @@ function initializePolyfills() {
2318
2318
  polyfillTextEncoder();
2319
2319
  polyfillPromiseFinally();
2320
2320
  }
2321
- // src/utils/vastMacros.ts
2322
- function generateCorrelator() {
2323
- if (typeof crypto !== "undefined" && crypto.getRandomValues) {
2321
+ // src/utils/vastEnvironmentSignals.ts
2322
+ var AIRY_ANDROID_APP_ID = "com.freeairytv.android";
2323
+ var AIRY_APP_NAME = "AiryTV Movies & TV";
2324
+ var AIRY_DEFAULT_CONTENT_URL = "https://live.airy.tv";
2325
+ var CTV_SESSION_STORAGE_KEY = "stormcloud.ctv.sid";
2326
+ var DEVICE_ID_STORAGE_KEYS = [
2327
+ "rdid",
2328
+ "ifa",
2329
+ "advertisingId",
2330
+ "advertising_id",
2331
+ "deviceAdvertisingId",
2332
+ "aaid",
2333
+ "adid",
2334
+ "rida",
2335
+ "tifa",
2336
+ "lgudid"
2337
+ ];
2338
+ var ANDROID_ID_TYPES = /* @__PURE__ */ new Set([
2339
+ "aaid",
2340
+ "adid"
2341
+ ]);
2342
+ function resolveVastEnvironmentSignals(isCtv) {
2343
+ var _ref, _bridgeSignals_limitAdTracking;
2344
+ var bridgeSignals = readNativeBridgeSignals();
2345
+ var deviceId = bridgeSignals.deviceId || readStoredDeviceId();
2346
+ var deviceIdType = bridgeSignals.deviceIdType || readStoredString("deviceIdType") || readStoredString("idtype") || inferDeviceIdType();
2347
+ var limitAdTracking = deviceId != null ? (_ref = (_bridgeSignals_limitAdTracking = bridgeSignals.limitAdTracking) !== null && _bridgeSignals_limitAdTracking !== void 0 ? _bridgeSignals_limitAdTracking : readStoredLimitAdTracking()) !== null && _ref !== void 0 ? _ref : false : void 0;
2348
+ if (isCtv) {
2349
+ return _object_spread_props(_object_spread({
2350
+ isCtv: true,
2351
+ contentUrl: bridgeSignals.contentUrl || readStoredString("contentUrl") || AIRY_DEFAULT_CONTENT_URL,
2352
+ appId: bridgeSignals.appId || readStoredString("appId") || readStoredString("msid") || AIRY_ANDROID_APP_ID,
2353
+ appName: bridgeSignals.appName || readStoredString("appName") || readStoredString("an") || AIRY_APP_NAME,
2354
+ sessionId: getOrCreateCtvSessionId()
2355
+ }, deviceId ? {
2356
+ deviceId: deviceId
2357
+ } : {}, deviceIdType ? {
2358
+ deviceIdType: deviceIdType
2359
+ } : {}, limitAdTracking != null ? {
2360
+ limitAdTracking: limitAdTracking
2361
+ } : {}), {
2362
+ deviceTypeHint: 5
2363
+ });
2364
+ }
2365
+ return _object_spread({
2366
+ isCtv: false
2367
+ }, deviceId ? {
2368
+ deviceId: deviceId
2369
+ } : {}, deviceIdType ? {
2370
+ deviceIdType: deviceIdType
2371
+ } : {}, limitAdTracking != null ? {
2372
+ limitAdTracking: limitAdTracking
2373
+ } : {});
2374
+ }
2375
+ function inferDeviceIdType() {
2376
+ if (typeof navigator === "undefined") {
2377
+ return void 0;
2378
+ }
2379
+ var ua = navigator.userAgent;
2380
+ if (/Roku/i.test(ua)) return "rida";
2381
+ if (/Tizen|Samsung/i.test(ua)) return "tifa";
2382
+ if (/AppleTV|Apple TV/i.test(ua)) return "tvOS";
2383
+ if (/AFT|Fire TV|Amazon/i.test(ua)) return "afai";
2384
+ if (/Web0S|webOS|LG Browser|LGSTB|LGE/i.test(ua)) return "lgudid";
2385
+ if (/Android|Google TV/i.test(ua)) return "aaid";
2386
+ if (/iPhone|iPad|iPod/i.test(ua)) return "idfa";
2387
+ return void 0;
2388
+ }
2389
+ function isEquivalentDeviceIdType(tagType, runtimeType) {
2390
+ if (!tagType || !runtimeType) return false;
2391
+ var tag = tagType.toLowerCase();
2392
+ var runtime = runtimeType.toLowerCase();
2393
+ if (tag === runtime) return true;
2394
+ return ANDROID_ID_TYPES.has(tag) && ANDROID_ID_TYPES.has(runtime);
2395
+ }
2396
+ function getOrCreateCtvSessionId() {
2397
+ var existing = readStoredString(CTV_SESSION_STORAGE_KEY);
2398
+ if (existing) {
2399
+ return existing;
2400
+ }
2401
+ var sessionId = createUuid();
2402
+ try {
2403
+ var _window_localStorage;
2404
+ (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(CTV_SESSION_STORAGE_KEY, sessionId);
2405
+ } catch (unused) {}
2406
+ return sessionId;
2407
+ }
2408
+ function createUuid() {
2409
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
2410
+ return crypto.randomUUID();
2411
+ }
2412
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(char) {
2413
+ var value = Math.floor(Math.random() * 16);
2414
+ var nibble = char === "x" ? value : value & 3 | 8;
2415
+ return nibble.toString(16);
2416
+ });
2417
+ }
2418
+ function readNativeBridgeSignals() {
2419
+ if (typeof window === "undefined") {
2420
+ return {};
2421
+ }
2422
+ var candidates = [
2423
+ window.__STORMCLOUD_CTV_AD_INFO__,
2424
+ window.__STORMCLOUD_CTV__,
2425
+ window.stormcloudCtv,
2426
+ window.AiryTV,
2427
+ window.Android,
2428
+ window.webOS,
2429
+ window.tizen,
2430
+ window.amazon
2431
+ ].filter(Boolean);
2432
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2433
+ try {
2434
+ for(var _iterator = candidates[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2435
+ var source = _step.value;
2436
+ var contentUrl = readBridgeValue(source, [
2437
+ "contentUrl",
2438
+ "url",
2439
+ "videoUrl",
2440
+ "canonicalUrl"
2441
+ ]) || void 0;
2442
+ var appId = readBridgeValue(source, [
2443
+ "appId",
2444
+ "msid",
2445
+ "applicationId",
2446
+ "packageName"
2447
+ ]) || void 0;
2448
+ var appName = readBridgeValue(source, [
2449
+ "appName",
2450
+ "an",
2451
+ "applicationName"
2452
+ ]) || void 0;
2453
+ var deviceId = readBridgeValue(source, [
2454
+ "rdid",
2455
+ "ifa",
2456
+ "advertisingId",
2457
+ "adId",
2458
+ "deviceId",
2459
+ "lgudid",
2460
+ "LGUDID",
2461
+ "tifa",
2462
+ "rida",
2463
+ "afai",
2464
+ "aaid"
2465
+ ]) || void 0;
2466
+ if (!contentUrl && !deviceId && !appId && !appName) continue;
2467
+ var deviceIdType = readBridgeValue(source, [
2468
+ "idtype",
2469
+ "deviceIdType",
2470
+ "advertisingIdType",
2471
+ "idType"
2472
+ ]) || inferDeviceIdType();
2473
+ var limitAdTracking = readBridgeBoolean(source, [
2474
+ "is_lat",
2475
+ "limitAdTracking",
2476
+ "limitedAdTracking",
2477
+ "lat"
2478
+ ]);
2479
+ return _object_spread({}, contentUrl ? {
2480
+ contentUrl: contentUrl
2481
+ } : {}, appId ? {
2482
+ appId: appId
2483
+ } : {}, appName ? {
2484
+ appName: appName
2485
+ } : {}, deviceId ? {
2486
+ deviceId: deviceId
2487
+ } : {}, deviceId && deviceIdType ? {
2488
+ deviceIdType: deviceIdType
2489
+ } : {}, deviceId && limitAdTracking != null ? {
2490
+ limitAdTracking: limitAdTracking
2491
+ } : {});
2492
+ }
2493
+ } catch (err) {
2494
+ _didIteratorError = true;
2495
+ _iteratorError = err;
2496
+ } finally{
2324
2497
  try {
2325
- var _buf_, _buf_1;
2326
- var buf = new Uint32Array(2);
2327
- crypto.getRandomValues(buf);
2328
- var value = ((_buf_ = buf[0]) !== null && _buf_ !== void 0 ? _buf_ : 0) * 2097152 + (((_buf_1 = buf[1]) !== null && _buf_1 !== void 0 ? _buf_1 : 0) & 2097151);
2329
- if (value > 0) {
2330
- return String(value);
2498
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2499
+ _iterator.return();
2331
2500
  }
2332
- } catch (unused) {}
2501
+ } finally{
2502
+ if (_didIteratorError) {
2503
+ throw _iteratorError;
2504
+ }
2505
+ }
2333
2506
  }
2334
- return String(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER) + 1);
2507
+ return {};
2508
+ }
2509
+ function readBridgeValue(source, keys) {
2510
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2511
+ try {
2512
+ for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2513
+ var key = _step.value;
2514
+ var value = source === null || source === void 0 ? void 0 : source[key];
2515
+ if (typeof value === "string" && value) {
2516
+ return value;
2517
+ }
2518
+ if (typeof value === "function") {
2519
+ try {
2520
+ var result = value.call(source);
2521
+ if (typeof result === "string" && result) {
2522
+ return result;
2523
+ }
2524
+ } catch (unused) {}
2525
+ }
2526
+ }
2527
+ } catch (err) {
2528
+ _didIteratorError = true;
2529
+ _iteratorError = err;
2530
+ } finally{
2531
+ try {
2532
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2533
+ _iterator.return();
2534
+ }
2535
+ } finally{
2536
+ if (_didIteratorError) {
2537
+ throw _iteratorError;
2538
+ }
2539
+ }
2540
+ }
2541
+ return void 0;
2542
+ }
2543
+ function readBridgeBoolean(source, keys) {
2544
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2545
+ try {
2546
+ for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2547
+ var key = _step.value;
2548
+ var value = source === null || source === void 0 ? void 0 : source[key];
2549
+ var normalized = normalizeBoolean(value);
2550
+ if (normalized != null) {
2551
+ return normalized;
2552
+ }
2553
+ if (typeof value === "function") {
2554
+ try {
2555
+ var result = normalizeBoolean(value.call(source));
2556
+ if (result != null) {
2557
+ return result;
2558
+ }
2559
+ } catch (unused) {}
2560
+ }
2561
+ }
2562
+ } catch (err) {
2563
+ _didIteratorError = true;
2564
+ _iteratorError = err;
2565
+ } finally{
2566
+ try {
2567
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2568
+ _iterator.return();
2569
+ }
2570
+ } finally{
2571
+ if (_didIteratorError) {
2572
+ throw _iteratorError;
2573
+ }
2574
+ }
2575
+ }
2576
+ return void 0;
2335
2577
  }
2578
+ function readStoredDeviceId() {
2579
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2580
+ try {
2581
+ for(var _iterator = DEVICE_ID_STORAGE_KEYS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2582
+ var key = _step.value;
2583
+ var value = readStoredString(key);
2584
+ if (value) {
2585
+ return value;
2586
+ }
2587
+ }
2588
+ } catch (err) {
2589
+ _didIteratorError = true;
2590
+ _iteratorError = err;
2591
+ } finally{
2592
+ try {
2593
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2594
+ _iterator.return();
2595
+ }
2596
+ } finally{
2597
+ if (_didIteratorError) {
2598
+ throw _iteratorError;
2599
+ }
2600
+ }
2601
+ }
2602
+ return void 0;
2603
+ }
2604
+ function readStoredString(key) {
2605
+ if (typeof window === "undefined") {
2606
+ return void 0;
2607
+ }
2608
+ try {
2609
+ var _window_localStorage;
2610
+ var value = (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(key);
2611
+ return value || void 0;
2612
+ } catch (unused) {
2613
+ return void 0;
2614
+ }
2615
+ }
2616
+ function readStoredLimitAdTracking() {
2617
+ return normalizeBoolean(readStoredString("limitAdTracking") || readStoredString("limitedAdTracking") || readStoredString("is_lat"));
2618
+ }
2619
+ function normalizeBoolean(value) {
2620
+ if (typeof value === "boolean") {
2621
+ return value;
2622
+ }
2623
+ if (typeof value === "number") {
2624
+ return value === 1;
2625
+ }
2626
+ if (typeof value === "string") {
2627
+ var normalized = value.toLowerCase();
2628
+ if (normalized === "1" || normalized === "true" || normalized === "yes") {
2629
+ return true;
2630
+ }
2631
+ if (normalized === "0" || normalized === "false" || normalized === "no") {
2632
+ return false;
2633
+ }
2634
+ }
2635
+ return void 0;
2636
+ }
2637
+ // src/utils/vastMacros.ts
2336
2638
  var UNEXPANDED_MACRO_PATTERN = /^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%)$/;
2639
+ var INVALID_VAST_PARAM_KEY = /^\s|\s$/;
2640
+ var EXAMPLE_COM_URL = /example\.com/i;
2337
2641
  var CTV_UNSUPPORTED_PARAMS = [
2338
2642
  "description_url",
2339
2643
  "tfcd",
@@ -2348,14 +2652,265 @@ var CTV_UNSUPPORTED_PARAMS = [
2348
2652
  "gdpr_consent",
2349
2653
  "us_privacy"
2350
2654
  ];
2655
+ var INLINE_DEVICE_MACRO_REPLACEMENTS = [
2656
+ {
2657
+ pattern: /\[RDID\]/gi,
2658
+ getValue: function getValue(ctx) {
2659
+ return ctx.deviceId;
2660
+ }
2661
+ },
2662
+ {
2663
+ pattern: /\[IFA\]/gi,
2664
+ getValue: function getValue(ctx) {
2665
+ return ctx.deviceId;
2666
+ }
2667
+ },
2668
+ {
2669
+ pattern: /\[ADVERTISING[_-]?ID(?:ENTIFIER)?\]/gi,
2670
+ getValue: function getValue(ctx) {
2671
+ return ctx.deviceId;
2672
+ }
2673
+ },
2674
+ {
2675
+ pattern: /\[DEVICE[_-]?ID\]/gi,
2676
+ getValue: function getValue(ctx) {
2677
+ return ctx.deviceId;
2678
+ }
2679
+ },
2680
+ {
2681
+ pattern: /\[IDTYPE\]/gi,
2682
+ getValue: function getValue(ctx) {
2683
+ return ctx.deviceIdType;
2684
+ }
2685
+ },
2686
+ {
2687
+ pattern: /\{rdid\}/gi,
2688
+ getValue: function getValue(ctx) {
2689
+ return ctx.deviceId;
2690
+ }
2691
+ },
2692
+ {
2693
+ pattern: /\{device[_-]?id\}/gi,
2694
+ getValue: function getValue(ctx) {
2695
+ return ctx.deviceId;
2696
+ }
2697
+ },
2698
+ {
2699
+ pattern: /\{idtype\}/gi,
2700
+ getValue: function getValue(ctx) {
2701
+ return ctx.deviceIdType;
2702
+ }
2703
+ },
2704
+ {
2705
+ pattern: /%%ADVERTISING_IDENTIFIER_PLAIN%%/gi,
2706
+ getValue: function getValue(ctx) {
2707
+ return ctx.deviceId;
2708
+ }
2709
+ },
2710
+ {
2711
+ pattern: /%%ADVERTISING_ID_OPT_OUT%%/gi,
2712
+ getValue: function getValue(ctx) {
2713
+ return ctx.limitAdTracking != null ? ctx.limitAdTracking ? "1" : "0" : void 0;
2714
+ }
2715
+ },
2716
+ {
2717
+ pattern: /%%ADVERTISING_ID_TYPE%%/gi,
2718
+ getValue: function getValue(ctx) {
2719
+ return ctx.deviceIdType;
2720
+ }
2721
+ },
2722
+ {
2723
+ pattern: /%%ADVERTISING_ID%%/gi,
2724
+ getValue: function getValue(ctx) {
2725
+ return ctx.deviceId;
2726
+ }
2727
+ },
2728
+ {
2729
+ pattern: /%%LIMIT_AD_TRACKING%%/gi,
2730
+ getValue: function getValue(ctx) {
2731
+ return ctx.limitAdTracking != null ? ctx.limitAdTracking ? "1" : "0" : void 0;
2732
+ }
2733
+ },
2734
+ {
2735
+ pattern: /%%MSID%%/gi,
2736
+ getValue: function getValue(ctx) {
2737
+ return ctx.appId;
2738
+ }
2739
+ },
2740
+ {
2741
+ pattern: /%%APP_NAME%%/gi,
2742
+ getValue: function getValue(ctx) {
2743
+ return ctx.appName;
2744
+ }
2745
+ },
2746
+ {
2747
+ pattern: /%%SESSION_ID%%/gi,
2748
+ getValue: function getValue(ctx) {
2749
+ return ctx.sessionId;
2750
+ }
2751
+ },
2752
+ {
2753
+ pattern: /%%CORRELATOR%%/gi,
2754
+ getValue: function getValue(ctx) {
2755
+ return ctx.correlator;
2756
+ }
2757
+ }
2758
+ ];
2759
+ function isMacroPlaceholder(value) {
2760
+ if (value == null) return true;
2761
+ var trimmed = value.trim();
2762
+ if (!trimmed) return true;
2763
+ if (UNEXPANDED_MACRO_PATTERN.test(trimmed)) return true;
2764
+ return /^(unknown|null|undefined|none|n\/a|\$\{[^}]+\})$/i.test(trimmed);
2765
+ }
2766
+ function generateCorrelator() {
2767
+ if (typeof crypto !== "undefined" && crypto.getRandomValues) {
2768
+ try {
2769
+ var _buf_, _buf_1;
2770
+ var buf = new Uint32Array(2);
2771
+ crypto.getRandomValues(buf);
2772
+ var value = ((_buf_ = buf[0]) !== null && _buf_ !== void 0 ? _buf_ : 0) * 2097152 + (((_buf_1 = buf[1]) !== null && _buf_1 !== void 0 ? _buf_1 : 0) & 2097151);
2773
+ if (value > 0) {
2774
+ return String(value);
2775
+ }
2776
+ } catch (unused) {}
2777
+ }
2778
+ return String(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER) + 1);
2779
+ }
2780
+ function expandInlineMacroPlaceholders(baseUrl, ctx) {
2781
+ var url = baseUrl;
2782
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2783
+ try {
2784
+ for(var _iterator = INLINE_DEVICE_MACRO_REPLACEMENTS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2785
+ var _step_value = _step.value, pattern = _step_value.pattern, getValue = _step_value.getValue;
2786
+ var value = getValue(ctx);
2787
+ if (value != null && value !== "") {
2788
+ url = url.replace(pattern, encodeURIComponent(value));
2789
+ }
2790
+ }
2791
+ } catch (err) {
2792
+ _didIteratorError = true;
2793
+ _iteratorError = err;
2794
+ } finally{
2795
+ try {
2796
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2797
+ _iterator.return();
2798
+ }
2799
+ } finally{
2800
+ if (_didIteratorError) {
2801
+ throw _iteratorError;
2802
+ }
2803
+ }
2804
+ }
2805
+ return url;
2806
+ }
2807
+ function applyDeviceIdentityParams(params, ctx) {
2808
+ var _ctx_deviceId, _ctx_deviceIdType;
2809
+ var runtimeId = (_ctx_deviceId = ctx.deviceId) === null || _ctx_deviceId === void 0 ? void 0 : _ctx_deviceId.trim();
2810
+ var runtimeType = ((_ctx_deviceIdType = ctx.deviceIdType) === null || _ctx_deviceIdType === void 0 ? void 0 : _ctx_deviceIdType.trim()) || inferDeviceIdType();
2811
+ var tagRdid = params.get("rdid");
2812
+ var tagType = params.get("idtype");
2813
+ var tagLat = params.get("is_lat");
2814
+ var latValue = ctx.limitAdTracking != null ? ctx.limitAdTracking ? "1" : "0" : void 0;
2815
+ if (runtimeId) {
2816
+ params.set("rdid", runtimeId);
2817
+ params.set("idtype", runtimeType || tagType || "aaid");
2818
+ params.set("is_lat", latValue !== null && latValue !== void 0 ? latValue : isMacroPlaceholder(tagLat) ? "0" : tagLat);
2819
+ return;
2820
+ }
2821
+ var tagRdidValid = Boolean(tagRdid && !isMacroPlaceholder(tagRdid));
2822
+ var tagTypeValid = Boolean(tagType && !isMacroPlaceholder(tagType));
2823
+ if (tagRdidValid && tagTypeValid && runtimeType && !isEquivalentDeviceIdType(tagType, runtimeType)) {
2824
+ params.delete("rdid");
2825
+ params.delete("idtype");
2826
+ params.delete("is_lat");
2827
+ return;
2828
+ }
2829
+ if (tagRdidValid) {
2830
+ if (isMacroPlaceholder(tagType) && runtimeType) {
2831
+ params.set("idtype", runtimeType);
2832
+ }
2833
+ if (isMacroPlaceholder(tagLat)) {
2834
+ params.set("is_lat", latValue !== null && latValue !== void 0 ? latValue : "0");
2835
+ }
2836
+ return;
2837
+ }
2838
+ params.delete("rdid");
2839
+ params.delete("idtype");
2840
+ params.delete("is_lat");
2841
+ }
2842
+ function removeBrokenAppNameOrphans(params, appName) {
2843
+ var toDelete = [];
2844
+ params.forEach(function(_value, key) {
2845
+ if (!key || INVALID_VAST_PARAM_KEY.test(key)) {
2846
+ toDelete.push(key);
2847
+ }
2848
+ });
2849
+ if (appName && appName.includes("&")) {
2850
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2851
+ try {
2852
+ for(var _iterator = appName.split("&").slice(1)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2853
+ var suffix = _step.value;
2854
+ var trimmed = suffix.trimStart();
2855
+ if (!trimmed) continue;
2856
+ toDelete.push(suffix, " ".concat(trimmed), trimmed);
2857
+ }
2858
+ } catch (err) {
2859
+ _didIteratorError = true;
2860
+ _iteratorError = err;
2861
+ } finally{
2862
+ try {
2863
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2864
+ _iterator.return();
2865
+ }
2866
+ } finally{
2867
+ if (_didIteratorError) {
2868
+ throw _iteratorError;
2869
+ }
2870
+ }
2871
+ }
2872
+ }
2873
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
2874
+ try {
2875
+ for(var _iterator1 = new Set(toDelete)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
2876
+ var key = _step1.value;
2877
+ if (key) params.delete(key);
2878
+ }
2879
+ } catch (err) {
2880
+ _didIteratorError1 = true;
2881
+ _iteratorError1 = err;
2882
+ } finally{
2883
+ try {
2884
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
2885
+ _iterator1.return();
2886
+ }
2887
+ } finally{
2888
+ if (_didIteratorError1) {
2889
+ throw _iteratorError1;
2890
+ }
2891
+ }
2892
+ }
2893
+ }
2894
+ function normalizeVastTagUrl(raw) {
2895
+ if (!raw) return raw;
2896
+ try {
2897
+ var url = new URL(raw);
2898
+ removeBrokenAppNameOrphans(url.searchParams);
2899
+ return url.toString();
2900
+ } catch (unused) {
2901
+ return raw;
2902
+ }
2903
+ }
2351
2904
  function applyVastMacros(baseUrl, ctx) {
2905
+ var expandedUrl = expandInlineMacroPlaceholders(baseUrl, ctx);
2352
2906
  var url;
2353
2907
  try {
2354
- url = new URL(baseUrl);
2908
+ url = new URL(normalizeVastTagUrl(expandedUrl));
2355
2909
  } catch (unused) {
2356
- return replaceCorrelatorFallback(baseUrl, ctx.correlator);
2910
+ return replaceCorrelatorFallback(expandedUrl, ctx.correlator);
2357
2911
  }
2358
2912
  var params = url.searchParams;
2913
+ removeBrokenAppNameOrphans(params, ctx.appName);
2359
2914
  params.set("correlator", ctx.correlator);
2360
2915
  if (ctx.isCtv) {
2361
2916
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
@@ -2393,6 +2948,12 @@ function applyVastMacros(baseUrl, ctx) {
2393
2948
  if (!ctx.isCtv) {
2394
2949
  params.set("description_url", requestUrl);
2395
2950
  }
2951
+ } else {
2952
+ var existingUrl = params.get("url") || "";
2953
+ if (EXAMPLE_COM_URL.test(existingUrl)) {
2954
+ params.delete("url");
2955
+ params.delete("description_url");
2956
+ }
2396
2957
  }
2397
2958
  if (ctx.adWillPlayMuted != null) {
2398
2959
  params.set("vpmute", ctx.adWillPlayMuted ? "1" : "0");
@@ -2404,6 +2965,7 @@ function applyVastMacros(baseUrl, ctx) {
2404
2965
  params.set("msid", ctx.appId);
2405
2966
  }
2406
2967
  if (ctx.appName) {
2968
+ removeBrokenAppNameOrphans(params, ctx.appName);
2407
2969
  params.set("an", ctx.appName);
2408
2970
  }
2409
2971
  if (ctx.sessionId) {
@@ -2414,15 +2976,7 @@ function applyVastMacros(baseUrl, ctx) {
2414
2976
  } else if (ctx.isCtv) {
2415
2977
  params.set("dth", "5");
2416
2978
  }
2417
- if (ctx.deviceId && ctx.deviceIdType) {
2418
- params.set("rdid", ctx.deviceId);
2419
- params.set("idtype", ctx.deviceIdType);
2420
- params.set("is_lat", ctx.limitAdTracking ? "1" : "0");
2421
- } else {
2422
- params.delete("rdid");
2423
- params.delete("idtype");
2424
- params.delete("is_lat");
2425
- }
2979
+ applyDeviceIdentityParams(params, ctx);
2426
2980
  if (!ctx.isCtv) {
2427
2981
  var consent = ctx.consent;
2428
2982
  if ((consent === null || consent === void 0 ? void 0 : consent.gdpr) != null) {
@@ -2440,7 +2994,7 @@ function applyVastMacros(baseUrl, ctx) {
2440
2994
  }
2441
2995
  var staleKeys = [];
2442
2996
  params.forEach(function(value, key) {
2443
- if (UNEXPANDED_MACRO_PATTERN.test(value)) {
2997
+ if (isMacroPlaceholder(value)) {
2444
2998
  staleKeys.push(key);
2445
2999
  }
2446
3000
  });
@@ -2464,6 +3018,7 @@ function applyVastMacros(baseUrl, ctx) {
2464
3018
  }
2465
3019
  }
2466
3020
  }
3021
+ removeBrokenAppNameOrphans(params, ctx.appName);
2467
3022
  return url.toString();
2468
3023
  }
2469
3024
  function replaceCorrelatorFallback(baseUrl, correlator) {
@@ -3739,277 +4294,11 @@ var Scte35CueManager = /*#__PURE__*/ function() {
3739
4294
  ]);
3740
4295
  return Scte35CueManager;
3741
4296
  }();
3742
- // src/utils/ctvVastSignals.ts
3743
- var AIRY_ANDROID_APP_ID = "com.freeairytv.android";
3744
- var AIRY_APP_NAME = "AiryTV Movies & TV";
3745
- var AIRY_DEFAULT_CONTENT_URL = "https://live.airy.tv";
3746
- var CTV_SESSION_STORAGE_KEY = "stormcloud.ctv.sid";
3747
- var DEVICE_ID_STORAGE_KEYS = [
3748
- "rdid",
3749
- "ifa",
3750
- "advertisingId",
3751
- "advertising_id",
3752
- "deviceAdvertisingId",
3753
- "aaid",
3754
- "adid",
3755
- "rida",
3756
- "tifa"
3757
- ];
3758
- function resolveCtvVastSignals() {
3759
- var _ref, _bridgeSignals_limitAdTracking;
3760
- var bridgeSignals = readNativeBridgeSignals();
3761
- var deviceId = bridgeSignals.deviceId || readStoredDeviceId();
3762
- var deviceIdType = bridgeSignals.deviceIdType || readStoredString("deviceIdType") || inferDeviceIdType();
3763
- var contentUrl = bridgeSignals.contentUrl || readStoredString("contentUrl") || AIRY_DEFAULT_CONTENT_URL;
3764
- return _object_spread_props(_object_spread({
3765
- contentUrl: contentUrl,
3766
- appId: AIRY_ANDROID_APP_ID,
3767
- appName: AIRY_APP_NAME,
3768
- sessionId: getOrCreateCtvSessionId()
3769
- }, deviceId ? {
3770
- deviceId: deviceId
3771
- } : {}, deviceId && deviceIdType ? {
3772
- deviceIdType: deviceIdType
3773
- } : {}, deviceId ? {
3774
- limitAdTracking: (_ref = (_bridgeSignals_limitAdTracking = bridgeSignals.limitAdTracking) !== null && _bridgeSignals_limitAdTracking !== void 0 ? _bridgeSignals_limitAdTracking : readStoredLimitAdTracking()) !== null && _ref !== void 0 ? _ref : false
3775
- } : {}), {
3776
- deviceTypeHint: 5
3777
- });
3778
- }
3779
- function getOrCreateCtvSessionId() {
3780
- var existing = readStoredString(CTV_SESSION_STORAGE_KEY);
3781
- if (existing) {
3782
- return existing;
3783
- }
3784
- var sessionId = createUuid();
3785
- try {
3786
- var _window_localStorage;
3787
- (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(CTV_SESSION_STORAGE_KEY, sessionId);
3788
- } catch (unused) {}
3789
- return sessionId;
3790
- }
3791
- function createUuid() {
3792
- if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
3793
- return crypto.randomUUID();
3794
- }
3795
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(char) {
3796
- var value = Math.floor(Math.random() * 16);
3797
- var nibble = char === "x" ? value : value & 3 | 8;
3798
- return nibble.toString(16);
3799
- });
3800
- }
3801
- function readNativeBridgeSignals() {
3802
- if (typeof window === "undefined") {
3803
- return {};
3804
- }
3805
- var candidates = [
3806
- window.__STORMCLOUD_CTV_AD_INFO__,
3807
- window.__STORMCLOUD_CTV__,
3808
- window.stormcloudCtv,
3809
- window.AiryTV,
3810
- window.Android
3811
- ].filter(Boolean);
3812
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3813
- try {
3814
- for(var _iterator = candidates[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3815
- var source = _step.value;
3816
- var contentUrl = readBridgeValue(source, [
3817
- "contentUrl",
3818
- "url",
3819
- "videoUrl",
3820
- "canonicalUrl"
3821
- ]) || void 0;
3822
- var deviceId = readBridgeValue(source, [
3823
- "rdid",
3824
- "ifa",
3825
- "advertisingId",
3826
- "adId",
3827
- "deviceId"
3828
- ]) || void 0;
3829
- if (!contentUrl && !deviceId) continue;
3830
- var deviceIdType = readBridgeValue(source, [
3831
- "idtype",
3832
- "deviceIdType",
3833
- "advertisingIdType"
3834
- ]) || inferDeviceIdType();
3835
- var limitAdTracking = readBridgeBoolean(source, [
3836
- "is_lat",
3837
- "limitAdTracking",
3838
- "limitedAdTracking",
3839
- "lat"
3840
- ]);
3841
- return _object_spread({}, contentUrl ? {
3842
- contentUrl: contentUrl
3843
- } : {}, deviceId ? {
3844
- deviceId: deviceId
3845
- } : {}, deviceId && deviceIdType ? {
3846
- deviceIdType: deviceIdType
3847
- } : {}, deviceId && limitAdTracking != null ? {
3848
- limitAdTracking: limitAdTracking
3849
- } : {});
3850
- }
3851
- } catch (err) {
3852
- _didIteratorError = true;
3853
- _iteratorError = err;
3854
- } finally{
3855
- try {
3856
- if (!_iteratorNormalCompletion && _iterator.return != null) {
3857
- _iterator.return();
3858
- }
3859
- } finally{
3860
- if (_didIteratorError) {
3861
- throw _iteratorError;
3862
- }
3863
- }
3864
- }
3865
- return {};
3866
- }
3867
- function readBridgeValue(source, keys) {
3868
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3869
- try {
3870
- for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3871
- var key = _step.value;
3872
- var value = source === null || source === void 0 ? void 0 : source[key];
3873
- if (typeof value === "string" && value) {
3874
- return value;
3875
- }
3876
- if (typeof value === "function") {
3877
- try {
3878
- var result = value.call(source);
3879
- if (typeof result === "string" && result) {
3880
- return result;
3881
- }
3882
- } catch (unused) {}
3883
- }
3884
- }
3885
- } catch (err) {
3886
- _didIteratorError = true;
3887
- _iteratorError = err;
3888
- } finally{
3889
- try {
3890
- if (!_iteratorNormalCompletion && _iterator.return != null) {
3891
- _iterator.return();
3892
- }
3893
- } finally{
3894
- if (_didIteratorError) {
3895
- throw _iteratorError;
3896
- }
3897
- }
3898
- }
3899
- return void 0;
3900
- }
3901
- function readBridgeBoolean(source, keys) {
3902
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3903
- try {
3904
- for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3905
- var key = _step.value;
3906
- var value = source === null || source === void 0 ? void 0 : source[key];
3907
- var normalized = normalizeBoolean(value);
3908
- if (normalized != null) {
3909
- return normalized;
3910
- }
3911
- if (typeof value === "function") {
3912
- try {
3913
- var result = normalizeBoolean(value.call(source));
3914
- if (result != null) {
3915
- return result;
3916
- }
3917
- } catch (unused) {}
3918
- }
3919
- }
3920
- } catch (err) {
3921
- _didIteratorError = true;
3922
- _iteratorError = err;
3923
- } finally{
3924
- try {
3925
- if (!_iteratorNormalCompletion && _iterator.return != null) {
3926
- _iterator.return();
3927
- }
3928
- } finally{
3929
- if (_didIteratorError) {
3930
- throw _iteratorError;
3931
- }
3932
- }
3933
- }
3934
- return void 0;
3935
- }
3936
- function readStoredDeviceId() {
3937
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3938
- try {
3939
- for(var _iterator = DEVICE_ID_STORAGE_KEYS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3940
- var key = _step.value;
3941
- var value = readStoredString(key);
3942
- if (value) {
3943
- return value;
3944
- }
3945
- }
3946
- } catch (err) {
3947
- _didIteratorError = true;
3948
- _iteratorError = err;
3949
- } finally{
3950
- try {
3951
- if (!_iteratorNormalCompletion && _iterator.return != null) {
3952
- _iterator.return();
3953
- }
3954
- } finally{
3955
- if (_didIteratorError) {
3956
- throw _iteratorError;
3957
- }
3958
- }
3959
- }
3960
- return void 0;
3961
- }
3962
- function readStoredString(key) {
3963
- if (typeof window === "undefined") {
3964
- return void 0;
3965
- }
3966
- try {
3967
- var _window_localStorage;
3968
- var value = (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(key);
3969
- return value || void 0;
3970
- } catch (unused) {
3971
- return void 0;
3972
- }
3973
- }
3974
- function readStoredLimitAdTracking() {
3975
- return normalizeBoolean(readStoredString("limitAdTracking") || readStoredString("limitedAdTracking") || readStoredString("is_lat"));
3976
- }
3977
- function normalizeBoolean(value) {
3978
- if (typeof value === "boolean") {
3979
- return value;
3980
- }
3981
- if (typeof value === "number") {
3982
- return value === 1;
3983
- }
3984
- if (typeof value === "string") {
3985
- var normalized = value.toLowerCase();
3986
- if (normalized === "1" || normalized === "true" || normalized === "yes") {
3987
- return true;
3988
- }
3989
- if (normalized === "0" || normalized === "false" || normalized === "no") {
3990
- return false;
3991
- }
3992
- }
3993
- return void 0;
3994
- }
3995
- function inferDeviceIdType() {
3996
- if (typeof navigator === "undefined") {
3997
- return void 0;
3998
- }
3999
- var ua = navigator.userAgent;
4000
- if (/Roku/i.test(ua)) return "rida";
4001
- if (/Tizen|Samsung/i.test(ua)) return "tifa";
4002
- if (/AppleTV/i.test(ua)) return "tvOS";
4003
- if (/AFT|Fire TV|Amazon/i.test(ua)) return "afai";
4004
- if (/Web0S|webOS|LG/i.test(ua)) return "lgudid";
4005
- if (/Android|Google TV/i.test(ua)) return "aaid";
4006
- return void 0;
4007
- }
4008
- // src/player/VmapManager.ts
4009
- var VmapManager = /*#__PURE__*/ function() {
4297
+ // src/player/AdConfigManager.ts
4298
+ var AdConfigManager = /*#__PURE__*/ function() {
4010
4299
  "use strict";
4011
- function VmapManager(config, video) {
4012
- _class_call_check(this, VmapManager);
4300
+ function AdConfigManager(config, video) {
4301
+ _class_call_check(this, AdConfigManager);
4013
4302
  this.vmapBreaks = [];
4014
4303
  this.consumedVmapBreakIds = /* @__PURE__ */ new Set();
4015
4304
  this.streamCorrelator = generateCorrelator();
@@ -4021,7 +4310,7 @@ var VmapManager = /*#__PURE__*/ function() {
4021
4310
  this.config = config;
4022
4311
  this.video = video;
4023
4312
  }
4024
- _create_class(VmapManager, [
4313
+ _create_class(AdConfigManager, [
4025
4314
  {
4026
4315
  key: "debug",
4027
4316
  get: function get() {
@@ -4083,7 +4372,7 @@ var VmapManager = /*#__PURE__*/ function() {
4083
4372
  ];
4084
4373
  }
4085
4374
  if (this.config.vastTagUrl) {
4086
- this.apiVastTagUrl = this.config.vastTagUrl;
4375
+ this.apiVastTagUrl = normalizeVastTagUrl(this.config.vastTagUrl);
4087
4376
  if (this.debug) {
4088
4377
  console.log("[StormcloudVideoPlayer] Using custom VAST tag URL:", this.apiVastTagUrl);
4089
4378
  }
@@ -4123,7 +4412,7 @@ var VmapManager = /*#__PURE__*/ function() {
4123
4412
  data = _state.sent();
4124
4413
  imaPayload = (_data_response = data.response) === null || _data_response === void 0 ? void 0 : (_data_response_ima = _data_response.ima) === null || _data_response_ima === void 0 ? void 0 : (_data_response_ima_publisherdeskima = _data_response_ima["publisherdesk.ima"]) === null || _data_response_ima_publisherdeskima === void 0 ? void 0 : _data_response_ima_publisherdeskima.payload;
4125
4414
  if (imaPayload) {
4126
- this.apiVastTagUrl = decodeURIComponent(imaPayload);
4415
+ this.apiVastTagUrl = normalizeVastTagUrl(imaPayload);
4127
4416
  if (this.debug) {
4128
4417
  console.log("[StormcloudVideoPlayer] Extracted VAST tag URL from /ads/web:", this.apiVastTagUrl);
4129
4418
  }
@@ -4438,24 +4727,24 @@ var VmapManager = /*#__PURE__*/ function() {
4438
4727
  for(var i = 0; i < count; i++){
4439
4728
  this.adRequestPositionInBreak++;
4440
4729
  var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
4441
- var ctvSignals = this.config.ctvAdRequest ? resolveCtvVastSignals() : void 0;
4730
+ var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest);
4442
4731
  var urlWithMacros = applyVastMacros(baseUrl, {
4443
4732
  correlator: generateCorrelator(),
4444
4733
  streamCorrelator: this.streamCorrelator,
4445
4734
  pod: this.podCounter > 0 ? this.podCounter : void 0,
4446
4735
  adPosition: this.adRequestPositionInBreak,
4447
- isCtv: this.config.ctvAdRequest,
4448
- contentUrl: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.contentUrl,
4449
- pageUrl: !this.config.ctvAdRequest && typeof window !== "undefined" ? window.location.href : void 0,
4736
+ isCtv: envSignals.isCtv,
4737
+ contentUrl: envSignals.contentUrl,
4738
+ pageUrl: !envSignals.isCtv && typeof window !== "undefined" ? window.location.href : void 0,
4450
4739
  adWillPlayMuted: adWillPlayMuted,
4451
4740
  adWillAutoPlay: !!this.config.autoplay,
4452
- appId: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.appId,
4453
- appName: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.appName,
4454
- sessionId: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.sessionId,
4455
- deviceId: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.deviceId,
4456
- deviceIdType: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.deviceIdType,
4457
- limitAdTracking: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.limitAdTracking,
4458
- deviceTypeHint: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.deviceTypeHint,
4741
+ appId: envSignals.appId,
4742
+ appName: envSignals.appName,
4743
+ sessionId: envSignals.sessionId,
4744
+ deviceId: envSignals.deviceId,
4745
+ deviceIdType: envSignals.deviceIdType,
4746
+ limitAdTracking: envSignals.limitAdTracking,
4747
+ deviceTypeHint: envSignals.deviceTypeHint,
4459
4748
  adTest: this.config.adTest,
4460
4749
  consent: this.consentSignals
4461
4750
  });
@@ -4508,7 +4797,7 @@ var VmapManager = /*#__PURE__*/ function() {
4508
4797
  }
4509
4798
  }
4510
4799
  ]);
4511
- return VmapManager;
4800
+ return AdConfigManager;
4512
4801
  }();
4513
4802
  // src/player/AdTimingService.ts
4514
4803
  var AdTimingService = /*#__PURE__*/ function() {
@@ -6240,7 +6529,7 @@ function resizePlayer(video, adPlayer, debug) {
6240
6529
  // src/player/AdBreakOrchestrator.ts
6241
6530
  var AdBreakOrchestrator = /*#__PURE__*/ function() {
6242
6531
  "use strict";
6243
- function AdBreakOrchestrator(host, timing, preloadPool, vmap, cueManager, placeholder) {
6532
+ function AdBreakOrchestrator(host, timing, preloadPool, adConfig, cueManager, placeholder) {
6244
6533
  _class_call_check(this, AdBreakOrchestrator);
6245
6534
  this.inAdBreak = false;
6246
6535
  this.showAds = false;
@@ -6255,7 +6544,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
6255
6544
  this.host = host;
6256
6545
  this.timing = timing;
6257
6546
  this.preloadPool = preloadPool;
6258
- this.vmap = vmap;
6547
+ this.adConfig = adConfig;
6259
6548
  this.cueManager = cueManager;
6260
6549
  this.placeholder = placeholder;
6261
6550
  }
@@ -6421,7 +6710,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
6421
6710
  }
6422
6711
  this.pendingAdBreak = null;
6423
6712
  this.cueManager.pendingScte35CueKey = void 0;
6424
- this.vmap.podAssignedByPrefetch = false;
6713
+ this.adConfig.podAssignedByPrefetch = false;
6425
6714
  }
6426
6715
  },
6427
6716
  {
@@ -6435,15 +6724,15 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
6435
6724
  return _ts_generator(this, function(_state) {
6436
6725
  switch(_state.label){
6437
6726
  case 0:
6438
- scheduled = this.vmap.findCurrentOrNextBreak(this.host.video.currentTime * 1e3);
6727
+ scheduled = this.adConfig.findCurrentOrNextBreak(this.host.video.currentTime * 1e3);
6439
6728
  if (scheduled) {
6440
- this.vmap.consumedVmapBreakIds.add(this.vmap.getAdBreakKey(scheduled));
6729
+ this.adConfig.consumedVmapBreakIds.add(this.adConfig.getAdBreakKey(scheduled));
6441
6730
  }
6442
- tags = this.vmap.selectVastTagsForBreak(scheduled);
6731
+ tags = this.adConfig.selectVastTagsForBreak(scheduled);
6443
6732
  if (tags && tags.length > 0 && tags[0]) {
6444
6733
  baseVastUrl = tags[0];
6445
- } else if (this.vmap.apiVastTagUrl) {
6446
- baseVastUrl = this.vmap.apiVastTagUrl;
6734
+ } else if (this.adConfig.apiVastTagUrl) {
6735
+ baseVastUrl = this.adConfig.apiVastTagUrl;
6447
6736
  } else {
6448
6737
  this.clearPendingAdBreak();
6449
6738
  return [
@@ -6461,10 +6750,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
6461
6750
  this.continuousFetchingActive = true;
6462
6751
  this.isShowingPlaceholder = false;
6463
6752
  this.timing.totalAdRequestsInBreak = 0;
6464
- if (this.vmap.podAssignedByPrefetch) {
6465
- this.vmap.podAssignedByPrefetch = false;
6753
+ if (this.adConfig.podAssignedByPrefetch) {
6754
+ this.adConfig.podAssignedByPrefetch = false;
6466
6755
  } else {
6467
- this.vmap.beginNewAdPod();
6756
+ this.adConfig.beginNewAdPod();
6468
6757
  }
6469
6758
  currentMuted = this.host.video.muted;
6470
6759
  currentVolume = this.host.video.volume;
@@ -7737,7 +8026,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7737
8026
  return _this.adBreak.inAdBreak;
7738
8027
  }
7739
8028
  });
7740
- this.vmap = new VmapManager(this.config, this.video);
8029
+ this.adConfig = new AdConfigManager(this.config, this.video);
7741
8030
  this.timing = new AdTimingService(this.config, this.video, {
7742
8031
  onAdStopTimerFired: function onAdStopTimerFired() {
7743
8032
  return _this.onAdStopTimerFired();
@@ -7817,7 +8106,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7817
8106
  generateVastUrls: function generateVastUrls(base, count) {
7818
8107
  return _this.generateVastUrls(base, count);
7819
8108
  }
7820
- }, this.timing, this.preloadPool, this.vmap, this.cueManager, this.placeholder);
8109
+ }, this.timing, this.preloadPool, this.adConfig, this.cueManager, this.placeholder);
7821
8110
  }
7822
8111
  _create_class(StormcloudVideoPlayer, [
7823
8112
  {
@@ -7845,7 +8134,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7845
8134
  {
7846
8135
  key: "generateVastUrls",
7847
8136
  value: function generateVastUrls(baseUrl, count) {
7848
- return this.vmap.generateVastUrlsWithCorrelators(baseUrl, count, this.adPlayer, this.palNonce, this.adBreak.inAdBreak);
8137
+ return this.adConfig.generateVastUrlsWithCorrelators(baseUrl, count, this.adPlayer, this.palNonce, this.adBreak.inAdBreak);
7849
8138
  }
7850
8139
  },
7851
8140
  {
@@ -7873,7 +8162,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7873
8162
  ]);
7874
8163
  return [
7875
8164
  4,
7876
- this.vmap.fetchAdConfiguration()
8165
+ this.adConfig.fetchAdConfiguration()
7877
8166
  ];
7878
8167
  case 2:
7879
8168
  _state.sent();
@@ -7900,9 +8189,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7900
8189
  continuousPlayback: (_this_config_lowLatencyMode = this.config.lowLatencyMode) !== null && _this_config_lowLatencyMode !== void 0 ? _this_config_lowLatencyMode : false
7901
8190
  }).catch(function() {});
7902
8191
  fetchConsentSignals().then(function(signals) {
7903
- _this.vmap.consentSignals = signals;
8192
+ _this.adConfig.consentSignals = signals;
7904
8193
  }).catch(function() {});
7905
- this.vmap.initializeTracking();
8194
+ this.adConfig.initializeTracking();
7906
8195
  if (!this.hlsEngine.shouldUseNativeHls(function() {
7907
8196
  return _this.getStreamType();
7908
8197
  })) return [
@@ -7937,14 +8226,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7937
8226
  return _async_to_generator(function() {
7938
8227
  var prerollKey, adBehavior;
7939
8228
  return _ts_generator(this, function(_state) {
7940
- if (!this.vmap.isVmapEnabled() && !isLive && this.vmap.vmapBreaks.length === 0 && this.vmap.apiVastTagUrl) {
8229
+ if (!this.adConfig.isVmapEnabled() && !isLive && this.adConfig.vmapBreaks.length === 0 && this.adConfig.apiVastTagUrl) {
7941
8230
  prerollKey = "synthetic-vod-preroll";
7942
- if (!this.vmap.consumedVmapBreakIds.has(prerollKey)) {
7943
- this.vmap.vmapBreaks = [
8231
+ if (!this.adConfig.consumedVmapBreakIds.has(prerollKey)) {
8232
+ this.adConfig.vmapBreaks = [
7944
8233
  {
7945
8234
  id: prerollKey,
7946
8235
  startTimeMs: 0,
7947
- vastTagUrl: this.vmap.apiVastTagUrl
8236
+ vastTagUrl: this.adConfig.apiVastTagUrl
7948
8237
  }
7949
8238
  ];
7950
8239
  if (this.debug) {
@@ -8211,19 +8500,19 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8211
8500
  key: "startAdPrefetch",
8212
8501
  value: function startAdPrefetch(marker, fragmentSn, cueKey) {
8213
8502
  if (this.adBreak.pendingAdBreak || this.adBreak.inAdBreak) return;
8214
- var scheduled = this.vmap.findCurrentOrNextBreak(this.video.currentTime * 1e3);
8215
- var tags = this.vmap.selectVastTagsForBreak(scheduled);
8503
+ var scheduled = this.adConfig.findCurrentOrNextBreak(this.video.currentTime * 1e3);
8504
+ var tags = this.adConfig.selectVastTagsForBreak(scheduled);
8216
8505
  var baseVastUrl;
8217
8506
  if (tags && tags.length > 0 && tags[0]) {
8218
8507
  baseVastUrl = tags[0];
8219
- } else if (this.vmap.apiVastTagUrl) {
8220
- baseVastUrl = this.vmap.apiVastTagUrl;
8508
+ } else if (this.adConfig.apiVastTagUrl) {
8509
+ baseVastUrl = this.adConfig.apiVastTagUrl;
8221
8510
  } else {
8222
8511
  if (this.debug) console.warn("[StormcloudVideoPlayer] No VAST URL available for prefetch");
8223
8512
  return;
8224
8513
  }
8225
- this.vmap.beginNewAdPod();
8226
- this.vmap.podAssignedByPrefetch = true;
8514
+ this.adConfig.beginNewAdPod();
8515
+ this.adConfig.podAssignedByPrefetch = true;
8227
8516
  var generatedUrls = this.generateVastUrls(baseVastUrl, 1);
8228
8517
  this.adBreak.pendingAdBreak = _object_spread_props(_object_spread({
8229
8518
  marker: marker
@@ -8258,10 +8547,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8258
8547
  key: "onTimeUpdate",
8259
8548
  value: function onTimeUpdate(currentTimeSec) {
8260
8549
  var _this = this;
8261
- if (!this.vmap.isVmapEnabled() || this.vmap.vmapBreaks.length === 0) return;
8550
+ if (!this.adConfig.isVmapEnabled() || this.adConfig.vmapBreaks.length === 0) return;
8262
8551
  if (this.adPlayer.isAdPlaying() || this.adBreak.inAdBreak) return;
8263
8552
  var nowMs = currentTimeSec * 1e3;
8264
- var breakToPlay = this.vmap.findBreakForTime(nowMs);
8553
+ var breakToPlay = this.adConfig.findBreakForTime(nowMs);
8265
8554
  if (breakToPlay) {
8266
8555
  void this.handleVmapAdBreak(breakToPlay, nowMs).catch(function(error) {
8267
8556
  if (_this.debug) {
@@ -8275,11 +8564,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8275
8564
  key: "onVideoEnded",
8276
8565
  value: function onVideoEnded() {
8277
8566
  var _this = this;
8278
- if (!this.vmap.isVmapEnabled() || this.vmap.vmapBreaks.length === 0) return;
8567
+ if (!this.adConfig.isVmapEnabled() || this.adConfig.vmapBreaks.length === 0) return;
8279
8568
  if (this.adPlayer.isAdPlaying() || this.adBreak.inAdBreak) return;
8280
8569
  var durationMs = Number.isFinite(this.video.duration) ? Math.floor(this.video.duration * 1e3) : 0;
8281
- var postroll = this.vmap.vmapBreaks.find(function(b) {
8282
- return b.startTimeMs === -1 && !_this.vmap.consumedVmapBreakIds.has(_this.vmap.getAdBreakKey(b));
8570
+ var postroll = this.adConfig.vmapBreaks.find(function(b) {
8571
+ return b.startTimeMs === -1 && !_this.adConfig.consumedVmapBreakIds.has(_this.adConfig.getAdBreakKey(b));
8283
8572
  });
8284
8573
  if (postroll) {
8285
8574
  void this.handleVmapAdBreak(postroll, durationMs).catch(function(error) {
@@ -8298,11 +8587,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8298
8587
  return _ts_generator(this, function(_state) {
8299
8588
  switch(_state.label){
8300
8589
  case 0:
8301
- key = this.vmap.getAdBreakKey(adBreak);
8302
- if (this.vmap.consumedVmapBreakIds.has(key)) return [
8590
+ key = this.adConfig.getAdBreakKey(adBreak);
8591
+ if (this.adConfig.consumedVmapBreakIds.has(key)) return [
8303
8592
  2
8304
8593
  ];
8305
- breakStartMs = this.vmap.resolveBreakStartMs(adBreak);
8594
+ breakStartMs = this.adConfig.resolveBreakStartMs(adBreak);
8306
8595
  if (breakStartMs == null) return [
8307
8596
  2
8308
8597
  ];
@@ -8313,8 +8602,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8313
8602
  3,
8314
8603
  4
8315
8604
  ];
8316
- this.vmap.consumedVmapBreakIds.add(key);
8317
- tags = this.vmap.selectVastTagsForBreak(adBreak);
8605
+ this.adConfig.consumedVmapBreakIds.add(key);
8606
+ tags = this.adConfig.selectVastTagsForBreak(adBreak);
8318
8607
  if (!tags || tags.length === 0) return [
8319
8608
  2
8320
8609
  ];
@@ -8506,7 +8795,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8506
8795
  this.video.removeEventListener("emptied", this.emptiedHandler);
8507
8796
  delete this.emptiedHandler;
8508
8797
  }
8509
- this.vmap.destroyTracking();
8798
+ this.adConfig.destroyTracking();
8510
8799
  this.hlsEngine.destroy();
8511
8800
  (_this_adPlayer = this.adPlayer) === null || _this_adPlayer === void 0 ? void 0 : _this_adPlayer.destroy();
8512
8801
  if (this.palPlaybackStarted) {