stormcloud-video-player 0.3.14 → 0.3.16

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.
@@ -1,284 +1,586 @@
1
1
  "use strict";
2
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
3
+ try {
4
+ var info = gen[key](arg);
5
+ var value = info.value;
6
+ } catch (error) {
7
+ reject(error);
8
+ return;
9
+ }
10
+ if (info.done) {
11
+ resolve(value);
12
+ } else {
13
+ Promise.resolve(value).then(_next, _throw);
14
+ }
15
+ }
16
+ function _async_to_generator(fn) {
17
+ return function() {
18
+ var self = this, args = arguments;
19
+ return new Promise(function(resolve, reject) {
20
+ var gen = fn.apply(self, args);
21
+ function _next(value) {
22
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
23
+ }
24
+ function _throw(err) {
25
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
26
+ }
27
+ _next(undefined);
28
+ });
29
+ };
30
+ }
31
+ function _define_property(obj, key, value) {
32
+ if (key in obj) {
33
+ Object.defineProperty(obj, key, {
34
+ value: value,
35
+ enumerable: true,
36
+ configurable: true,
37
+ writable: true
38
+ });
39
+ } else {
40
+ obj[key] = value;
41
+ }
42
+ return obj;
43
+ }
44
+ function _object_spread(target) {
45
+ for(var i = 1; i < arguments.length; i++){
46
+ var source = arguments[i] != null ? arguments[i] : {};
47
+ var ownKeys = Object.keys(source);
48
+ if (typeof Object.getOwnPropertySymbols === "function") {
49
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
50
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
51
+ }));
52
+ }
53
+ ownKeys.forEach(function(key) {
54
+ _define_property(target, key, source[key]);
55
+ });
56
+ }
57
+ return target;
58
+ }
59
+ function _type_of(obj) {
60
+ "@swc/helpers - typeof";
61
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
62
+ }
63
+ function _ts_generator(thisArg, body) {
64
+ var f, y, t, _ = {
65
+ label: 0,
66
+ sent: function() {
67
+ if (t[0] & 1) throw t[1];
68
+ return t[1];
69
+ },
70
+ trys: [],
71
+ ops: []
72
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
73
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
74
+ return this;
75
+ }), g;
76
+ function verb(n) {
77
+ return function(v) {
78
+ return step([
79
+ n,
80
+ v
81
+ ]);
82
+ };
83
+ }
84
+ function step(op) {
85
+ if (f) throw new TypeError("Generator is already executing.");
86
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
87
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
88
+ if (y = 0, t) op = [
89
+ op[0] & 2,
90
+ t.value
91
+ ];
92
+ switch(op[0]){
93
+ case 0:
94
+ case 1:
95
+ t = op;
96
+ break;
97
+ case 4:
98
+ _.label++;
99
+ return {
100
+ value: op[1],
101
+ done: false
102
+ };
103
+ case 5:
104
+ _.label++;
105
+ y = op[1];
106
+ op = [
107
+ 0
108
+ ];
109
+ continue;
110
+ case 7:
111
+ op = _.ops.pop();
112
+ _.trys.pop();
113
+ continue;
114
+ default:
115
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
116
+ _ = 0;
117
+ continue;
118
+ }
119
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
120
+ _.label = op[1];
121
+ break;
122
+ }
123
+ if (op[0] === 6 && _.label < t[1]) {
124
+ _.label = t[1];
125
+ t = op;
126
+ break;
127
+ }
128
+ if (t && _.label < t[2]) {
129
+ _.label = t[2];
130
+ _.ops.push(op);
131
+ break;
132
+ }
133
+ if (t[2]) _.ops.pop();
134
+ _.trys.pop();
135
+ continue;
136
+ }
137
+ op = body.call(thisArg, _);
138
+ } catch (e) {
139
+ op = [
140
+ 6,
141
+ e
142
+ ];
143
+ y = 0;
144
+ } finally{
145
+ f = t = 0;
146
+ }
147
+ if (op[0] & 5) throw op[1];
148
+ return {
149
+ value: op[0] ? op[1] : void 0,
150
+ done: true
151
+ };
152
+ }
153
+ }
2
154
  var __defProp = Object.defineProperty;
