stormcloud-video-player 0.8.26 → 0.8.27

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.
@@ -1897,38 +1897,108 @@ function getOrCreateStoredUuid(storageKey) {
1897
1897
  if (typeof window === "undefined") {
1898
1898
  return void 0;
1899
1899
  }
1900
- var existing = readStoredString(storageKey);
1900
+ var existing = readPersistentId(storageKey);
1901
1901
  if (existing) {
1902
+ writePersistentId(storageKey, existing);
1902
1903
  return existing;
1903
1904
  }
1904
1905
  var id = createUuid();
1905
- try {
1906
- var _window_localStorage;
1907
- (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(storageKey, id);
1908
- } catch (unused) {}
1906
+ writePersistentId(storageKey, id);
1909
1907
  return id;
1910
1908
  }
1911
1909
  function getOrCreateCtvSessionId() {
1912
- var existing = readStoredString(CTV_SESSION_STORAGE_KEY);
1910
+ var existing = readPersistentId(CTV_SESSION_STORAGE_KEY);
1913
1911
  if (existing) {
1912
+ writePersistentId(CTV_SESSION_STORAGE_KEY, existing);
1914
1913
  return existing;
1915
1914
  }
1916
1915
  var sessionId = createUuid();
1916
+ writePersistentId(CTV_SESSION_STORAGE_KEY, sessionId);
1917
+ return sessionId;
1918
+ }
1919
+ function readPersistentId(storageKey) {
1920
+ return readStoredString(storageKey) || readCookie(storageKey);
1921
+ }
1922
+ function writePersistentId(storageKey, value) {
1917
1923
  try {
1918
1924
  var _window_localStorage;
1919
- (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(CTV_SESSION_STORAGE_KEY, sessionId);
1925
+ (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(storageKey, value);
1926
+ } catch (unused) {}
1927
+ writeCookie(storageKey, value);
1928
+ }
1929
+ var PERSISTENT_ID_COOKIE_MAX_AGE = 60 * 60 * 24 * 365 * 5;
1930
+ function readCookie(name) {
1931
+ if (typeof document === "undefined") {
1932
+ return void 0;
1933
+ }
1934
+ try {
1935
+ var prefix = encodeURIComponent(name) + "=";
1936
+ var parts = document.cookie ? document.cookie.split(";") : [];
1937
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1938
+ try {
1939
+ for(var _iterator = parts[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1940
+ var part = _step.value;
1941
+ var entry = part.trim();
1942
+ if (entry.startsWith(prefix)) {
1943
+ return decodeURIComponent(entry.slice(prefix.length)) || void 0;
1944
+ }
1945
+ }
1946
+ } catch (err) {
1947
+ _didIteratorError = true;
1948
+ _iteratorError = err;
1949
+ } finally{
1950
+ try {
1951
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1952
+ _iterator.return();
1953
+ }
1954
+ } finally{
1955
+ if (_didIteratorError) {
1956
+ throw _iteratorError;
1957
+ }
1958
+ }
1959
+ }
1960
+ } catch (unused) {}
1961
+ return void 0;
1962
+ }
1963
+ function writeCookie(name, value) {
1964
+ if (typeof document === "undefined") {
1965
+ return;
1966
+ }
1967
+ try {
1968
+ document.cookie = encodeURIComponent(name) + "=" + encodeURIComponent(value) + ";path=/;max-age=" + PERSISTENT_ID_COOKIE_MAX_AGE + ";SameSite=Lax";
1920
1969
  } catch (unused) {}
1921
- return sessionId;
1922
1970
  }
1923
1971
  function createUuid() {
1972
+ var _bytes_, _bytes_1;
1924
1973
  if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
1925
1974
  return crypto.randomUUID();
1926
1975
  }
1927
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(char) {
1928
- var value = Math.floor(Math.random() * 16);
1929
- var nibble = char === "x" ? value : value & 3 | 8;
1930
- return nibble.toString(16);
1931
- });
1976
+ var bytes = new Uint8Array(16);
1977
+ if (typeof crypto !== "undefined" && typeof crypto.getRandomValues === "function") {
1978
+ crypto.getRandomValues(bytes);
1979
+ } else {
1980
+ var seed = Date.now() ^ Math.floor(performanceNow() * 1e3);
1981
+ for(var i = 0; i < 16; i++){
1982
+ seed = seed * 1103515245 + 12345 & 2147483647;
1983
+ bytes[i] = (seed ^ Math.floor(Math.random() * 256)) & 255;
1984
+ }
1985
+ }
1986
+ bytes[6] = ((_bytes_ = bytes[6]) !== null && _bytes_ !== void 0 ? _bytes_ : 0) & 15 | 64;
1987
+ bytes[8] = ((_bytes_1 = bytes[8]) !== null && _bytes_1 !== void 0 ? _bytes_1 : 0) & 63 | 128;
1988
+ var hex = "";
1989
+ for(var i1 = 0; i1 < 16; i1++){
1990
+ var _bytes_i;
1991
+ hex += ((_bytes_i = bytes[i1]) !== null && _bytes_i !== void 0 ? _bytes_i : 0).toString(16).padStart(2, "0");
1992
+ }
1993
+ return hex.slice(0, 8) + "-" + hex.slice(8, 12) + "-" + hex.slice(12, 16) + "-" + hex.slice(16, 20) + "-" + hex.slice(20, 32);
1994
+ }
1995
+ function performanceNow() {
1996
+ try {
1997
+ if (typeof performance !== "undefined" && typeof performance.now === "function") {
1998
+ return performance.now();
1999
+ }
2000
+ } catch (unused) {}
2001
+ return 0;
1932
2002
  }
1933
2003
  function readPlatformNativeDeviceId() {
1934
2004
  if (typeof window === "undefined") return {};