stormcloud-video-player 0.8.26 → 0.8.28

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.
@@ -1948,38 +1948,108 @@ function getOrCreateStoredUuid(storageKey) {
1948
1948
  if (typeof window === "undefined") {
1949
1949
  return void 0;
1950
1950
  }
1951
- var existing = readStoredString(storageKey);
1951
+ var existing = readPersistentId(storageKey);
1952
1952
  if (existing) {
1953
+ writePersistentId(storageKey, existing);
1953
1954
  return existing;
1954
1955
  }
1955
1956
  var id = createUuid();
1956
- try {
1957
- var _window_localStorage;
1958
- (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(storageKey, id);
1959
- } catch (unused) {}
1957
+ writePersistentId(storageKey, id);
1960
1958
  return id;
1961
1959
  }
1962
1960
  function getOrCreateCtvSessionId() {
1963
- var existing = readStoredString(CTV_SESSION_STORAGE_KEY);
1961
+ var existing = readPersistentId(CTV_SESSION_STORAGE_KEY);
1964
1962
  if (existing) {
1963
+ writePersistentId(CTV_SESSION_STORAGE_KEY, existing);
1965
1964
  return existing;
1966
1965
  }
1967
1966
  var sessionId = createUuid();
1967
+ writePersistentId(CTV_SESSION_STORAGE_KEY, sessionId);
1968
+ return sessionId;
1969
+ }
1970
+ function readPersistentId(storageKey) {
1971
+ return readStoredString(storageKey) || readCookie(storageKey);
1972
+ }
1973
+ function writePersistentId(storageKey, value) {
1968
1974
  try {
1969
1975
  var _window_localStorage;
1970
- (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(CTV_SESSION_STORAGE_KEY, sessionId);
1976
+ (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(storageKey, value);
1977
+ } catch (unused) {}
1978
+ writeCookie(storageKey, value);
1979
+ }
1980
+ var PERSISTENT_ID_COOKIE_MAX_AGE = 60 * 60 * 24 * 365 * 5;
1981
+ function readCookie(name) {
1982
+ if (typeof document === "undefined") {
1983
+ return void 0;
1984
+ }
1985
+ try {
1986
+ var prefix = encodeURIComponent(name) + "=";
1987
+ var parts = document.cookie ? document.cookie.split(";") : [];
1988
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1989
+ try {
1990
+ for(var _iterator = parts[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1991
+ var part = _step.value;
1992
+ var entry = part.trim();
1993
+ if (entry.startsWith(prefix)) {
1994
+ return decodeURIComponent(entry.slice(prefix.length)) || void 0;
1995
+ }
1996
+ }
1997
+ } catch (err) {
1998
+ _didIteratorError = true;
1999
+ _iteratorError = err;
2000
+ } finally{
2001
+ try {
2002
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2003
+ _iterator.return();
2004
+ }
2005
+ } finally{
2006
+ if (_didIteratorError) {
2007
+ throw _iteratorError;
2008
+ }
2009
+ }
2010
+ }
2011
+ } catch (unused) {}
2012
+ return void 0;
2013
+ }
2014
+ function writeCookie(name, value) {
2015
+ if (typeof document === "undefined") {
2016
+ return;
2017
+ }
2018
+ try {
2019
+ document.cookie = encodeURIComponent(name) + "=" + encodeURIComponent(value) + ";path=/;max-age=" + PERSISTENT_ID_COOKIE_MAX_AGE + ";SameSite=Lax";
1971
2020
  } catch (unused) {}
1972
- return sessionId;
1973
2021
  }
1974
2022
  function createUuid() {
2023
+ var _bytes_, _bytes_1;
1975
2024
  if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
1976
2025
  return crypto.randomUUID();
1977
2026
  }
1978
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(char) {
1979
- var value = Math.floor(Math.random() * 16);
1980
- var nibble = char === "x" ? value : value & 3 | 8;
1981
- return nibble.toString(16);
1982
- });
2027
+ var bytes = new Uint8Array(16);
2028
+ if (typeof crypto !== "undefined" && typeof crypto.getRandomValues === "function") {
2029
+ crypto.getRandomValues(bytes);
2030
+ } else {
2031
+ var seed = Date.now() ^ Math.floor(performanceNow() * 1e3);
2032
+ for(var i = 0; i < 16; i++){
2033
+ seed = seed * 1103515245 + 12345 & 2147483647;
2034
+ bytes[i] = (seed ^ Math.floor(Math.random() * 256)) & 255;
2035
+ }
2036
+ }
2037
+ bytes[6] = ((_bytes_ = bytes[6]) !== null && _bytes_ !== void 0 ? _bytes_ : 0) & 15 | 64;
2038
+ bytes[8] = ((_bytes_1 = bytes[8]) !== null && _bytes_1 !== void 0 ? _bytes_1 : 0) & 63 | 128;
2039
+ var hex = "";
2040
+ for(var i1 = 0; i1 < 16; i1++){
2041
+ var _bytes_i;
2042
+ hex += ((_bytes_i = bytes[i1]) !== null && _bytes_i !== void 0 ? _bytes_i : 0).toString(16).padStart(2, "0");
2043
+ }
2044
+ return hex.slice(0, 8) + "-" + hex.slice(8, 12) + "-" + hex.slice(12, 16) + "-" + hex.slice(16, 20) + "-" + hex.slice(20, 32);
2045
+ }
2046
+ function performanceNow() {
2047
+ try {
2048
+ if (typeof performance !== "undefined" && typeof performance.now === "function") {
2049
+ return performance.now();
2050
+ }
2051
+ } catch (unused) {}
2052
+ return 0;
1983
2053
  }
1984
2054
  function readPlatformNativeDeviceId() {
1985
2055
  if (typeof window === "undefined") return {};
@@ -4747,6 +4817,7 @@ var AdConfigManager = /*#__PURE__*/ function() {
4747
4817
  this.vmapBreaks = [];
4748
4818
  this.consumedVmapBreakIds = /* @__PURE__ */ new Set();
4749
4819
  this.streamCorrelator = generateCorrelator();
4820
+ this.viewCorrelator = generateCorrelator();
4750
4821
  this.consentSignals = {};
4751
4822
  this.podCounter = 0;
4752
4823
  this.podAssignedByPrefetch = false;
@@ -5182,7 +5253,7 @@ var AdConfigManager = /*#__PURE__*/ function() {
5182
5253
  var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
5183
5254
  var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest);
5184
5255
  var urlWithMacros = applyVastMacros(baseUrl, {
5185
- correlator: generateCorrelator(),
5256
+ correlator: this.viewCorrelator,
5186
5257
  streamCorrelator: this.streamCorrelator,
5187
5258
  pod: this.podCounter > 0 ? this.podCounter : void 0,
5188
5259
  adPosition: this.adRequestPositionInBreak,
@@ -5228,7 +5299,7 @@ var AdConfigManager = /*#__PURE__*/ function() {
5228
5299
  var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
5229
5300
  var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest);
5230
5301
  var urlWithMacros = applyVastMacros(baseUrl, {
5231
- correlator: generateCorrelator(),
5302
+ correlator: this.viewCorrelator,
5232
5303
  streamCorrelator: this.streamCorrelator,
5233
5304
  pod: this.podCounter > 0 ? this.podCounter : void 0,
5234
5305
  podMaxAds: podParams.maxAds,
@@ -7079,7 +7150,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7079
7150
  // IMA event listeners
7080
7151
  // ───────────────────────────────────────────────────────────────
7081
7152
  function get() {
7082
- return !!this.host.config.optimizedPods;
7153
+ return this.host.config.optimizedPods !== false;
7083
7154
  }
7084
7155
  },
7085
7156
  {
@@ -9219,7 +9290,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
9219
9290
  }
9220
9291
  this.adConfig.beginNewAdPod();
9221
9292
  this.adConfig.podAssignedByPrefetch = true;
9222
- var optimizedPods = !!this.config.optimizedPods;
9293
+ var optimizedPods = this.config.optimizedPods !== false;
9223
9294
  var breakDurationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : void 0;
9224
9295
  var generatedUrls = optimizedPods ? [
9225
9296
  this.generatePodVastUrl(baseVastUrl, breakDurationMs)