3
155
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
156
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
157
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
158
+ var __export = function(target, all) {
159
+ for(var name in all)__defProp(target, name, {
160
+ get: all[name],
161
+ enumerable: true
162
+ });
163
+ };
164
+ var __copyProps = function(to, from, except, desc) {
165
+ if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
166
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
167
+ try {
168
+ var _loop = function() {
169
+ var key = _step.value;
170
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
171
+ get: function() {
172
+ return from[key];
173
+ },
174
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
175
+ });
176
+ };
177
+ for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
178
+ } catch (err) {
179
+ _didIteratorError = true;
180
+ _iteratorError = err;
181
+ } finally{
182
+ try {
183
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
184
+ _iterator.return();
185
+ }
186
+ } finally{
187
+ if (_didIteratorError) {
188
+ throw _iteratorError;
189
+ }
190
+ }
191
+ }
192
+ }
193
+ return to;
9
194
  };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
195
+ var __toCommonJS = function(mod) {
196
+ return __copyProps(__defProp({}, "__esModule", {
197
+ value: true
198
+ }), mod);
17
199
  };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
200
  // src/utils/tracking.ts
21
201
  var tracking_exports = {};
22
202
  __export(tracking_exports, {
23
- getBrowserID: () => getBrowserID,
24
- getClientInfo: () => getClientInfo,
25
- sendHeartbeat: () => sendHeartbeat,
26
- sendInitialTracking: () => sendInitialTracking
203
+ getBrowserID: function() {
204
+ return getBrowserID;
205
+ },
206
+ getClientInfo: function() {
207
+ return getClientInfo;
208
+ },
209
+ sendHeartbeat: function() {
210
+ return sendHeartbeat;
211
+ },
212
+ sendInitialTracking: function() {
213
+ return sendInitialTracking;
214
+ }
27
215
  });
28
216
  module.exports = __toCommonJS(tracking_exports);
29
217
  var cachedBrowserId = null;
