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.
package/lib/index.cjs CHANGED
@@ -2159,38 +2159,108 @@ function getOrCreateStoredUuid(storageKey) {
2159
2159
  if (typeof window === "undefined") {
2160
2160
  return void 0;
2161
2161
  }
2162
- var existing = readStoredString(storageKey);
2162
+ var existing = readPersistentId(storageKey);
2163
2163
  if (existing) {
2164
+ writePersistentId(storageKey, existing);
2164
2165
  return existing;
2165
2166
  }
2166
2167
  var id = createUuid();
2167
- try {
2168
- var _window_localStorage;
2169
- (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(storageKey, id);
2170
- } catch (unused) {}
2168
+ writePersistentId(storageKey, id);
2171
2169
  return id;
2172
2170
  }
2173
2171
  function getOrCreateCtvSessionId() {
2174
- var existing = readStoredString(CTV_SESSION_STORAGE_KEY);
2172
+ var existing = readPersistentId(CTV_SESSION_STORAGE_KEY);
2175
2173
  if (existing) {
2174
+ writePersistentId(CTV_SESSION_STORAGE_KEY, existing);
2176
2175
  return existing;
2177
2176
  }
2178
2177
  var sessionId = createUuid();
2178
+ writePersistentId(CTV_SESSION_STORAGE_KEY, sessionId);
2179
+ return sessionId;
2180
+ }
2181
+ function readPersistentId(storageKey) {
2182
+ return readStoredString(storageKey) || readCookie(storageKey);
2183
+ }
2184
+ function writePersistentId(storageKey, value) {
2179
2185
  try {
2180
2186
  var _window_localStorage;
2181
- (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(CTV_SESSION_STORAGE_KEY, sessionId);
2187
+ (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(storageKey, value);
2188
+ } catch (unused) {}
2189
+ writeCookie(storageKey, value);
2190
+ }
2191
+ var PERSISTENT_ID_COOKIE_MAX_AGE = 60 * 60 * 24 * 365 * 5;
2192
+ function readCookie(name) {
2193
+ if (typeof document === "undefined") {
2194
+ return void 0;
2195
+ }
2196
+ try {
2197
+ var prefix = encodeURIComponent(name) + "=";
2198
+ var parts = document.cookie ? document.cookie.split(";") : [];
2199
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2200
+ try {
2201
+ for(var _iterator = parts[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2202
+ var part = _step.value;
2203
+ var entry = part.trim();
2204
+ if (entry.startsWith(prefix)) {
2205
+ return decodeURIComponent(entry.slice(prefix.length)) || void 0;
2206
+ }
2207
+ }
2208
+ } catch (err) {
2209
+ _didIteratorError = true;
2210
+ _iteratorError = err;
2211
+ } finally{
2212
+ try {
2213
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2214
+ _iterator.return();
2215
+ }
2216
+ } finally{
2217
+ if (_didIteratorError) {
2218
+ throw _iteratorError;
2219
+ }
2220
+ }
2221
+ }
2222
+ } catch (unused) {}
2223
+ return void 0;
2224
+ }
2225
+ function writeCookie(name, value) {
2226
+ if (typeof document === "undefined") {
2227
+ return;
2228
+ }
2229
+ try {
2230
+ document.cookie = encodeURIComponent(name) + "=" + encodeURIComponent(value) + ";path=/;max-age=" + PERSISTENT_ID_COOKIE_MAX_AGE + ";SameSite=Lax";
2182
2231
  } catch (unused) {}
2183
- return sessionId;
2184
2232
  }
2185
2233
  function createUuid() {
2234
+ var _bytes_, _bytes_1;
2186
2235
  if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
2187
2236
  return crypto.randomUUID();
2188
2237
  }
2189
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(char) {
2190
- var value = Math.floor(Math.random() * 16);
2191
- var nibble = char === "x" ? value : value & 3 | 8;
2192
- return nibble.toString(16);
2193
- });
2238
+ var bytes = new Uint8Array(16);
2239
+ if (typeof crypto !== "undefined" && typeof crypto.getRandomValues === "function") {
2240
+ crypto.getRandomValues(bytes);
2241
+ } else {
2242
+ var seed = Date.now() ^ Math.floor(performanceNow() * 1e3);
2243
+ for(var i = 0; i < 16; i++){
2244
+ seed = seed * 1103515245 + 12345 & 2147483647;
2245
+ bytes[i] = (seed ^ Math.floor(Math.random() * 256)) & 255;
2246
+ }
2247
+ }
2248
+ bytes[6] = ((_bytes_ = bytes[6]) !== null && _bytes_ !== void 0 ? _bytes_ : 0) & 15 | 64;
2249
+ bytes[8] = ((_bytes_1 = bytes[8]) !== null && _bytes_1 !== void 0 ? _bytes_1 : 0) & 63 | 128;
2250
+ var hex = "";
2251
+ for(var i1 = 0; i1 < 16; i1++){
2252
+ var _bytes_i;
2253
+ hex += ((_bytes_i = bytes[i1]) !== null && _bytes_i !== void 0 ? _bytes_i : 0).toString(16).padStart(2, "0");
2254
+ }
2255
+ return hex.slice(0, 8) + "-" + hex.slice(8, 12) + "-" + hex.slice(12, 16) + "-" + hex.slice(16, 20) + "-" + hex.slice(20, 32);
2256
+ }
2257
+ function performanceNow() {
2258
+ try {
2259
+ if (typeof performance !== "undefined" && typeof performance.now === "function") {
2260
+ return performance.now();
2261
+ }
2262
+ } catch (unused) {}
2263
+ return 0;
2194
2264
  }
2195
2265
  function readPlatformNativeDeviceId() {
2196
2266
  if (typeof window === "undefined") return {};