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.cjs CHANGED
@@ -2530,22 +2530,326 @@ function initializePolyfills() {
2530
2530
  polyfillTextEncoder();
2531
2531
  polyfillPromiseFinally();
2532
2532
  }
2533
- // src/utils/vastMacros.ts
2534
- function generateCorrelator() {
2535
- if (typeof crypto !== "undefined" && crypto.getRandomValues) {
2533
+ // src/utils/vastEnvironmentSignals.ts
2534
+ var AIRY_ANDROID_APP_ID = "com.freeairytv.android";
2535
+ var AIRY_APP_NAME = "AiryTV Movies & TV";
2536
+ var AIRY_DEFAULT_CONTENT_URL = "https://live.airy.tv";
2537
+ var CTV_SESSION_STORAGE_KEY = "stormcloud.ctv.sid";
2538
+ var DEVICE_ID_STORAGE_KEYS = [
2539
+ "rdid",
2540
+ "ifa",
2541
+ "advertisingId",
2542
+ "advertising_id",
2543
+ "deviceAdvertisingId",
2544
+ "aaid",
2545
+ "adid",
2546
+ "rida",
2547
+ "tifa",
2548
+ "lgudid"
2549
+ ];
2550
+ var ANDROID_ID_TYPES = /* @__PURE__ */ new Set([
2551
+ "aaid",
2552
+ "adid"
2553
+ ]);
2554
+ function resolveVastEnvironmentSignals(isCtv) {
2555
+ var _ref, _bridgeSignals_limitAdTracking;
2556
+ var bridgeSignals = readNativeBridgeSignals();
2557
+ var deviceId = bridgeSignals.deviceId || readStoredDeviceId();
2558
+ var deviceIdType = bridgeSignals.deviceIdType || readStoredString("deviceIdType") || readStoredString("idtype") || inferDeviceIdType();
2559
+ 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;
2560
+ if (isCtv) {
2561
+ return _object_spread_props(_object_spread({
2562
+ isCtv: true,
2563
+ contentUrl: bridgeSignals.contentUrl || readStoredString("contentUrl") || AIRY_DEFAULT_CONTENT_URL,
2564
+ appId: bridgeSignals.appId || readStoredString("appId") || readStoredString("msid") || AIRY_ANDROID_APP_ID,
2565
+ appName: bridgeSignals.appName || readStoredString("appName") || readStoredString("an") || AIRY_APP_NAME,
2566
+ sessionId: getOrCreateCtvSessionId()
2567
+ }, deviceId ? {
2568
+ deviceId: deviceId
2569
+ } : {}, deviceIdType ? {
2570
+ deviceIdType: deviceIdType
2571
+ } : {}, limitAdTracking != null ? {
2572
+ limitAdTracking: limitAdTracking
2573
+ } : {}), {
2574
+ deviceTypeHint: 5
2575
+ });
2576
+ }
2577
+ return _object_spread({
2578
+ isCtv: false
2579
+ }, deviceId ? {
2580
+ deviceId: deviceId
2581
+ } : {}, deviceIdType ? {
2582
+ deviceIdType: deviceIdType
2583
+ } : {}, limitAdTracking != null ? {
2584
+ limitAdTracking: limitAdTracking
2585
+ } : {});
2586
+ }
2587
+ function inferDeviceIdType() {
2588
+ if (typeof navigator === "undefined") {
2589
+ return void 0;
2590
+ }
2591
+ var ua = navigator.userAgent;
2592
+ if (/Roku/i.test(ua)) return "rida";
2593
+ if (/Tizen|Samsung/i.test(ua)) return "tifa";
2594
+ if (/AppleTV|Apple TV/i.test(ua)) return "tvOS";
2595
+ if (/AFT|Fire TV|Amazon/i.test(ua)) return "afai";
2596
+ if (/Web0S|webOS|LG Browser|LGSTB|LGE/i.test(ua)) return "lgudid";
2597
+ if (/Android|Google TV/i.test(ua)) return "aaid";
2598
+ if (/iPhone|iPad|iPod/i.test(ua)) return "idfa";
2599
+ return void 0;
2600
+ }
2601
+ function isEquivalentDeviceIdType(tagType, runtimeType) {
2602
+ if (!tagType || !runtimeType) return false;
2603
+ var tag = tagType.toLowerCase();
2604
+ var runtime = runtimeType.toLowerCase();
2605
+ if (tag === runtime) return true;
2606
+ return ANDROID_ID_TYPES.has(tag) && ANDROID_ID_TYPES.has(runtime);
2607
+ }
2608
+ function getOrCreateCtvSessionId() {
2609
+ var existing = readStoredString(CTV_SESSION_STORAGE_KEY);
2610
+ if (existing) {
2611
+ return existing;
2612
+ }
2613
+ var sessionId = createUuid();
2614
+ try {
2615
+ var _window_localStorage;
2616
+ (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(CTV_SESSION_STORAGE_KEY, sessionId);
2617
+ } catch (unused) {}
2618
+ return sessionId;
2619
+ }
2620
+ function createUuid() {
2621
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
2622
+ return crypto.randomUUID();
2623
+ }
2624
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(char) {
2625
+ var value = Math.floor(Math.random() * 16);
2626
+ var nibble = char === "x" ? value : value & 3 | 8;
2627
+ return nibble.toString(16);
2628
+ });
2629
+ }
2630
+ function readNativeBridgeSignals() {
2631
+ if (typeof window === "undefined") {
2632
+ return {};
2633
+ }
2634
+ var candidates = [
2635
+ window.__STORMCLOUD_CTV_AD_INFO__,
2636
+ window.__STORMCLOUD_CTV__,
2637
+ window.stormcloudCtv,
2638
+ window.AiryTV,
2639
+ window.Android,
2640
+ window.webOS,
2641
+ window.tizen,
2642
+ window.amazon
2643
+ ].filter(Boolean);
2644
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2645
+ try {
2646
+ for(var _iterator = candidates[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2647
+ var source = _step.value;
2648
+ var contentUrl = readBridgeValue(source, [
2649
+ "contentUrl",
2650
+ "url",
2651
+ "videoUrl",
2652
+ "canonicalUrl"
2653
+ ]) || void 0;
2654
+ var appId = readBridgeValue(source, [
2655
+ "appId",
2656
+ "msid",
2657
+ "applicationId",
2658
+ "packageName"
2659
+ ]) || void 0;
2660
+ var appName = readBridgeValue(source, [
2661
+ "appName",
2662
+ "an",
2663
+ "applicationName"
2664
+ ]) || void 0;
2665
+ var deviceId = readBridgeValue(source, [
2666
+ "rdid",
2667
+ "ifa",
2668
+ "advertisingId",
2669
+ "adId",
2670
+ "deviceId",
2671
+ "lgudid",
2672
+ "LGUDID",
2673
+ "tifa",
2674
+ "rida",
2675
+ "afai",
2676
+ "aaid"
2677
+ ]) || void 0;
2678
+ if (!contentUrl && !deviceId && !appId && !appName) continue;
2679
+ var deviceIdType = readBridgeValue(source, [
2680
+ "idtype",
2681
+ "deviceIdType",
2682
+ "advertisingIdType",
2683
+ "idType"
2684
+ ]) || inferDeviceIdType();
2685
+ var limitAdTracking = readBridgeBoolean(source, [
2686
+ "is_lat",
2687
+ "limitAdTracking",
2688
+ "limitedAdTracking",
2689
+ "lat"
2690
+ ]);
2691
+ return _object_spread({}, contentUrl ? {
2692
+ contentUrl: contentUrl
2693
+ } : {}, appId ? {
2694
+ appId: appId
2695
+ } : {}, appName ? {
2696
+ appName: appName
2697
+ } : {}, deviceId ? {
2698
+ deviceId: deviceId
2699
+ } : {}, deviceId && deviceIdType ? {
2700
+ deviceIdType: deviceIdType
2701
+ } : {}, deviceId && limitAdTracking != null ? {
2702
+ limitAdTracking: limitAdTracking
2703
+ } : {});
2704
+ }
2705
+ } catch (err) {
2706
+ _didIteratorError = true;
2707
+ _iteratorError = err;
2708
+ } finally{
2536
2709
  try {
2537
- var _buf_, _buf_1;
2538
- var buf = new Uint32Array(2);
2539
- crypto.getRandomValues(buf);
2540
- 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);
2541
- if (value > 0) {
2542
- return String(value);
2710
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2711
+ _iterator.return();
2543
2712
  }
2544
- } catch (unused) {}
2713
+ } finally{
2714
+ if (_didIteratorError) {
2715
+ throw _iteratorError;
2716
+ }
2717
+ }
2545
2718
  }
2546
- return String(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER) + 1);
2719
+ return {};
2720
+ }
2721
+ function readBridgeValue(source, keys) {
2722
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2723
+ try {
2724
+ for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2725
+ var key = _step.value;
2726
+ var value = source === null || source === void 0 ? void 0 : source[key];
2727
+ if (typeof value === "string" && value) {
2728
+ return value;
2729
+ }
2730
+ if (typeof value === "function") {
2731
+ try {
2732
+ var result = value.call(source);
2733
+ if (typeof result === "string" && result) {
2734
+ return result;
2735
+ }
2736
+ } catch (unused) {}
2737
+ }
2738
+ }
2739
+ } catch (err) {
2740
+ _didIteratorError = true;
2741
+ _iteratorError = err;
2742
+ } finally{
2743
+ try {
2744
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2745
+ _iterator.return();
2746
+ }
2747
+ } finally{
2748
+ if (_didIteratorError) {
2749
+ throw _iteratorError;
2750
+ }
2751
+ }
2752
+ }
2753
+ return void 0;
2754
+ }
2755
+ function readBridgeBoolean(source, keys) {
2756
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2757
+ try {
2758
+ for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2759
+ var key = _step.value;
2760
+ var value = source === null || source === void 0 ? void 0 : source[key];
2761
+ var normalized = normalizeBoolean(value);
2762
+ if (normalized != null) {
2763
+ return normalized;
2764
+ }
2765
+ if (typeof value === "function") {
2766
+ try {
2767
+ var result = normalizeBoolean(value.call(source));
2768
+ if (result != null) {
2769
+ return result;
2770
+ }
2771
+ } catch (unused) {}
2772
+ }
2773
+ }
2774
+ } catch (err) {
2775
+ _didIteratorError = true;
2776
+ _iteratorError = err;
2777
+ } finally{
2778
+ try {
2779
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2780
+ _iterator.return();
2781
+ }
2782
+ } finally{
2783
+ if (_didIteratorError) {
2784
+ throw _iteratorError;
2785
+ }
2786
+ }
2787
+ }
2788
+ return void 0;
2547
2789
  }