30
218
  function getClientInfo() {
31
- var _a, _b, _c, _d;
32
- const ua = navigator.userAgent;
33
- const platform = navigator.platform;
34
- const vendor = navigator.vendor || "";
35
- const maxTouchPoints = navigator.maxTouchPoints || 0;
36
- const memory = navigator.deviceMemory || null;
37
- const hardwareConcurrency = navigator.hardwareConcurrency || 1;
38
- const screenInfo = {
39
- width: screen == null ? void 0 : screen.width,
40
- height: screen == null ? void 0 : screen.height,
41
- availWidth: screen == null ? void 0 : screen.availWidth,
42
- availHeight: screen == null ? void 0 : screen.availHeight,
43
- orientation: ((_a = screen == null ? void 0 : screen.orientation) == null ? void 0 : _a.type) || "",
44
- pixelDepth: screen == null ? void 0 : screen.pixelDepth
45
- };
46
- let deviceType = "desktop";
47
- let brand = "Unknown";
48
- let os = "Unknown";
49
- let model = "";
50
- let isSmartTV = false;
51
- let isAndroid = false;
52
- let isWebView = false;
53
- let isWebApp = false;
54
- if (ua.includes("Web0S")) {
55
- brand = "LG";
56
- os = "webOS";
57
- isSmartTV = true;
58
- deviceType = "tv";
59
- const webosMatch = ua.match(/Web0S\/([^\s]+)/);
60
- model = webosMatch ? `webOS ${webosMatch[1]}` : "webOS TV";
61
- } else if (ua.includes("Tizen")) {
62
- brand = "Samsung";
63
- os = "Tizen";
64
- isSmartTV = true;
65
- deviceType = "tv";
66
- const tizenMatch = ua.match(/Tizen\/([^\s]+)/);
67
- const tvMatch = ua.match(/(?:Smart-TV|SMART-TV|TV)/i) ? "Smart TV" : "";
68
- model = tizenMatch ? `Tizen ${tizenMatch[1]} ${tvMatch}`.trim() : "Tizen TV";
69
- } else if (ua.includes("Philips")) {
70
- brand = "Philips";
71
- os = "Saphi";
72
- isSmartTV = true;
73
- deviceType = "tv";
74
- } else if (ua.includes("Sharp") || ua.includes("AQUOS")) {
75
- brand = "Sharp";
76
- os = "Android TV";
77
- isSmartTV = true;
78
- deviceType = "tv";
79
- } else if (ua.includes("Android") && (ua.includes("Sony") || vendor.includes("Sony"))) {
80
- brand = "Sony";
81
- os = "Android TV";
82
- isSmartTV = true;
83
- deviceType = "tv";
84
- } else if (ua.includes("Android") && (ua.includes("NetCast") || ua.includes("LG"))) {
85
- brand = "LG";
86
- os = "Android TV";
87
- isSmartTV = true;
88
- deviceType = "tv";
89
- } else if (ua.includes(" Roku") || ua.includes("Roku/")) {
90
- brand = "Roku";
91
- os = "Roku OS";
92
- isSmartTV = true;
93
- deviceType = "tv";
94
- } else if (ua.includes("AppleTV")) {
95
- brand = "Apple";
96
- os = "tvOS";
97
- isSmartTV = true;
98
- deviceType = "tv";
99
- }
100
- if (ua.includes("Android")) {
101
- isAndroid = true;
102
- os = "Android";
103
- deviceType = /Mobile/.test(ua) ? "mobile" : "tablet";
104
- if (ua.includes("Android") && (maxTouchPoints === 0 || ua.includes("Google TV") || ua.includes("XiaoMi"))) {
105
- deviceType = "tv";
106
- isSmartTV = true;
107
- brand = brand === "Unknown" ? "Android TV" : brand;
108
- }
109
- const androidModelMatch = ua.match(/\(([^)]*Android[^)]*)\)/);
110
- if (androidModelMatch && androidModelMatch[1]) {
111
- model = androidModelMatch[1];
219
+ var _screen, _screen1, _screen2, _screen3, _screen_orientation, _screen4, _screen5, _window, _window1, _window_screen_orientation, _window_screen, _navigator_languages;
220
+ var ua = navigator.userAgent;
221
+ var platform = navigator.platform;
222
+ var vendor = navigator.vendor || "";
223
+ var maxTouchPoints = navigator.maxTouchPoints || 0;
224
+ var memory = navigator.deviceMemory || null;
225
+ var hardwareConcurrency = navigator.hardwareConcurrency || 1;
226
+ var screenInfo = {
227
+ width: (_screen = screen) === null || _screen === void 0 ? void 0 : _screen.width,
228
+ height: (_screen1 = screen) === null || _screen1 === void 0 ? void 0 : _screen1.height,
229
+ availWidth: (_screen2 = screen) === null || _screen2 === void 0 ? void 0 : _screen2.availWidth,
230
+ availHeight: (_screen3 = screen) === null || _screen3 === void 0 ? void 0 : _screen3.availHeight,
231
+ orientation: ((_screen4 = screen) === null || _screen4 === void 0 ? void 0 : (_screen_orientation = _screen4.orientation) === null || _screen_orientation === void 0 ? void 0 : _screen_orientation.type) || "",
232
+ pixelDepth: (_screen5 = screen) === null || _screen5 === void 0 ? void 0 : _screen5.pixelDepth
233
+ };
234
+ var deviceType = "desktop";
235
+ var brand = "Unknown";
236
+ var os = "Unknown";
237
+ var model = "";
238
+ var isSmartTV = false;
239
+ var isAndroid = false;
240
+ var isWebView = false;
241
+ var isWebApp = false;
242
+ if (ua.includes("Web0S")) {
243
+ brand = "LG";
244
+ os = "webOS";
245
+ isSmartTV = true;
246
+ deviceType = "tv";
247
+ var webosMatch = ua.match(/Web0S\/([^\s]+)/);
248
+ model = webosMatch ? "webOS ".concat(webosMatch[1]) : "webOS TV";
249
+ } else if (ua.includes("Tizen")) {
250
+ brand = "Samsung";
251
+ os = "Tizen";
252
+ isSmartTV = true;
253
+ deviceType = "tv";
254
+ var tizenMatch = ua.match(/Tizen\/([^\s]+)/);
255
+ var tvMatch = ua.match(/(?:Smart-TV|SMART-TV|TV)/i) ? "Smart TV" : "";
256
+ model = tizenMatch ? "Tizen ".concat(tizenMatch[1], " ").concat(tvMatch).trim() : "Tizen TV";
257
+ } else if (ua.includes("Philips")) {
258
+ brand = "Philips";
259
+ os = "Saphi";
260
+ isSmartTV = true;
261
+ deviceType = "tv";
262
+ } else if (ua.includes("Sharp") || ua.includes("AQUOS")) {
263
+ brand = "Sharp";
264
+ os = "Android TV";
265
+ isSmartTV = true;
266
+ deviceType = "tv";
267
+ } else if (ua.includes("Android") && (ua.includes("Sony") || vendor.includes("Sony"))) {
268
+ brand = "Sony";
269
+ os = "Android TV";
270
+ isSmartTV = true;
271
+ deviceType = "tv";
272
+ } else if (ua.includes("Android") && (ua.includes("NetCast") || ua.includes("LG"))) {
273
+ brand = "LG";
274
+ os = "Android TV";
275
+ isSmartTV = true;
276
+ deviceType = "tv";
277
+ } else if (ua.includes(" Roku") || ua.includes("Roku/")) {
278
+ brand = "Roku";
279
+ os = "Roku OS";
280
+ isSmartTV = true;
281
+ deviceType = "tv";
282
+ } else if (ua.includes("AppleTV")) {
283
+ brand = "Apple";
284
+ os = "tvOS";
285
+ isSmartTV = true;
286
+ deviceType = "tv";
112
287
  }
113
- }
114
- if (/iPad|iPhone|iPod/.test(ua)) {
115
- os = "iOS";
116
- deviceType = "mobile";
117
- brand = "Apple";
118
- if (navigator.maxTouchPoints > 1 && /iPad/.test(ua)) {
119
- deviceType = "tablet";
288
+ if (ua.includes("Android")) {
289
+ isAndroid = true;
290
+ os = "Android";
291
+ deviceType = /Mobile/.test(ua) ? "mobile" : "tablet";
292
+ if (ua.includes("Android") && (maxTouchPoints === 0 || ua.includes("Google TV") || ua.includes("XiaoMi"))) {
293
+ deviceType = "tv";
294
+ isSmartTV = true;
295
+ brand = brand === "Unknown" ? "Android TV" : brand;
296
+ }
297
+ var androidModelMatch = ua.match(/\(([^)]*Android[^)]*)\)/);
298
+ if (androidModelMatch && androidModelMatch[1]) {
299
+ model = androidModelMatch[1];
300
+ }
120
301
  }
121
- }
122
- if (!isAndroid && !isSmartTV && !/Mobile/.test(ua)) {
123
- if (ua.includes("Windows")) {
124
- os = "Windows";
125
- deviceType = "desktop";
126
- } else if (ua.includes("Mac") && !/iPhone/.test(ua)) {
127
- os = "macOS";
128
- deviceType = "desktop";
129
- if (maxTouchPoints > 1) deviceType = "tablet";
130
- } else if (ua.includes("Linux")) {
131
- os = "Linux";
132
- deviceType = "desktop";
302
+ if (/iPad|iPhone|iPod/.test(ua)) {
303
+ os = "iOS";
304
+ deviceType = "mobile";
305
+ brand = "Apple";
306
+ if (navigator.maxTouchPoints > 1 && /iPad/.test(ua)) {
307
+ deviceType = "tablet";
308
+ }
133
309
  }
134
- }
135
- if (brand === "Unknown") {
136
- if (vendor.includes("Google") || ua.includes("Chrome")) brand = "Google";
137
- if (vendor.includes("Apple")) brand = "Apple";
138
- if (vendor.includes("Samsung") || ua.includes("SM-")) brand = "Samsung";
139
- }
140
- isWebView = /wv|WebView|Linux; U;/.test(ua);
141
- if ((window == null ? void 0 : window.outerHeight) === 0 && (window == null ? void 0 : window.outerWidth) === 0) {
142
- isWebView = true;
143
- }
144
- isWebApp = window.matchMedia("(display-mode: standalone)").matches || window.navigator.standalone === true || ((_c = (_b = window.screen) == null ? void 0 : _b.orientation) == null ? void 0 : _c.angle) !== void 0;
145
- return {
146
- brand,
147
- os,
148
- model: model || ua.substring(0, 50) + "...",
149
- deviceType,
150
- isSmartTV,
151
- isAndroid,
152
- isWebView,
153
- isWebApp,
154
- domain: window.location.hostname,
155
- origin: window.location.origin,
156
- path: window.location.pathname,
157
- userAgent: ua,
158
- vendor,
159
- platform,
160
- screen: screenInfo,
161
- hardwareConcurrency,
162
- deviceMemory: memory,
163
- maxTouchPoints,
164
- language: navigator.language,
165
- languages: ((_d = navigator.languages) == null ? void 0 : _d.join(",")) || "",
166
- cookieEnabled: navigator.cookieEnabled,
167
- doNotTrack: navigator.doNotTrack || "",
168
- referrer: document.referrer,
169
- visibilityState: document.visibilityState
170
- };
171
- }
172
- async function getBrowserID(clientInfo) {
173
- if (cachedBrowserId) {
174
- return cachedBrowserId;
175
- }
176
- const fingerprintString = JSON.stringify(clientInfo);
177
- if (typeof crypto !== "undefined" && crypto.subtle && crypto.subtle.digest) {
178
- try {
179
- await crypto.subtle.digest("SHA-256", new Uint8Array([1, 2, 3]));
180
- let encodedData;
181
- if (typeof TextEncoder !== "undefined") {
182
- encodedData = new TextEncoder().encode(fingerprintString);
183
- } else {
184
- const utf8 = unescape(encodeURIComponent(fingerprintString));
185
- const buffer = new Uint8Array(utf8.length);
186
- for (let i = 0; i < utf8.length; i++) {
187
- buffer[i] = utf8.charCodeAt(i);
310
+ if (!isAndroid && !isSmartTV && !/Mobile/.test(ua)) {
311
+ if (ua.includes("Windows")) {
312
+ os = "Windows";
313
+ deviceType = "desktop";
314
+ } else if (ua.includes("Mac") && !/iPhone/.test(ua)) {
315
+ os = "macOS";
316
+ deviceType = "desktop";
317
+ if (maxTouchPoints > 1) deviceType = "tablet";
318
+ } else if (ua.includes("Linux")) {
319
+ os = "Linux";
320
+ deviceType = "desktop";
188
321
  }
189
- encodedData = buffer;
190
- }
191
- const hashBuffer = await crypto.subtle.digest("SHA-256", encodedData);
192
- const hashArray = Array.from(new Uint8Array(hashBuffer));
193
- const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
194
- cachedBrowserId = hashHex;
195
- return hashHex;
196
- } catch (error) {
197
- console.warn(
198
- "[StormcloudVideoPlayer] crypto.subtle.digest not supported, using fallback hash"
199
- );
200
322
  }
201
- }
202
- let hash = 0;
203
- for (let i = 0; i < fingerprintString.length; i++) {
204
- const char = fingerprintString.charCodeAt(i);
205
- hash = (hash << 5) - hash + char;
206
- hash = hash & hash;
207
- }
208
- const fallbackHash = Math.abs(hash).toString(16).padStart(8, "0");
209
- const timestamp = Date.now().toString(16).padStart(12, "0");
210
- const random = Math.random().toString(16).substring(2, 14).padStart(12, "0");
211
- cachedBrowserId = (fallbackHash + timestamp + random).padEnd(64, "0");
212
- return cachedBrowserId;
213
- }
214
- async function sendInitialTracking(licenseKey) {
215
- try {
216
- const clientInfo = getClientInfo();
217
- const browserId = await getBrowserID(clientInfo);
218
- const trackingData = {
219
- browserId,
220
- ...clientInfo
221
- };
222
- const headers = {
223
- "Content-Type": "application/json"
224
- };
225
- if (licenseKey) {
226
- headers["Authorization"] = `Bearer ${licenseKey}`;
323
+ if (brand === "Unknown") {
324
+ if (vendor.includes("Google") || ua.includes("Chrome")) brand = "Google";
325
+ if (vendor.includes("Apple")) brand = "Apple";
326
+ if (vendor.includes("Samsung") || ua.includes("SM-")) brand = "Samsung";
227
327
  }
228
- const response = await fetch(
229
- "https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/track",
230
- {
231
- method: "POST",
232
- headers,
233
- body: JSON.stringify(trackingData)
234
- }
235
- );
236
- if (!response.ok) {
237
- throw new Error(`HTTP error! status: ${response.status}`);
328
+ isWebView = /wv|WebView|Linux; U;/.test(ua);
329
+ if (((_window = window) === null || _window === void 0 ? void 0 : _window.outerHeight) === 0 && ((_window1 = window) === null || _window1 === void 0 ? void 0 : _window1.outerWidth) === 0) {
330
+ isWebView = true;
238
331
  }
239
- await response.json();
240
- } catch (error) {
241
- console.error(
242
- "[StormcloudVideoPlayer] Error sending initial tracking data:",
243
- error
244
- );
245
- }
246
- }
247
- async function sendHeartbeat(licenseKey) {
248
- try {
249
- const clientInfo = getClientInfo();
250
- const browserId = await getBrowserID(clientInfo);
251
- const heartbeatData = {
252
- browserId,
253
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
332
+ isWebApp = window.matchMedia("(display-mode: standalone)").matches || window.navigator.standalone === true || ((_window_screen = window.screen) === null || _window_screen === void 0 ? void 0 : (_window_screen_orientation = _window_screen.orientation) === null || _window_screen_orientation === void 0 ? void 0 : _window_screen_orientation.angle) !== void 0;
333
+ return {
334
+ brand: brand,
335
+ os: os,
336
+ model: model || ua.substring(0, 50) + "...",
337
+ deviceType: deviceType,
338
+ isSmartTV: isSmartTV,
339
+ isAndroid: isAndroid,
340
+ isWebView: isWebView,
341
+ isWebApp: isWebApp,
342
+ domain: window.location.hostname,
343
+ origin: window.location.origin,
344
+ path: window.location.pathname,
345
+ userAgent: ua,
346
+ vendor: vendor,
347
+ platform: platform,
348
+ screen: screenInfo,
349
+ hardwareConcurrency: hardwareConcurrency,
350
+ deviceMemory: memory,
351
+ maxTouchPoints: maxTouchPoints,
352
+ language: navigator.language,
353
+ languages: ((_navigator_languages = navigator.languages) === null || _navigator_languages === void 0 ? void 0 : _navigator_languages.join(",")) || "",
354
+ cookieEnabled: navigator.cookieEnabled,
355
+ doNotTrack: navigator.doNotTrack || "",
356
+ referrer: document.referrer,
357
+ visibilityState: document.visibilityState
254
358
  };
255
- const headers = {
256
- "Content-Type": "application/json"
257
- };
258
- if (licenseKey) {
259
- headers["Authorization"] = `Bearer ${licenseKey}`;
260
- }
261
- const response = await fetch(
262
- "https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/heartbeat",
263
- {
264
- method: "POST",
265
- headers,
266
- body: JSON.stringify(heartbeatData)
267
- }
268
- );
269
- if (!response.ok) {
270
- throw new Error(`HTTP error! status: ${response.status}`);
271
- }
272
- await response.json();
273
- } catch (error) {
274
- console.error("[StormcloudVideoPlayer] Error sending heartbeat:", error);
275
- }
359
+ }
360
+ function getBrowserID(clientInfo) {
361
+ return _async_to_generator(function() {
362
+ var fingerprintString, encodedData, utf8, buffer, i, hashBuffer, hashArray, hashHex, error, hash, i1, char, fallbackHash, timestamp, random;
363
+ return _ts_generator(this, function(_state) {
364
+ switch(_state.label){
365
+ case 0:
366
+ if (cachedBrowserId) {
367
+ return [
368
+ 2,
369
+ cachedBrowserId
370
+ ];
371
+ }
372
+ fingerprintString = JSON.stringify(clientInfo);
373
+ if (!(typeof crypto !== "undefined" && crypto.subtle && crypto.subtle.digest)) return [
374
+ 3,
375
+ 5
376
+ ];
377
+ _state.label = 1;
378
+ case 1:
379
+ _state.trys.push([
380
+ 1,
381
+ 4,
382
+ ,
383
+ 5
384
+ ]);
385
+ return [
386
+ 4,
387
+ crypto.subtle.digest("SHA-256", new Uint8Array([
388
+ 1,
389
+ 2,
390
+ 3
391
+ ]))
392
+ ];
393
+ case 2:
394
+ _state.sent();
395
+ if (typeof TextEncoder !== "undefined") {
396
+ encodedData = new TextEncoder().encode(fingerprintString);
397
+ } else {
398
+ utf8 = unescape(encodeURIComponent(fingerprintString));
399
+ buffer = new Uint8Array(utf8.length);
400
+ for(i = 0; i < utf8.length; i++){
401
+ buffer[i] = utf8.charCodeAt(i);
402
+ }
403
+ encodedData = buffer;
404
+ }
405
+ return [
406
+ 4,
407
+ crypto.subtle.digest("SHA-256", encodedData)
408
+ ];
409
+ case 3:
410
+ hashBuffer = _state.sent();
411
+ hashArray = Array.from(new Uint8Array(hashBuffer));
412
+ hashHex = hashArray.map(function(b) {
413
+ return b.toString(16).padStart(2, "0");
414
+ }).join("");
415
+ cachedBrowserId = hashHex;
416
+ return [
417
+ 2,
418
+ hashHex
419
+ ];
420
+ case 4:
421
+ error = _state.sent();
422
+ console.warn("[StormcloudVideoPlayer] crypto.subtle.digest not supported, using fallback hash");
423
+ return [
424
+ 3,
425
+ 5
426
+ ];
427
+ case 5:
428
+ hash = 0;
429
+ for(i1 = 0; i1 < fingerprintString.length; i1++){
430
+ char = fingerprintString.charCodeAt(i1);
431
+ hash = (hash << 5) - hash + char;
432
+ hash = hash & hash;
433
+ }
434
+ fallbackHash = Math.abs(hash).toString(16).padStart(8, "0");
435
+ timestamp = Date.now().toString(16).padStart(12, "0");
436
+ random = Math.random().toString(16).substring(2, 14).padStart(12, "0");
437
+ cachedBrowserId = (fallbackHash + timestamp + random).padEnd(64, "0");
438
+ return [
439
+ 2,
440
+ cachedBrowserId
441
+ ];
442
+ }
443
+ });
444
+ })();
445
+ }
446
+ function sendInitialTracking(licenseKey) {
447
+ return _async_to_generator(function() {
448
+ var clientInfo, browserId, trackingData, headers, response, error;
449
+ return _ts_generator(this, function(_state) {
450
+ switch(_state.label){
451
+ case 0:
452
+ _state.trys.push([
453
+ 0,
454
+ 4,
455
+ ,
456
+ 5
457
+ ]);
458
+ clientInfo = getClientInfo();
459
+ return [
460
+ 4,
461
+ getBrowserID(clientInfo)
462
+ ];
463
+ case 1:
464
+ browserId = _state.sent();
465
+ trackingData = _object_spread({
466
+ browserId: browserId
467
+ }, clientInfo);
468
+ headers = {
469
+ "Content-Type": "application/json"
470
+ };
471
+ if (licenseKey) {
472
+ headers["Authorization"] = "Bearer ".concat(licenseKey);
473
+ }
474
+ return [
475
+ 4,
476
+ fetch("https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/track", {
477
+ method: "POST",
478
+ headers: headers,
479
+ body: JSON.stringify(trackingData)
480
+ })
481
+ ];
482
+ case 2:
483
+ response = _state.sent();
484
+ if (!response.ok) {
485
+ throw new Error("HTTP error! status: ".concat(response.status));
486
+ }
487
+ return [
488
+ 4,
489
+ response.json()
490
+ ];
491
+ case 3:
492
+ _state.sent();
493
+ return [
494
+ 3,
495
+ 5
496
+ ];
497
+ case 4:
498
+ error = _state.sent();
499
+ console.error("[StormcloudVideoPlayer] Error sending initial tracking data:", error);
500
+ return [
501
+ 3,
502
+ 5
503
+ ];
504
+ case 5:
505
+ return [
506
+ 2
507
+ ];
508
+ }
509
+ });
510
+ })();
511
+ }
512
+ function sendHeartbeat(licenseKey) {
513
+ return _async_to_generator(function() {
514
+ var clientInfo, browserId, heartbeatData, headers, response, error;
515
+ return _ts_generator(this, function(_state) {
516
+ switch(_state.label){
517
+ case 0:
518
+ _state.trys.push([
519
+ 0,
520
+ 4,
521
+ ,
522
+ 5
523
+ ]);
524
+ clientInfo = getClientInfo();
525
+ return [
526
+ 4,
527
+ getBrowserID(clientInfo)
528
+ ];
529
+ case 1:
530
+ browserId = _state.sent();
531
+ heartbeatData = {
532
+ browserId: browserId,
533
+ timestamp: /* @__PURE__ */ new Date().toISOString()
534
+ };
535
+ headers = {
536
+ "Content-Type": "application/json"
537
+ };
538
+ if (licenseKey) {
539
+ headers["Authorization"] = "Bearer ".concat(licenseKey);
540
+ }
541
+ return [
542
+ 4,
543
+ fetch("https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/heartbeat", {
544
+ method: "POST",
545
+ headers: headers,
546
+ body: JSON.stringify(heartbeatData)
547
+ })
548
+ ];
549
+ case 2:
550
+ response = _state.sent();
551
+ if (!response.ok) {
552
+ throw new Error("HTTP error! status: ".concat(response.status));
553
+ }
554
+ return [
555
+ 4,
556
+ response.json()
557
+ ];
558
+ case 3:
559
+ _state.sent();
560
+ return [
561
+ 3,
562
+ 5
563
+ ];
564
+ case 4:
565
+ error = _state.sent();
566
+ console.error("[StormcloudVideoPlayer] Error sending heartbeat:", error);
567
+ return [
568
+ 3,
569
+ 5
570
+ ];
571
+ case 5:
572
+ return [
573
+ 2
574
+ ];
575
+ }
576
+ });
577
+ })();
276
578
  }
277
579
  // Annotate the CommonJS export names for ESM import in node:
278
580
  0 && (module.exports = {
279
- getBrowserID,
280
- getClientInfo,
281
- sendHeartbeat,
282
- sendInitialTracking
581
+ getBrowserID: getBrowserID,
582
+ getClientInfo: getClientInfo,
583
+ sendHeartbeat: sendHeartbeat,
584
+ sendInitialTracking: sendInitialTracking
283
585
  });
284
586
  //# sourceMappingURL=tracking.cjs.map