2790
+ function readStoredDeviceId() {
2791
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2792
+ try {
2793
+ for(var _iterator = DEVICE_ID_STORAGE_KEYS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2794
+ var key = _step.value;
2795
+ var value = readStoredString(key);
2796
+ if (value) {
2797
+ return value;
2798
+ }
2799
+ }
2800
+ } catch (err) {
2801
+ _didIteratorError = true;
2802
+ _iteratorError = err;
2803
+ } finally{
2804
+ try {
2805
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2806
+ _iterator.return();
2807
+ }
2808
+ } finally{
2809
+ if (_didIteratorError) {
2810
+ throw _iteratorError;
2811
+ }
2812
+ }
2813
+ }
2814
+ return void 0;
2815
+ }
2816
+ function readStoredString(key) {
2817
+ if (typeof window === "undefined") {
2818
+ return void 0;
2819
+ }
2820
+ try {
2821
+ var _window_localStorage;
2822
+ var value = (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(key);
2823
+ return value || void 0;
2824
+ } catch (unused) {
2825
+ return void 0;
2826
+ }
2827
+ }
2828
+ function readStoredLimitAdTracking() {
2829
+ return normalizeBoolean(readStoredString("limitAdTracking") || readStoredString("limitedAdTracking") || readStoredString("is_lat"));
2830
+ }
2831
+ function normalizeBoolean(value) {
2832
+ if (typeof value === "boolean") {
2833
+ return value;
2834
+ }
2835
+ if (typeof value === "number") {
2836
+ return value === 1;
2837
+ }
2838
+ if (typeof value === "string") {
2839
+ var normalized = value.toLowerCase();
2840
+ if (normalized === "1" || normalized === "true" || normalized === "yes") {
2841
+ return true;
2842
+ }
2843
+ if (normalized === "0" || normalized === "false" || normalized === "no") {
2844
+ return false;
2845
+ }
2846
+ }
2847
+ return void 0;
2848
+ }
2849
+ // src/utils/vastMacros.ts
2548
2850
  var UNEXPANDED_MACRO_PATTERN = /^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%)$/;
2851
+ var INVALID_VAST_PARAM_KEY = /^\s|\s$/;
2852
+ var EXAMPLE_COM_URL = /example\.com/i;
2549
2853
  var CTV_UNSUPPORTED_PARAMS = [
2550
2854
  "description_url",
2551
2855
  "tfcd",
@@ -2560,14 +2864,265 @@ var CTV_UNSUPPORTED_PARAMS = [
2560
2864
  "gdpr_consent",
2561
2865
  "us_privacy"
2562
2866
  ];
2867
+ var INLINE_DEVICE_MACRO_REPLACEMENTS = [
2868
+ {
2869
+ pattern: /\[RDID\]/gi,
2870
+ getValue: function getValue(ctx) {
2871
+ return ctx.deviceId;
2872
+ }
2873
+ },
2874
+ {
2875
+ pattern: /\[IFA\]/gi,
2876
+ getValue: function getValue(ctx) {
2877
+ return ctx.deviceId;
2878
+ }
2879
+ },
2880
+ {
2881
+ pattern: /\[ADVERTISING[_-]?ID(?:ENTIFIER)?\]/gi,
2882
+ getValue: function getValue(ctx) {
2883
+ return ctx.deviceId;
2884
+ }
2885
+ },
2886
+ {
2887
+ pattern: /\[DEVICE[_-]?ID\]/gi,
2888
+ getValue: function getValue(ctx) {
2889
+ return ctx.deviceId;
2890
+ }
2891
+ },
2892
+ {
2893
+ pattern: /\[IDTYPE\]/gi,
2894
+ getValue: function getValue(ctx) {
2895
+ return ctx.deviceIdType;
2896
+ }
2897
+ },
2898
+ {
2899
+ pattern: /\{rdid\}/gi,
2900
+ getValue: function getValue(ctx) {
2901
+ return ctx.deviceId;
2902
+ }
2903
+ },
2904
+ {
2905
+ pattern: /\{device[_-]?id\}/gi,
2906
+ getValue: function getValue(ctx) {
2907
+ return ctx.deviceId;
2908
+ }
2909
+ },
2910
+ {
2911
+ pattern: /\{idtype\}/gi,
2912
+ getValue: function getValue(ctx) {
2913
+ return ctx.deviceIdType;
2914
+ }
2915
+ },
2916
+ {
2917
+ pattern: /%%ADVERTISING_IDENTIFIER_PLAIN%%/gi,
2918
+ getValue: function getValue(ctx) {
2919
+ return ctx.deviceId;
2920
+ }
2921
+ },
2922
+ {
2923
+ pattern: /%%ADVERTISING_ID_OPT_OUT%%/gi,
2924
+ getValue: function getValue(ctx) {
2925
+ return ctx.limitAdTracking != null ? ctx.limitAdTracking ? "1" : "0" : void 0;
2926
+ }
2927
+ },
2928
+ {
2929
+ pattern: /%%ADVERTISING_ID_TYPE%%/gi,
2930
+ getValue: function getValue(ctx) {
2931
+ return ctx.deviceIdType;
2932
+ }
2933
+ },
2934
+ {
2935
+ pattern: /%%ADVERTISING_ID%%/gi,
2936
+ getValue: function getValue(ctx) {
2937
+ return ctx.deviceId;
2938
+ }
2939
+ },
2940
+ {
2941
+ pattern: /%%LIMIT_AD_TRACKING%%/gi,
2942
+ getValue: function getValue(ctx) {
2943
+ return ctx.limitAdTracking != null ? ctx.limitAdTracking ? "1" : "0" : void 0;
2944
+ }
2945
+ },
2946
+ {
2947
+ pattern: /%%MSID%%/gi,
2948
+ getValue: function getValue(ctx) {
2949
+ return ctx.appId;
2950
+ }
2951
+ },
2952
+ {
2953
+ pattern: /%%APP_NAME%%/gi,
2954
+ getValue: function getValue(ctx) {
2955
+ return ctx.appName;
2956
+ }
2957
+ },
2958
+ {
2959
+ pattern: /%%SESSION_ID%%/gi,
2960
+ getValue: function getValue(ctx) {
2961
+ return ctx.sessionId;
2962
+ }
2963
+ },
2964
+ {
2965
+ pattern: /%%CORRELATOR%%/gi,
2966
+ getValue: function getValue(ctx) {
2967
+ return ctx.correlator;
2968
+ }
2969
+ }
2970
+ ];
2971
+ function isMacroPlaceholder(value) {
2972
+ if (value == null) return true;
2973
+ var trimmed = value.trim();
2974
+ if (!trimmed) return true;
2975
+ if (UNEXPANDED_MACRO_PATTERN.test(trimmed)) return true;
2976
+ return /^(unknown|null|undefined|none|n\/a|\$\{[^}]+\})$/i.test(trimmed);
2977
+ }
2978
+ function generateCorrelator() {
2979
+ if (typeof crypto !== "undefined" && crypto.getRandomValues) {
2980
+ try {
2981
+ var _buf_, _buf_1;
2982
+ var buf = new Uint32Array(2);
2983
+ crypto.getRandomValues(buf);
2984
+ 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);
2985
+ if (value > 0) {
2986
+ return String(value);
2987
+ }
2988
+ } catch (unused) {}
2989
+ }
2990
+ return String(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER) + 1);
2991
+ }
2992
+ function expandInlineMacroPlaceholders(baseUrl, ctx) {
2993
+ var url = baseUrl;
2994
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2995
+ try {
2996
+ for(var _iterator = INLINE_DEVICE_MACRO_REPLACEMENTS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2997
+ var _step_value = _step.value, pattern = _step_value.pattern, getValue = _step_value.getValue;
2998
+ var value = getValue(ctx);
2999
+ if (value != null && value !== "") {
3000
+ url = url.replace(pattern, encodeURIComponent(value));
3001
+ }
3002
+ }
3003
+ } catch (err) {
3004
+ _didIteratorError = true;
3005
+ _iteratorError = err;
3006
+ } finally{
3007
+ try {
3008
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
3009
+ _iterator.return();
3010
+ }
3011
+ } finally{
3012
+ if (_didIteratorError) {
3013
+ throw _iteratorError;
3014
+ }
3015
+ }
3016
+ }
3017
+ return url;
3018
+ }
3019
+ function applyDeviceIdentityParams(params, ctx) {
3020
+ var _ctx_deviceId, _ctx_deviceIdType;
3021
+ var runtimeId = (_ctx_deviceId = ctx.deviceId) === null || _ctx_deviceId === void 0 ? void 0 : _ctx_deviceId.trim();
3022
+ var runtimeType = ((_ctx_deviceIdType = ctx.deviceIdType) === null || _ctx_deviceIdType === void 0 ? void 0 : _ctx_deviceIdType.trim()) || inferDeviceIdType();
3023
+ var tagRdid = params.get("rdid");
3024
+ var tagType = params.get("idtype");
3025
+ var tagLat = params.get("is_lat");
3026
+ var latValue = ctx.limitAdTracking != null ? ctx.limitAdTracking ? "1" : "0" : void 0;
3027
+ if (runtimeId) {
3028
+ params.set("rdid", runtimeId);
3029
+ params.set("idtype", runtimeType || tagType || "aaid");
3030
+ params.set("is_lat", latValue !== null && latValue !== void 0 ? latValue : isMacroPlaceholder(tagLat) ? "0" : tagLat);
3031
+ return;
3032
+ }
3033
+ var tagRdidValid = Boolean(tagRdid && !isMacroPlaceholder(tagRdid));
3034
+ var tagTypeValid = Boolean(tagType && !isMacroPlaceholder(tagType));
3035
+ if (tagRdidValid && tagTypeValid && runtimeType && !isEquivalentDeviceIdType(tagType, runtimeType)) {
3036
+ params.delete("rdid");
3037
+ params.delete("idtype");
3038
+ params.delete("is_lat");
3039
+ return;
3040
+ }
3041
+ if (tagRdidValid) {
3042
+ if (isMacroPlaceholder(tagType) && runtimeType) {
3043
+ params.set("idtype", runtimeType);
3044
+ }
3045
+ if (isMacroPlaceholder(tagLat)) {
3046
+ params.set("is_lat", latValue !== null && latValue !== void 0 ? latValue : "0");
3047
+ }
3048
+ return;
3049
+ }
3050
+ params.delete("rdid");
3051
+ params.delete("idtype");
3052
+ params.delete("is_lat");
3053
+ }
3054
+ function removeBrokenAppNameOrphans(params, appName) {
3055
+ var toDelete = [];
3056
+ params.forEach(function(_value, key) {
3057
+ if (!key || INVALID_VAST_PARAM_KEY.test(key)) {
3058
+ toDelete.push(key);
3059
+ }
3060
+ });
3061
+ if (appName && appName.includes("&")) {
3062
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3063
+ try {
3064
+ for(var _iterator = appName.split("&").slice(1)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3065
+ var suffix = _step.value;
3066
+ var trimmed = suffix.trimStart();
3067
+ if (!trimmed) continue;
3068
+ toDelete.push(suffix, " ".concat(trimmed), trimmed);
3069
+ }
3070
+ } catch (err) {
3071
+ _didIteratorError = true;
3072
+ _iteratorError = err;
3073
+ } finally{
3074
+ try {
3075
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
3076
+ _iterator.return();
3077
+ }
3078
+ } finally{
3079
+ if (_didIteratorError) {
3080
+ throw _iteratorError;
3081
+ }
3082
+ }
3083
+ }
3084
+ }
3085
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
3086
+ try {
3087
+ for(var _iterator1 = new Set(toDelete)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
3088
+ var key = _step1.value;
3089
+ if (key) params.delete(key);
3090
+ }
3091
+ } catch (err) {
3092
+ _didIteratorError1 = true;
3093
+ _iteratorError1 = err;
3094
+ } finally{
3095
+ try {
3096
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
3097
+ _iterator1.return();
3098
+ }
3099
+ } finally{
3100
+ if (_didIteratorError1) {
3101
+ throw _iteratorError1;
3102
+ }
3103
+ }
3104
+ }
3105
+ }
3106
+ function normalizeVastTagUrl(raw) {
3107
+ if (!raw) return raw;
3108
+ try {
3109
+ var url = new URL(raw);
3110
+ removeBrokenAppNameOrphans(url.searchParams);
3111
+ return url.toString();
3112
+ } catch (unused) {
3113
+ return raw;
3114
+ }
3115
+ }
2563
3116
  function applyVastMacros(baseUrl, ctx) {
3117
+ var expandedUrl = expandInlineMacroPlaceholders(baseUrl, ctx);
2564
3118
  var url;
2565
3119
  try {
2566
- url = new URL(baseUrl);
3120
+ url = new URL(normalizeVastTagUrl(expandedUrl));
2567
3121
  } catch (unused) {
2568
- return replaceCorrelatorFallback(baseUrl, ctx.correlator);
3122
+ return replaceCorrelatorFallback(expandedUrl, ctx.correlator);
2569
3123
  }
2570
3124
  var params = url.searchParams;
3125
+ removeBrokenAppNameOrphans(params, ctx.appName);
2571
3126
  params.set("correlator", ctx.correlator);
2572
3127
  if (ctx.isCtv) {
2573
3128
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
@@ -2605,6 +3160,12 @@ function applyVastMacros(baseUrl, ctx) {
2605
3160
  if (!ctx.isCtv) {
2606
3161
  params.set("description_url", requestUrl);
2607
3162
  }
3163
+ } else {
3164
+ var existingUrl = params.get("url") || "";
3165
+ if (EXAMPLE_COM_URL.test(existingUrl)) {
3166
+ params.delete("url");
3167
+ params.delete("description_url");
3168
+ }
2608
3169
  }
2609
3170
  if (ctx.adWillPlayMuted != null) {
2610
3171
  params.set("vpmute", ctx.adWillPlayMuted ? "1" : "0");
@@ -2616,6 +3177,7 @@ function applyVastMacros(baseUrl, ctx) {
2616
3177
  params.set("msid", ctx.appId);
2617
3178
  }
2618
3179
  if (ctx.appName) {
3180
+ removeBrokenAppNameOrphans(params, ctx.appName);
2619
3181
  params.set("an", ctx.appName);
2620
3182
  }
2621
3183
  if (ctx.sessionId) {
@@ -2626,15 +3188,7 @@ function applyVastMacros(baseUrl, ctx) {
2626
3188
  } else if (ctx.isCtv) {
2627
3189
  params.set("dth", "5");
2628
3190
  }
2629
- if (ctx.deviceId && ctx.deviceIdType) {
2630
- params.set("rdid", ctx.deviceId);
2631
- params.set("idtype", ctx.deviceIdType);
2632
- params.set("is_lat", ctx.limitAdTracking ? "1" : "0");
2633
- } else {
2634
- params.delete("rdid");
2635
- params.delete("idtype");
2636
- params.delete("is_lat");
2637
- }
3191
+ applyDeviceIdentityParams(params, ctx);
2638
3192
  if (!ctx.isCtv) {
2639
3193
  var consent = ctx.consent;
2640
3194
  if ((consent === null || consent === void 0 ? void 0 : consent.gdpr) != null) {
@@ -2652,7 +3206,7 @@ function applyVastMacros(baseUrl, ctx) {
2652
3206
  }
2653
3207
  var staleKeys = [];
2654
3208
  params.forEach(function(value, key) {
2655
- if (UNEXPANDED_MACRO_PATTERN.test(value)) {
3209
+ if (isMacroPlaceholder(value)) {
2656
3210
  staleKeys.push(key);
2657
3211
  }
2658
3212
  });
@@ -2676,6 +3230,7 @@ function applyVastMacros(baseUrl, ctx) {
2676
3230
  }
2677
3231
  }
2678
3232
  }
3233
+ removeBrokenAppNameOrphans(params, ctx.appName);
2679
3234
  return url.toString();
2680
3235
  }
2681
3236
  function replaceCorrelatorFallback(baseUrl, correlator) {
@@ -3949,276 +4504,10 @@ var Scte35CueManager = /*#__PURE__*/ function() {
3949
4504
  ]);
3950
4505
  return Scte35CueManager;
3951
4506
  }();
3952
- // src/utils/ctvVastSignals.ts
3953
- var AIRY_ANDROID_APP_ID = "com.freeairytv.android";
3954
- var AIRY_APP_NAME = "AiryTV Movies & TV";
3955
- var AIRY_DEFAULT_CONTENT_URL = "https://live.airy.tv";
3956
- var CTV_SESSION_STORAGE_KEY = "stormcloud.ctv.sid";
3957
- var DEVICE_ID_STORAGE_KEYS = [
3958
- "rdid",
3959
- "ifa",
3960
- "advertisingId",
3961
- "advertising_id",
3962
- "deviceAdvertisingId",
3963
- "aaid",
3964
- "adid",
3965
- "rida",
3966
- "tifa"
3967
- ];
3968
- function resolveCtvVastSignals() {
3969
- var _ref, _bridgeSignals_limitAdTracking;
3970
- var bridgeSignals = readNativeBridgeSignals();
3971
- var deviceId = bridgeSignals.deviceId || readStoredDeviceId();
3972
- var deviceIdType = bridgeSignals.deviceIdType || readStoredString("deviceIdType") || inferDeviceIdType();
3973
- var contentUrl = bridgeSignals.contentUrl || readStoredString("contentUrl") || AIRY_DEFAULT_CONTENT_URL;
3974
- return _object_spread_props(_object_spread({
3975
- contentUrl: contentUrl,
3976
- appId: AIRY_ANDROID_APP_ID,
3977
- appName: AIRY_APP_NAME,
3978
- sessionId: getOrCreateCtvSessionId()
3979
- }, deviceId ? {
3980
- deviceId: deviceId
3981
- } : {}, deviceId && deviceIdType ? {
3982
- deviceIdType: deviceIdType
3983
- } : {}, deviceId ? {
3984
- limitAdTracking: (_ref = (_bridgeSignals_limitAdTracking = bridgeSignals.limitAdTracking) !== null && _bridgeSignals_limitAdTracking !== void 0 ? _bridgeSignals_limitAdTracking : readStoredLimitAdTracking()) !== null && _ref !== void 0 ? _ref : false
3985
- } : {}), {
3986
- deviceTypeHint: 5
3987
- });
3988
- }
3989
- function getOrCreateCtvSessionId() {
3990
- var existing = readStoredString(CTV_SESSION_STORAGE_KEY);
3991
- if (existing) {
3992
- return existing;
3993
- }
3994
- var sessionId = createUuid();
3995
- try {
3996
- var _window_localStorage;
3997
- (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(CTV_SESSION_STORAGE_KEY, sessionId);
3998
- } catch (unused) {}
3999
- return sessionId;
4000
- }
4001
- function createUuid() {
4002
- if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
4003
- return crypto.randomUUID();
4004
- }
4005
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(char) {
4006
- var value = Math.floor(Math.random() * 16);
4007
- var nibble = char === "x" ? value : value & 3 | 8;
4008
- return nibble.toString(16);
4009
- });
4010
- }
4011
- function readNativeBridgeSignals() {
4012
- if (typeof window === "undefined") {
4013
- return {};
4014
- }
4015
- var candidates = [
4016
- window.__STORMCLOUD_CTV_AD_INFO__,
4017
- window.__STORMCLOUD_CTV__,
4018
- window.stormcloudCtv,
4019
- window.AiryTV,
4020
- window.Android
4021
- ].filter(Boolean);
4022
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
4023
- try {
4024
- for(var _iterator = candidates[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
4025
- var source = _step.value;
4026
- var contentUrl = readBridgeValue(source, [
4027
- "contentUrl",
4028
- "url",
4029
- "videoUrl",
4030
- "canonicalUrl"
4031
- ]) || void 0;
4032
- var deviceId = readBridgeValue(source, [
4033
- "rdid",
4034
- "ifa",
4035
- "advertisingId",
4036
- "adId",
4037
- "deviceId"
4038
- ]) || void 0;
4039
- if (!contentUrl && !deviceId) continue;
4040
- var deviceIdType = readBridgeValue(source, [
4041
- "idtype",
4042
- "deviceIdType",
4043
- "advertisingIdType"
4044
- ]) || inferDeviceIdType();
4045
- var limitAdTracking = readBridgeBoolean(source, [
4046
- "is_lat",
4047
- "limitAdTracking",
4048
- "limitedAdTracking",
4049
- "lat"
4050
- ]);
4051
- return _object_spread({}, contentUrl ? {
4052
- contentUrl: contentUrl
4053
- } : {}, deviceId ? {
4054
- deviceId: deviceId
4055
- } : {}, deviceId && deviceIdType ? {
4056
- deviceIdType: deviceIdType
4057
- } : {}, deviceId && limitAdTracking != null ? {
4058
- limitAdTracking: limitAdTracking
4059
- } : {});
4060
- }
4061
- } catch (err) {
4062
- _didIteratorError = true;
4063
- _iteratorError = err;
4064
- } finally{
4065
- try {
4066
- if (!_iteratorNormalCompletion && _iterator.return != null) {
4067
- _iterator.return();
4068
- }
4069
- } finally{
4070
- if (_didIteratorError) {
4071
- throw _iteratorError;
4072
- }
4073
- }
4074
- }
4075
- return {};
4076
- }
4077
- function readBridgeValue(source, keys) {
4078
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
4079
- try {
4080
- for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
4081
- var key = _step.value;
4082
- var value = source === null || source === void 0 ? void 0 : source[key];
4083
- if (typeof value === "string" && value) {
4084
- return value;
4085
- }
4086
- if (typeof value === "function") {
4087
- try {
4088
- var result = value.call(source);
4089
- if (typeof result === "string" && result) {
4090
- return result;
4091
- }
4092
- } catch (unused) {}
4093
- }
4094
- }
4095
- } catch (err) {
4096
- _didIteratorError = true;
4097
- _iteratorError = err;
4098
- } finally{
4099
- try {
4100
- if (!_iteratorNormalCompletion && _iterator.return != null) {
4101
- _iterator.return();
4102
- }
4103
- } finally{
4104
- if (_didIteratorError) {
4105
- throw _iteratorError;
4106
- }
4107
- }
4108
- }
4109
- return void 0;
4110
- }
4111
- function readBridgeBoolean(source, keys) {
4112
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
4113
- try {
4114
- for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
4115
- var key = _step.value;
4116
- var value = source === null || source === void 0 ? void 0 : source[key];
4117
- var normalized = normalizeBoolean(value);
4118
- if (normalized != null) {
4119
- return normalized;
4120
- }
4121
- if (typeof value === "function") {
4122
- try {
4123
- var result = normalizeBoolean(value.call(source));
4124
- if (result != null) {
4125
- return result;
4126
- }
4127
- } catch (unused) {}
4128
- }
4129
- }
4130
- } catch (err) {
4131
- _didIteratorError = true;
4132
- _iteratorError = err;
4133
- } finally{
4134
- try {
4135
- if (!_iteratorNormalCompletion && _iterator.return != null) {
4136
- _iterator.return();
4137
- }
4138
- } finally{
4139
- if (_didIteratorError) {
4140
- throw _iteratorError;
4141
- }
4142
- }
4143
- }
4144
- return void 0;
4145
- }
4146
- function readStoredDeviceId() {
4147
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
4148
- try {
4149
- for(var _iterator = DEVICE_ID_STORAGE_KEYS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
4150
- var key = _step.value;
4151
- var value = readStoredString(key);
4152
- if (value) {
4153
- return value;
4154
- }
4155
- }
4156
- } catch (err) {
4157
- _didIteratorError = true;
4158
- _iteratorError = err;
4159
- } finally{
4160
- try {
4161
- if (!_iteratorNormalCompletion && _iterator.return != null) {
4162
- _iterator.return();
4163
- }
4164
- } finally{
4165
- if (_didIteratorError) {
4166
- throw _iteratorError;
4167
- }
4168
- }
4169
- }
4170
- return void 0;
4171
- }
4172
- function readStoredString(key) {
4173
- if (typeof window === "undefined") {
4174
- return void 0;
4175
- }
4176
- try {
4177
- var _window_localStorage;
4178
- var value = (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(key);
4179
- return value || void 0;
4180
- } catch (unused) {
4181
- return void 0;
4182
- }
4183
- }
4184
- function readStoredLimitAdTracking() {
4185
- return normalizeBoolean(readStoredString("limitAdTracking") || readStoredString("limitedAdTracking") || readStoredString("is_lat"));
4186
- }
4187
- function normalizeBoolean(value) {
4188
- if (typeof value === "boolean") {
4189
- return value;
4190
- }
4191
- if (typeof value === "number") {
4192
- return value === 1;
4193
- }
4194
- if (typeof value === "string") {
4195
- var normalized = value.toLowerCase();
4196
- if (normalized === "1" || normalized === "true" || normalized === "yes") {
4197
- return true;
4198
- }
4199
- if (normalized === "0" || normalized === "false" || normalized === "no") {
4200
- return false;
4201
- }
4202
- }
4203
- return void 0;
4204
- }
4205
- function inferDeviceIdType() {
4206
- if (typeof navigator === "undefined") {
4207
- return void 0;
4208
- }
4209
- var ua = navigator.userAgent;
4210
- if (/Roku/i.test(ua)) return "rida";
4211
- if (/Tizen|Samsung/i.test(ua)) return "tifa";
4212
- if (/AppleTV/i.test(ua)) return "tvOS";
4213
- if (/AFT|Fire TV|Amazon/i.test(ua)) return "afai";
4214
- if (/Web0S|webOS|LG/i.test(ua)) return "lgudid";
4215
- if (/Android|Google TV/i.test(ua)) return "aaid";
4216
- return void 0;
4217
- }
4218
- // src/player/VmapManager.ts
4219
- var VmapManager = /*#__PURE__*/ function() {
4220
- function VmapManager(config, video) {
4221
- _class_call_check(this, VmapManager);
4507
+ // src/player/AdConfigManager.ts
4508
+ var AdConfigManager = /*#__PURE__*/ function() {
4509
+ function AdConfigManager(config, video) {
4510
+ _class_call_check(this, AdConfigManager);
4222
4511
  this.vmapBreaks = [];
4223
4512
  this.consumedVmapBreakIds = /* @__PURE__ */ new Set();
4224
4513
  this.streamCorrelator = generateCorrelator();
@@ -4230,7 +4519,7 @@ var VmapManager = /*#__PURE__*/ function() {
4230
4519
  this.config = config;
4231
4520
  this.video = video;
4232
4521
  }
4233
- _create_class(VmapManager, [
4522
+ _create_class(AdConfigManager, [
4234
4523
  {
4235
4524
  key: "debug",
4236
4525
  get: function get() {
@@ -4292,7 +4581,7 @@ var VmapManager = /*#__PURE__*/ function() {
4292
4581
  ];
4293
4582
  }
4294
4583
  if (this.config.vastTagUrl) {
4295
- this.apiVastTagUrl = this.config.vastTagUrl;
4584
+ this.apiVastTagUrl = normalizeVastTagUrl(this.config.vastTagUrl);
4296
4585
  if (this.debug) {
4297
4586
  console.log("[StormcloudVideoPlayer] Using custom VAST tag URL:", this.apiVastTagUrl);
4298
4587
  }
@@ -4332,7 +4621,7 @@ var VmapManager = /*#__PURE__*/ function() {
4332
4621
  data = _state.sent();
4333
4622
  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;
4334
4623
  if (imaPayload) {
4335
- this.apiVastTagUrl = decodeURIComponent(imaPayload);
4624
+ this.apiVastTagUrl = normalizeVastTagUrl(imaPayload);
4336
4625
  if (this.debug) {
4337
4626
  console.log("[StormcloudVideoPlayer] Extracted VAST tag URL from /ads/web:", this.apiVastTagUrl);
4338
4627
  }
@@ -4647,24 +4936,24 @@ var VmapManager = /*#__PURE__*/ function() {
4647
4936
  for(var i = 0; i < count; i++){
4648
4937
  this.adRequestPositionInBreak++;
4649
4938
  var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
4650
- var ctvSignals = this.config.ctvAdRequest ? resolveCtvVastSignals() : void 0;
4939
+ var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest);
4651
4940
  var urlWithMacros = applyVastMacros(baseUrl, {
4652
4941
  correlator: generateCorrelator(),
4653
4942
  streamCorrelator: this.streamCorrelator,
4654
4943
  pod: this.podCounter > 0 ? this.podCounter : void 0,
4655
4944
  adPosition: this.adRequestPositionInBreak,
4656
- isCtv: this.config.ctvAdRequest,
4657
- contentUrl: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.contentUrl,
4658
- pageUrl: !this.config.ctvAdRequest && typeof window !== "undefined" ? window.location.href : void 0,
4945
+ isCtv: envSignals.isCtv,
4946
+ contentUrl: envSignals.contentUrl,
4947
+ pageUrl: !envSignals.isCtv && typeof window !== "undefined" ? window.location.href : void 0,
4659
4948
  adWillPlayMuted: adWillPlayMuted,
4660
4949
  adWillAutoPlay: !!this.config.autoplay,
4661
- appId: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.appId,
4662
- appName: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.appName,
4663
- sessionId: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.sessionId,
4664
- deviceId: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.deviceId,
4665
- deviceIdType: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.deviceIdType,
4666
- limitAdTracking: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.limitAdTracking,
4667
- deviceTypeHint: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.deviceTypeHint,
4950
+ appId: envSignals.appId,
4951
+ appName: envSignals.appName,
4952
+ sessionId: envSignals.sessionId,
4953
+ deviceId: envSignals.deviceId,
4954
+ deviceIdType: envSignals.deviceIdType,
4955
+ limitAdTracking: envSignals.limitAdTracking,
4956
+ deviceTypeHint: envSignals.deviceTypeHint,
4668
4957
  adTest: this.config.adTest,
4669
4958
  consent: this.consentSignals
4670
4959
  });
@@ -4717,7 +5006,7 @@ var VmapManager = /*#__PURE__*/ function() {
4717
5006
  }
4718
5007
  }
4719
5008
  ]);
4720
- return VmapManager;
5009
+ return AdConfigManager;
4721
5010
  }();
4722
5011
  // src/player/AdTimingService.ts
4723
5012
  var AdTimingService = /*#__PURE__*/ function() {
@@ -6444,7 +6733,7 @@ function resizePlayer(video, adPlayer, debug) {
6444
6733
  }
6445
6734
  // src/player/AdBreakOrchestrator.ts
6446
6735
  var AdBreakOrchestrator = /*#__PURE__*/ function() {
6447
- function AdBreakOrchestrator(host, timing, preloadPool, vmap, cueManager, placeholder) {
6736
+ function AdBreakOrchestrator(host, timing, preloadPool, adConfig, cueManager, placeholder) {
6448
6737
  _class_call_check(this, AdBreakOrchestrator);
6449
6738
  this.inAdBreak = false;
6450
6739
  this.showAds = false;
@@ -6459,7 +6748,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
6459
6748
  this.host = host;
6460
6749
  this.timing = timing;
6461
6750
  this.preloadPool = preloadPool;
6462
- this.vmap = vmap;
6751
+ this.adConfig = adConfig;
6463
6752
  this.cueManager = cueManager;
6464
6753
  this.placeholder = placeholder;
6465
6754
  }
@@ -6625,7 +6914,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
6625
6914
  }
6626
6915
  this.pendingAdBreak = null;
6627
6916
  this.cueManager.pendingScte35CueKey = void 0;
6628
- this.vmap.podAssignedByPrefetch = false;
6917
+ this.adConfig.podAssignedByPrefetch = false;
6629
6918
  }
6630
6919
  },
6631
6920
  {
@@ -6639,15 +6928,15 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
6639
6928
  return _ts_generator(this, function(_state) {
6640
6929
  switch(_state.label){
6641
6930
  case 0:
6642
- scheduled = this.vmap.findCurrentOrNextBreak(this.host.video.currentTime * 1e3);
6931
+ scheduled = this.adConfig.findCurrentOrNextBreak(this.host.video.currentTime * 1e3);
6643
6932
  if (scheduled) {
6644
- this.vmap.consumedVmapBreakIds.add(this.vmap.getAdBreakKey(scheduled));
6933
+ this.adConfig.consumedVmapBreakIds.add(this.adConfig.getAdBreakKey(scheduled));
6645
6934
  }
6646
- tags = this.vmap.selectVastTagsForBreak(scheduled);
6935
+ tags = this.adConfig.selectVastTagsForBreak(scheduled);
6647
6936
  if (tags && tags.length > 0 && tags[0]) {
6648
6937
  baseVastUrl = tags[0];
6649
- } else if (this.vmap.apiVastTagUrl) {
6650
- baseVastUrl = this.vmap.apiVastTagUrl;
6938
+ } else if (this.adConfig.apiVastTagUrl) {
6939
+ baseVastUrl = this.adConfig.apiVastTagUrl;
6651
6940
  } else {
6652
6941
  this.clearPendingAdBreak();
6653
6942
  return [
@@ -6665,10 +6954,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
6665
6954
  this.continuousFetchingActive = true;
6666
6955
  this.isShowingPlaceholder = false;
6667
6956
  this.timing.totalAdRequestsInBreak = 0;
6668
- if (this.vmap.podAssignedByPrefetch) {
6669
- this.vmap.podAssignedByPrefetch = false;
6957
+ if (this.adConfig.podAssignedByPrefetch) {
6958
+ this.adConfig.podAssignedByPrefetch = false;
6670
6959
  } else {
6671
- this.vmap.beginNewAdPod();
6960
+ this.adConfig.beginNewAdPod();
6672
6961
  }
6673
6962
  currentMuted = this.host.video.muted;
6674
6963
  currentVolume = this.host.video.volume;
@@ -7940,7 +8229,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7940
8229
  return _this.adBreak.inAdBreak;
7941
8230
  }
7942
8231
  });
7943
- this.vmap = new VmapManager(this.config, this.video);
8232
+ this.adConfig = new AdConfigManager(this.config, this.video);
7944
8233
  this.timing = new AdTimingService(this.config, this.video, {
7945
8234
  onAdStopTimerFired: function onAdStopTimerFired() {
7946
8235
  return _this.onAdStopTimerFired();
@@ -8020,7 +8309,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8020
8309
  generateVastUrls: function generateVastUrls(base, count) {
8021
8310
  return _this.generateVastUrls(base, count);
8022
8311
  }
8023
- }, this.timing, this.preloadPool, this.vmap, this.cueManager, this.placeholder);
8312
+ }, this.timing, this.preloadPool, this.adConfig, this.cueManager, this.placeholder);
8024
8313
  }
8025
8314
  _create_class(StormcloudVideoPlayer, [
8026
8315
  {
@@ -8048,7 +8337,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8048
8337
  {
8049
8338
  key: "generateVastUrls",
8050
8339
  value: function generateVastUrls(baseUrl, count) {
8051
- return this.vmap.generateVastUrlsWithCorrelators(baseUrl, count, this.adPlayer, this.palNonce, this.adBreak.inAdBreak);
8340
+ return this.adConfig.generateVastUrlsWithCorrelators(baseUrl, count, this.adPlayer, this.palNonce, this.adBreak.inAdBreak);
8052
8341
  }
8053
8342
  },
8054
8343
  {
@@ -8076,7 +8365,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8076
8365
  ]);
8077
8366
  return [
8078
8367
  4,
8079
- this.vmap.fetchAdConfiguration()
8368
+ this.adConfig.fetchAdConfiguration()
8080
8369
  ];
8081
8370
  case 2:
8082
8371
  _state.sent();
@@ -8103,9 +8392,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8103
8392
  continuousPlayback: (_this_config_lowLatencyMode = this.config.lowLatencyMode) !== null && _this_config_lowLatencyMode !== void 0 ? _this_config_lowLatencyMode : false
8104
8393
  }).catch(function() {});
8105
8394
  fetchConsentSignals().then(function(signals) {
8106
- _this.vmap.consentSignals = signals;
8395
+ _this.adConfig.consentSignals = signals;
8107
8396
  }).catch(function() {});
8108
- this.vmap.initializeTracking();
8397
+ this.adConfig.initializeTracking();
8109
8398
  if (!this.hlsEngine.shouldUseNativeHls(function() {
8110
8399
  return _this.getStreamType();
8111
8400
  })) return [
@@ -8140,14 +8429,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8140
8429
  return _async_to_generator(function() {
8141
8430
  var prerollKey, adBehavior;
8142
8431
  return _ts_generator(this, function(_state) {
8143
- if (!this.vmap.isVmapEnabled() && !isLive && this.vmap.vmapBreaks.length === 0 && this.vmap.apiVastTagUrl) {
8432
+ if (!this.adConfig.isVmapEnabled() && !isLive && this.adConfig.vmapBreaks.length === 0 && this.adConfig.apiVastTagUrl) {
8144
8433
  prerollKey = "synthetic-vod-preroll";
8145
- if (!this.vmap.consumedVmapBreakIds.has(prerollKey)) {
8146
- this.vmap.vmapBreaks = [
8434
+ if (!this.adConfig.consumedVmapBreakIds.has(prerollKey)) {
8435
+ this.adConfig.vmapBreaks = [
8147
8436
  {
8148
8437
  id: prerollKey,
8149
8438
  startTimeMs: 0,
8150
- vastTagUrl: this.vmap.apiVastTagUrl
8439
+ vastTagUrl: this.adConfig.apiVastTagUrl
8151
8440
  }
8152
8441
  ];
8153
8442
  if (this.debug) {
@@ -8414,19 +8703,19 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8414
8703
  key: "startAdPrefetch",
8415
8704
  value: function startAdPrefetch(marker, fragmentSn, cueKey) {
8416
8705
  if (this.adBreak.pendingAdBreak || this.adBreak.inAdBreak) return;
8417
- var scheduled = this.vmap.findCurrentOrNextBreak(this.video.currentTime * 1e3);
8418
- var tags = this.vmap.selectVastTagsForBreak(scheduled);
8706
+ var scheduled = this.adConfig.findCurrentOrNextBreak(this.video.currentTime * 1e3);
8707
+ var tags = this.adConfig.selectVastTagsForBreak(scheduled);
8419
8708
  var baseVastUrl;
8420
8709
  if (tags && tags.length > 0 && tags[0]) {
8421
8710
  baseVastUrl = tags[0];
8422
- } else if (this.vmap.apiVastTagUrl) {
8423
- baseVastUrl = this.vmap.apiVastTagUrl;
8711
+ } else if (this.adConfig.apiVastTagUrl) {
8712
+ baseVastUrl = this.adConfig.apiVastTagUrl;
8424
8713
  } else {
8425
8714
  if (this.debug) console.warn("[StormcloudVideoPlayer] No VAST URL available for prefetch");
8426
8715
  return;
8427
8716
  }
8428
- this.vmap.beginNewAdPod();
8429
- this.vmap.podAssignedByPrefetch = true;
8717
+ this.adConfig.beginNewAdPod();
8718
+ this.adConfig.podAssignedByPrefetch = true;
8430
8719
  var generatedUrls = this.generateVastUrls(baseVastUrl, 1);
8431
8720
  this.adBreak.pendingAdBreak = _object_spread_props(_object_spread({
8432
8721
  marker: marker
@@ -8461,10 +8750,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8461
8750
  key: "onTimeUpdate",
8462
8751
  value: function onTimeUpdate(currentTimeSec) {
8463
8752
  var _this = this;
8464
- if (!this.vmap.isVmapEnabled() || this.vmap.vmapBreaks.length === 0) return;
8753
+ if (!this.adConfig.isVmapEnabled() || this.adConfig.vmapBreaks.length === 0) return;
8465
8754
  if (this.adPlayer.isAdPlaying() || this.adBreak.inAdBreak) return;
8466
8755
  var nowMs = currentTimeSec * 1e3;
8467
- var breakToPlay = this.vmap.findBreakForTime(nowMs);
8756
+ var breakToPlay = this.adConfig.findBreakForTime(nowMs);
8468
8757
  if (breakToPlay) {
8469
8758
  void this.handleVmapAdBreak(breakToPlay, nowMs).catch(function(error) {
8470
8759
  if (_this.debug) {
@@ -8478,11 +8767,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8478
8767
  key: "onVideoEnded",
8479
8768
  value: function onVideoEnded() {
8480
8769
  var _this = this;
8481
- if (!this.vmap.isVmapEnabled() || this.vmap.vmapBreaks.length === 0) return;
8770
+ if (!this.adConfig.isVmapEnabled() || this.adConfig.vmapBreaks.length === 0) return;
8482
8771
  if (this.adPlayer.isAdPlaying() || this.adBreak.inAdBreak) return;
8483
8772
  var durationMs = Number.isFinite(this.video.duration) ? Math.floor(this.video.duration * 1e3) : 0;
8484
- var postroll = this.vmap.vmapBreaks.find(function(b) {
8485
- return b.startTimeMs === -1 && !_this.vmap.consumedVmapBreakIds.has(_this.vmap.getAdBreakKey(b));
8773
+ var postroll = this.adConfig.vmapBreaks.find(function(b) {
8774
+ return b.startTimeMs === -1 && !_this.adConfig.consumedVmapBreakIds.has(_this.adConfig.getAdBreakKey(b));
8486
8775
  });
8487
8776
  if (postroll) {
8488
8777
  void this.handleVmapAdBreak(postroll, durationMs).catch(function(error) {
@@ -8501,11 +8790,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8501
8790
  return _ts_generator(this, function(_state) {
8502
8791
  switch(_state.label){
8503
8792
  case 0:
8504
- key = this.vmap.getAdBreakKey(adBreak);
8505
- if (this.vmap.consumedVmapBreakIds.has(key)) return [
8793
+ key = this.adConfig.getAdBreakKey(adBreak);
8794
+ if (this.adConfig.consumedVmapBreakIds.has(key)) return [
8506
8795
  2
8507
8796
  ];
8508
- breakStartMs = this.vmap.resolveBreakStartMs(adBreak);
8797
+ breakStartMs = this.adConfig.resolveBreakStartMs(adBreak);
8509
8798
  if (breakStartMs == null) return [
8510
8799
  2
8511
8800
  ];
@@ -8516,8 +8805,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8516
8805
  3,
8517
8806
  4
8518
8807
  ];
8519
- this.vmap.consumedVmapBreakIds.add(key);
8520
- tags = this.vmap.selectVastTagsForBreak(adBreak);
8808
+ this.adConfig.consumedVmapBreakIds.add(key);
8809
+ tags = this.adConfig.selectVastTagsForBreak(adBreak);
8521
8810
  if (!tags || tags.length === 0) return [
8522
8811
  2
8523
8812
  ];
@@ -8709,7 +8998,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8709
8998
  this.video.removeEventListener("emptied", this.emptiedHandler);
8710
8999
  delete this.emptiedHandler;
8711
9000
  }
8712
- this.vmap.destroyTracking();
9001
+ this.adConfig.destroyTracking();
8713
9002
  this.hlsEngine.destroy();
8714
9003
  (_this_adPlayer = this.adPlayer) === null || _this_adPlayer === void 0 ? void 0 : _this_adPlayer.destroy();
8715
9004
  if (this.palPlaybackStarted) {