stormcloud-video-player 0.6.11 → 0.6.13
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/README.md +33 -294
- package/dist/stormcloud-vp.min.js +3 -1
- package/lib/index.cjs +265 -191
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +29 -1
- package/lib/index.d.ts +29 -1
- package/lib/index.js +210 -192
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +193 -191
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +193 -191
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +193 -191
- package/lib/players/index.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +193 -191
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/utils/mqttClient.cjs +245 -0
- package/lib/utils/mqttClient.cjs.map +1 -0
- package/lib/utils/mqttClient.d.cts +13 -0
- package/lib/utils/mqttConfig.cjs +136 -0
- package/lib/utils/mqttConfig.cjs.map +1 -0
- package/lib/utils/mqttConfig.d.cts +19 -0
- package/lib/utils/tracking.cjs +193 -191
- package/lib/utils/tracking.cjs.map +1 -1
- package/package.json +3 -3
package/lib/index.cjs
CHANGED
|
@@ -428,6 +428,9 @@ var __toCommonJS = function __toCommonJS(mod) {
|
|
|
428
428
|
// src/index.ts
|
|
429
429
|
var index_exports = {};
|
|
430
430
|
__export(index_exports, {
|
|
431
|
+
DEFAULT_MQTT_CONFIG: function DEFAULT_MQTT_CONFIG1() {
|
|
432
|
+
return DEFAULT_MQTT_CONFIG;
|
|
433
|
+
},
|
|
431
434
|
IS_BROWSER: function IS_BROWSER1() {
|
|
432
435
|
return IS_BROWSER;
|
|
433
436
|
},
|
|
@@ -455,9 +458,21 @@ __export(index_exports, {
|
|
|
455
458
|
StormcloudVideoPlayerComponent: function StormcloudVideoPlayerComponent1() {
|
|
456
459
|
return StormcloudVideoPlayerComponent;
|
|
457
460
|
},
|
|
461
|
+
applyMQTTConfig: function applyMQTTConfig1() {
|
|
462
|
+
return applyMQTTConfig;
|
|
463
|
+
},
|
|
464
|
+
buildMQTTBrokerUrl: function buildMQTTBrokerUrl1() {
|
|
465
|
+
return buildMQTTBrokerUrl;
|
|
466
|
+
},
|
|
467
|
+
buildPlayerTopic: function buildPlayerTopic1() {
|
|
468
|
+
return buildPlayerTopic;
|
|
469
|
+
},
|
|
458
470
|
canPlay: function canPlay1() {
|
|
459
471
|
return canPlay;
|
|
460
472
|
},
|
|
473
|
+
configureMQTT: function configureMQTT1() {
|
|
474
|
+
return configureMQTT;
|
|
475
|
+
},
|
|
461
476
|
createStormcloudPlayer: function createStormcloudPlayer1() {
|
|
462
477
|
return createStormcloudPlayer;
|
|
463
478
|
},
|
|
@@ -473,6 +488,12 @@ __export(index_exports, {
|
|
|
473
488
|
detectBrowser: function detectBrowser1() {
|
|
474
489
|
return detectBrowser;
|
|
475
490
|
},
|
|
491
|
+
disconnectMQTT: function disconnectMQTT1() {
|
|
492
|
+
return disconnectMQTT;
|
|
493
|
+
},
|
|
494
|
+
ensureMQTTClient: function ensureMQTTClient1() {
|
|
495
|
+
return ensureMQTTClient;
|
|
496
|
+
},
|
|
476
497
|
getBrowserConfigOverrides: function getBrowserConfigOverrides1() {
|
|
477
498
|
return getBrowserConfigOverrides;
|
|
478
499
|
},
|
|
@@ -482,9 +503,24 @@ __export(index_exports, {
|
|
|
482
503
|
getClientInfo: function getClientInfo1() {
|
|
483
504
|
return getClientInfo;
|
|
484
505
|
},
|
|
506
|
+
getMQTTStatus: function getMQTTStatus1() {
|
|
507
|
+
return getMQTTStatus;
|
|
508
|
+
},
|
|
509
|
+
initMQTTClient: function initMQTTClient1() {
|
|
510
|
+
return initMQTTClient;
|
|
511
|
+
},
|
|
485
512
|
initializePolyfills: function initializePolyfills1() {
|
|
486
513
|
return initializePolyfills;
|
|
487
514
|
},
|
|
515
|
+
isMQTTConfigured: function isMQTTConfigured1() {
|
|
516
|
+
return isMQTTConfigured;
|
|
517
|
+
},
|
|
518
|
+
isMQTTConnected: function isMQTTConnected1() {
|
|
519
|
+
return isMQTTConnected;
|
|
520
|
+
},
|
|
521
|
+
isMQTTEnabled: function isMQTTEnabled1() {
|
|
522
|
+
return isMQTTEnabled;
|
|
523
|
+
},
|
|
488
524
|
isMediaStream: function isMediaStream1() {
|
|
489
525
|
return isMediaStream;
|
|
490
526
|
},
|
|
@@ -497,6 +533,9 @@ __export(index_exports, {
|
|
|
497
533
|
merge: function merge1() {
|
|
498
534
|
return merge;
|
|
499
535
|
},
|
|
536
|
+
mqttConfig: function mqttConfig1() {
|
|
537
|
+
return mqttConfig;
|
|
538
|
+
},
|
|
500
539
|
omit: function omit1() {
|
|
501
540
|
return omit;
|
|
502
541
|
},
|
|
@@ -506,6 +545,9 @@ __export(index_exports, {
|
|
|
506
545
|
players: function players() {
|
|
507
546
|
return players_default;
|
|
508
547
|
},
|
|
548
|
+
publishMQTT: function publishMQTT1() {
|
|
549
|
+
return publishMQTT;
|
|
550
|
+
},
|
|
509
551
|
randomString: function randomString1() {
|
|
510
552
|
return randomString;
|
|
511
553
|
},
|
|
@@ -2190,6 +2232,122 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
2190
2232
|
}
|
|
2191
2233
|
};
|
|
2192
2234
|
}
|
|
2235
|
+
// src/utils/mqttConfig.ts
|
|
2236
|
+
var DEFAULT_MQTT_CONFIG = {
|
|
2237
|
+
enabled: true,
|
|
2238
|
+
brokerAddress: "vecbae77.ala.us-east-1.emqxsl.com",
|
|
2239
|
+
brokerPort: 8883,
|
|
2240
|
+
wsPort: 8084,
|
|
2241
|
+
username: "for-sonifi",
|
|
2242
|
+
password: "sonifi-mqtt",
|
|
2243
|
+
topicPrefix: "adstorm/players",
|
|
2244
|
+
qos: 1
|
|
2245
|
+
};
|
|
2246
|
+
var mqttConfig = _object_spread({}, DEFAULT_MQTT_CONFIG);
|
|
2247
|
+
function applyMQTTConfig(overrides) {
|
|
2248
|
+
Object.assign(mqttConfig, overrides);
|
|
2249
|
+
}
|
|
2250
|
+
function isMQTTEnabled() {
|
|
2251
|
+
return mqttConfig.enabled;
|
|
2252
|
+
}
|
|
2253
|
+
function buildMQTTBrokerUrl() {
|
|
2254
|
+
if (mqttConfig.brokerUrl) return mqttConfig.brokerUrl;
|
|
2255
|
+
return "wss://".concat(mqttConfig.brokerAddress, ":").concat(mqttConfig.wsPort, "/mqtt");
|
|
2256
|
+
}
|
|
2257
|
+
function buildPlayerTopic(licenseKey, channel) {
|
|
2258
|
+
return "".concat(mqttConfig.topicPrefix, "/").concat(licenseKey, "/").concat(channel);
|
|
2259
|
+
}
|
|
2260
|
+
// src/utils/mqttClient.ts
|
|
2261
|
+
var import_mqtt = __toESM(require("mqtt"), 1);
|
|
2262
|
+
var LOG2 = "[StormcloudVideoPlayer][MQTT]";
|
|
2263
|
+
var client = null;
|
|
2264
|
+
var status = "disconnected";
|
|
2265
|
+
function getMQTTStatus() {
|
|
2266
|
+
return status;
|
|
2267
|
+
}
|
|
2268
|
+
function isMQTTConnected() {
|
|
2269
|
+
return status === "connected" && client !== null && client.connected;
|
|
2270
|
+
}
|
|
2271
|
+
function isMQTTConfigured() {
|
|
2272
|
+
return isMQTTEnabled();
|
|
2273
|
+
}
|
|
2274
|
+
function configureMQTT(overrides) {
|
|
2275
|
+
applyMQTTConfig(overrides);
|
|
2276
|
+
disconnectMQTT();
|
|
2277
|
+
}
|
|
2278
|
+
function initMQTTClient() {
|
|
2279
|
+
if (client || !isMQTTEnabled()) return;
|
|
2280
|
+
var url = buildMQTTBrokerUrl();
|
|
2281
|
+
status = "connecting";
|
|
2282
|
+
var clientId = "stormcloud-vp-".concat(Math.random().toString(36).slice(2, 9));
|
|
2283
|
+
try {
|
|
2284
|
+
client = import_mqtt.default.connect(url, {
|
|
2285
|
+
clientId: clientId,
|
|
2286
|
+
username: mqttConfig.username,
|
|
2287
|
+
password: mqttConfig.password,
|
|
2288
|
+
keepalive: 60,
|
|
2289
|
+
clean: true,
|
|
2290
|
+
reconnectPeriod: 5e3,
|
|
2291
|
+
connectTimeout: 1e4,
|
|
2292
|
+
queueQoSZero: false
|
|
2293
|
+
});
|
|
2294
|
+
} catch (err) {
|
|
2295
|
+
status = "error";
|
|
2296
|
+
console.warn("".concat(LOG2, " connect() threw:"), err);
|
|
2297
|
+
return;
|
|
2298
|
+
}
|
|
2299
|
+
client.on("connect", function() {
|
|
2300
|
+
status = "connected";
|
|
2301
|
+
console.info("".concat(LOG2, " connected to ").concat(url));
|
|
2302
|
+
});
|
|
2303
|
+
client.on("reconnect", function() {
|
|
2304
|
+
status = "connecting";
|
|
2305
|
+
console.info("".concat(LOG2, " reconnecting…"));
|
|
2306
|
+
});
|
|
2307
|
+
client.on("offline", function() {
|
|
2308
|
+
status = "disconnected";
|
|
2309
|
+
console.warn("".concat(LOG2, " offline"));
|
|
2310
|
+
});
|
|
2311
|
+
client.on("error", function(err) {
|
|
2312
|
+
status = "error";
|
|
2313
|
+
console.warn("".concat(LOG2, " error:"), err.message);
|
|
2314
|
+
});
|
|
2315
|
+
client.on("close", function() {
|
|
2316
|
+
if (status === "connected") {
|
|
2317
|
+
status = "disconnected";
|
|
2318
|
+
}
|
|
2319
|
+
});
|
|
2320
|
+
}
|
|
2321
|
+
function ensureMQTTClient() {
|
|
2322
|
+
if (isMQTTEnabled() && !client) {
|
|
2323
|
+
initMQTTClient();
|
|
2324
|
+
}
|
|
2325
|
+
}
|
|
2326
|
+
function publishMQTT(topic, payload) {
|
|
2327
|
+
if (!isMQTTEnabled()) {
|
|
2328
|
+
return false;
|
|
2329
|
+
}
|
|
2330
|
+
ensureMQTTClient();
|
|
2331
|
+
if (!client) {
|
|
2332
|
+
return false;
|
|
2333
|
+
}
|
|
2334
|
+
try {
|
|
2335
|
+
client.publish(topic, JSON.stringify(payload), {
|
|
2336
|
+
qos: mqttConfig.qos
|
|
2337
|
+
});
|
|
2338
|
+
return true;
|
|
2339
|
+
} catch (err) {
|
|
2340
|
+
console.warn("".concat(LOG2, " publish failed on ").concat(topic, ":"), err);
|
|
2341
|
+
return false;
|
|
2342
|
+
}
|
|
2343
|
+
}
|
|
2344
|
+
function disconnectMQTT() {
|
|
2345
|
+
if (client) {
|
|
2346
|
+
client.end(true);
|
|
2347
|
+
client = null;
|
|
2348
|
+
status = "disconnected";
|
|
2349
|
+
}
|
|
2350
|
+
}
|
|
2193
2351
|
// src/utils/tracking.ts
|
|
2194
2352
|
var cachedBrowserId = null;
|
|
2195
2353
|
function getClientInfo() {
|
|
@@ -2221,8 +2379,8 @@ function getClientInfo() {
|
|
|
2221
2379
|
os = "webOS";
|
|
2222
2380
|
isSmartTV = true;
|
|
2223
2381
|
deviceType = "tv";
|
|
2224
|
-
var
|
|
2225
|
-
model =
|
|
2382
|
+
var m = ua.match(/Web0S\/([^\s]+)/);
|
|
2383
|
+
model = m ? "webOS ".concat(m[1]) : "webOS TV";
|
|
2226
2384
|
} else if (ua.includes("Tizen")) {
|
|
2227
2385
|
brand = "Samsung";
|
|
2228
2386
|
os = "Tizen";
|
|
@@ -2266,23 +2424,19 @@ function getClientInfo() {
|
|
|
2266
2424
|
isAndroid = true;
|
|
2267
2425
|
os = "Android";
|
|
2268
2426
|
deviceType = /Mobile/.test(ua) ? "mobile" : "tablet";
|
|
2269
|
-
if (
|
|
2427
|
+
if (maxTouchPoints === 0 || ua.includes("Google TV") || ua.includes("XiaoMi")) {
|
|
2270
2428
|
deviceType = "tv";
|
|
2271
2429
|
isSmartTV = true;
|
|
2272
2430
|
brand = brand === "Unknown" ? "Android TV" : brand;
|
|
2273
2431
|
}
|
|
2274
2432
|
var androidModelMatch = ua.match(/\(([^)]*Android[^)]*)\)/);
|
|
2275
|
-
if (androidModelMatch
|
|
2276
|
-
model = androidModelMatch[1];
|
|
2277
|
-
}
|
|
2433
|
+
if (androidModelMatch === null || androidModelMatch === void 0 ? void 0 : androidModelMatch[1]) model = androidModelMatch[1];
|
|
2278
2434
|
}
|
|
2279
2435
|
if (/iPad|iPhone|iPod/.test(ua)) {
|
|
2280
2436
|
os = "iOS";
|
|
2281
2437
|
deviceType = "mobile";
|
|
2282
2438
|
brand = "Apple";
|
|
2283
|
-
if (navigator.maxTouchPoints > 1 && /iPad/.test(ua))
|
|
2284
|
-
deviceType = "tablet";
|
|
2285
|
-
}
|
|
2439
|
+
if (navigator.maxTouchPoints > 1 && /iPad/.test(ua)) deviceType = "tablet";
|
|
2286
2440
|
}
|
|
2287
2441
|
if (!isAndroid && !isSmartTV && !/Mobile/.test(ua)) {
|
|
2288
2442
|
if (ua.includes("Windows")) {
|
|
@@ -2303,9 +2457,7 @@ function getClientInfo() {
|
|
|
2303
2457
|
if (vendor.includes("Samsung") || ua.includes("SM-")) brand = "Samsung";
|
|
2304
2458
|
}
|
|
2305
2459
|
isWebView = /wv|WebView|Linux; U;/.test(ua);
|
|
2306
|
-
if (((_window = window) === null || _window === void 0 ? void 0 : _window.outerHeight) === 0 && ((_window1 = window) === null || _window1 === void 0 ? void 0 : _window1.outerWidth) === 0)
|
|
2307
|
-
isWebView = true;
|
|
2308
|
-
}
|
|
2460
|
+
if (((_window = window) === null || _window === void 0 ? void 0 : _window.outerHeight) === 0 && ((_window1 = window) === null || _window1 === void 0 ? void 0 : _window1.outerWidth) === 0) isWebView = true;
|
|
2309
2461
|
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;
|
|
2310
2462
|
return {
|
|
2311
2463
|
brand: brand,
|
|
@@ -2336,18 +2488,16 @@ function getClientInfo() {
|
|
|
2336
2488
|
}
|
|
2337
2489
|
function getBrowserID(clientInfo) {
|
|
2338
2490
|
return _async_to_generator(function() {
|
|
2339
|
-
var fingerprintString, encodedData, utf8, buffer, i, hashBuffer,
|
|
2491
|
+
var _crypto_subtle, fingerprintString, encodedData, utf8, buffer, i, hashBuffer, hashHex, unused, hash, i1, char, fallbackHash, timestamp, random;
|
|
2340
2492
|
return _ts_generator(this, function(_state) {
|
|
2341
2493
|
switch(_state.label){
|
|
2342
2494
|
case 0:
|
|
2343
|
-
if (cachedBrowserId)
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
];
|
|
2348
|
-
}
|
|
2495
|
+
if (cachedBrowserId) return [
|
|
2496
|
+
2,
|
|
2497
|
+
cachedBrowserId
|
|
2498
|
+
];
|
|
2349
2499
|
fingerprintString = JSON.stringify(clientInfo);
|
|
2350
|
-
if (!(typeof crypto !== "undefined" && crypto.subtle
|
|
2500
|
+
if (!(typeof crypto !== "undefined" && ((_crypto_subtle = crypto.subtle) === null || _crypto_subtle === void 0 ? void 0 : _crypto_subtle.digest))) return [
|
|
2351
2501
|
3,
|
|
2352
2502
|
5
|
|
2353
2503
|
];
|
|
@@ -2374,9 +2524,7 @@ function getBrowserID(clientInfo) {
|
|
|
2374
2524
|
} else {
|
|
2375
2525
|
utf8 = unescape(encodeURIComponent(fingerprintString));
|
|
2376
2526
|
buffer = new Uint8Array(utf8.length);
|
|
2377
|
-
for(i = 0; i < utf8.length; i++)
|
|
2378
|
-
buffer[i] = utf8.charCodeAt(i);
|
|
2379
|
-
}
|
|
2527
|
+
for(i = 0; i < utf8.length; i++)buffer[i] = utf8.charCodeAt(i);
|
|
2380
2528
|
encodedData = buffer;
|
|
2381
2529
|
}
|
|
2382
2530
|
return [
|
|
@@ -2385,8 +2533,7 @@ function getBrowserID(clientInfo) {
|
|
|
2385
2533
|
];
|
|
2386
2534
|
case 3:
|
|
2387
2535
|
hashBuffer = _state.sent();
|
|
2388
|
-
|
|
2389
|
-
hashHex = hashArray.map(function(b) {
|
|
2536
|
+
hashHex = Array.from(new Uint8Array(hashBuffer)).map(function(b) {
|
|
2390
2537
|
return b.toString(16).padStart(2, "0");
|
|
2391
2538
|
}).join("");
|
|
2392
2539
|
cachedBrowserId = hashHex;
|
|
@@ -2395,8 +2542,8 @@ function getBrowserID(clientInfo) {
|
|
|
2395
2542
|
hashHex
|
|
2396
2543
|
];
|
|
2397
2544
|
case 4:
|
|
2398
|
-
|
|
2399
|
-
console.warn("[StormcloudVideoPlayer] crypto.subtle
|
|
2545
|
+
unused = _state.sent();
|
|
2546
|
+
console.warn("[StormcloudVideoPlayer] crypto.subtle not supported, using fallback hash");
|
|
2400
2547
|
return [
|
|
2401
2548
|
3,
|
|
2402
2549
|
5
|
|
@@ -2420,177 +2567,91 @@ function getBrowserID(clientInfo) {
|
|
|
2420
2567
|
});
|
|
2421
2568
|
})();
|
|
2422
2569
|
}
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
var HEARTBEAT_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/heartbeat");
|
|
2426
|
-
var IMPRESSIONS_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/impressions/ingest");
|
|
2427
|
-
function buildHeaders(licenseKey) {
|
|
2428
|
-
var headers = {
|
|
2429
|
-
"Content-Type": "application/json"
|
|
2430
|
-
};
|
|
2431
|
-
if (licenseKey) {
|
|
2432
|
-
headers["Authorization"] = "Bearer ".concat(licenseKey);
|
|
2433
|
-
}
|
|
2434
|
-
return headers;
|
|
2570
|
+
function canPublish(licenseKey) {
|
|
2571
|
+
return Boolean(isMQTTEnabled() && licenseKey);
|
|
2435
2572
|
}
|
|
2436
|
-
function
|
|
2573
|
+
function buildPlayerMetricEvent() {
|
|
2437
2574
|
return _async_to_generator(function() {
|
|
2438
|
-
var
|
|
2439
|
-
return _ts_generator(this, function(_state) {
|
|
2440
|
-
switch(_state.label){
|
|
2441
|
-
case 0:
|
|
2442
|
-
return [
|
|
2443
|
-
4,
|
|
2444
|
-
fetch(TRACK_URL, {
|
|
2445
|
-
method: "POST",
|
|
2446
|
-
headers: buildHeaders(licenseKey),
|
|
2447
|
-
body: JSON.stringify(body)
|
|
2448
|
-
})
|
|
2449
|
-
];
|
|
2450
|
-
case 1:
|
|
2451
|
-
response = _state.sent();
|
|
2452
|
-
if (!response.ok) {
|
|
2453
|
-
throw new Error("HTTP error! status: ".concat(response.status));
|
|
2454
|
-
}
|
|
2455
|
-
return [
|
|
2456
|
-
4,
|
|
2457
|
-
response.json()
|
|
2458
|
-
];
|
|
2459
|
-
case 2:
|
|
2460
|
-
_state.sent();
|
|
2461
|
-
return [
|
|
2462
|
-
2
|
|
2463
|
-
];
|
|
2464
|
-
}
|
|
2465
|
-
});
|
|
2466
|
-
})();
|
|
2467
|
-
}
|
|
2468
|
-
function postJson(url, licenseKey, body) {
|
|
2469
|
-
return _async_to_generator(function() {
|
|
2470
|
-
var response;
|
|
2471
|
-
return _ts_generator(this, function(_state) {
|
|
2472
|
-
switch(_state.label){
|
|
2473
|
-
case 0:
|
|
2474
|
-
return [
|
|
2475
|
-
4,
|
|
2476
|
-
fetch(url, {
|
|
2477
|
-
method: "POST",
|
|
2478
|
-
headers: buildHeaders(licenseKey),
|
|
2479
|
-
body: JSON.stringify(body)
|
|
2480
|
-
})
|
|
2481
|
-
];
|
|
2482
|
-
case 1:
|
|
2483
|
-
response = _state.sent();
|
|
2484
|
-
if (!response.ok) {
|
|
2485
|
-
throw new Error("HTTP error! status: ".concat(response.status));
|
|
2486
|
-
}
|
|
2487
|
-
return [
|
|
2488
|
-
4,
|
|
2489
|
-
response.json()
|
|
2490
|
-
];
|
|
2491
|
-
case 2:
|
|
2492
|
-
_state.sent();
|
|
2493
|
-
return [
|
|
2494
|
-
2
|
|
2495
|
-
];
|
|
2496
|
-
}
|
|
2497
|
-
});
|
|
2498
|
-
})();
|
|
2499
|
-
}
|
|
2500
|
-
function buildPlayerMetricEvent(_0) {
|
|
2501
|
-
return _async_to_generator(function(licenseKey) {
|
|
2502
|
-
var context, flags, _flags_captureAt, clientInfo, browserId, captureAt;
|
|
2575
|
+
var context, flags, _flags_captureAt, _flags_adLoaded, _flags_adDetect, clientInfo, playerId, captureAt;
|
|
2503
2576
|
var _arguments = arguments;
|
|
2504
2577
|
return _ts_generator(this, function(_state) {
|
|
2505
2578
|
switch(_state.label){
|
|
2506
2579
|
case 0:
|
|
2507
|
-
context = _arguments.length >
|
|
2580
|
+
context = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : {}, flags = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
|
|
2508
2581
|
clientInfo = getClientInfo();
|
|
2509
2582
|
return [
|
|
2510
2583
|
4,
|
|
2511
2584
|
getBrowserID(clientInfo)
|
|
2512
2585
|
];
|
|
2513
2586
|
case 1:
|
|
2514
|
-
|
|
2587
|
+
playerId = _state.sent();
|
|
2515
2588
|
captureAt = (_flags_captureAt = flags.captureAt) !== null && _flags_captureAt !== void 0 ? _flags_captureAt : /* @__PURE__ */ new Date().toISOString();
|
|
2516
2589
|
return [
|
|
2517
2590
|
2,
|
|
2518
|
-
{
|
|
2519
|
-
player_id:
|
|
2520
|
-
browserId: browserId,
|
|
2591
|
+
_object_spread({
|
|
2592
|
+
player_id: playerId,
|
|
2521
2593
|
device_type: clientInfo.deviceType,
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
timestamp: captureAt
|
|
2530
|
-
}
|
|
2594
|
+
os: clientInfo.os.toLowerCase(),
|
|
2595
|
+
ad_loaded: (_flags_adLoaded = flags.adLoaded) !== null && _flags_adLoaded !== void 0 ? _flags_adLoaded : false,
|
|
2596
|
+
ad_detect: (_flags_adDetect = flags.adDetect) !== null && _flags_adDetect !== void 0 ? _flags_adDetect : false,
|
|
2597
|
+
capture_at: captureAt
|
|
2598
|
+
}, context.inputStreamType ? {
|
|
2599
|
+
input_stream_type: context.inputStreamType
|
|
2600
|
+
} : {})
|
|
2531
2601
|
];
|
|
2532
2602
|
}
|
|
2533
2603
|
});
|
|
2534
2604
|
}).apply(this, arguments);
|
|
2535
2605
|
}
|
|
2606
|
+
function publishTracking(licenseKey, channel, body) {
|
|
2607
|
+
ensureMQTTClient();
|
|
2608
|
+
publishMQTT(buildPlayerTopic(licenseKey, channel), body);
|
|
2609
|
+
}
|
|
2536
2610
|
function sendInitialTracking(_0) {
|
|
2537
2611
|
return _async_to_generator(function(licenseKey) {
|
|
2538
|
-
var context,
|
|
2612
|
+
var context, metricEvent, error;
|
|
2539
2613
|
var _arguments = arguments;
|
|
2540
2614
|
return _ts_generator(this, function(_state) {
|
|
2541
2615
|
switch(_state.label){
|
|
2542
2616
|
case 0:
|
|
2543
2617
|
context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
|
|
2618
|
+
if (!canPublish(licenseKey)) return [
|
|
2619
|
+
2
|
|
2620
|
+
];
|
|
2544
2621
|
_state.label = 1;
|
|
2545
2622
|
case 1:
|
|
2546
2623
|
_state.trys.push([
|
|
2547
2624
|
1,
|
|
2548
|
-
|
|
2625
|
+
3,
|
|
2549
2626
|
,
|
|
2550
|
-
|
|
2627
|
+
4
|
|
2551
2628
|
]);
|
|
2552
|
-
clientInfo = getClientInfo();
|
|
2553
|
-
return [
|
|
2554
|
-
4,
|
|
2555
|
-
getBrowserID(clientInfo)
|
|
2556
|
-
];
|
|
2557
|
-
case 2:
|
|
2558
|
-
browserId = _state.sent();
|
|
2559
|
-
trackingData = _object_spread({
|
|
2560
|
-
browserId: browserId
|
|
2561
|
-
}, clientInfo);
|
|
2562
2629
|
return [
|
|
2563
2630
|
4,
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
player_id: browserId,
|
|
2568
|
-
device_type: clientInfo.deviceType,
|
|
2569
|
-
input_stream_type: context.inputStreamType,
|
|
2570
|
-
os: clientInfo.os,
|
|
2571
|
-
ad_loaded: false,
|
|
2572
|
-
ad_detect: false,
|
|
2573
|
-
license_key: licenseKey,
|
|
2574
|
-
capture_at: /* @__PURE__ */ new Date().toISOString()
|
|
2575
|
-
}
|
|
2576
|
-
],
|
|
2577
|
-
trackingData: trackingData
|
|
2631
|
+
buildPlayerMetricEvent(context, {
|
|
2632
|
+
adLoaded: false,
|
|
2633
|
+
adDetect: false
|
|
2578
2634
|
})
|
|
2579
2635
|
];
|
|
2580
|
-
case
|
|
2581
|
-
_state.sent();
|
|
2636
|
+
case 2:
|
|
2637
|
+
metricEvent = _state.sent();
|
|
2638
|
+
publishTracking(licenseKey, "metrics", {
|
|
2639
|
+
events: [
|
|
2640
|
+
metricEvent
|
|
2641
|
+
]
|
|
2642
|
+
});
|
|
2582
2643
|
return [
|
|
2583
2644
|
3,
|
|
2584
|
-
|
|
2645
|
+
4
|
|
2585
2646
|
];
|
|
2586
|
-
case
|
|
2647
|
+
case 3:
|
|
2587
2648
|
error = _state.sent();
|
|
2588
2649
|
console.error("[StormcloudVideoPlayer] Error sending initial tracking data:", error);
|
|
2589
2650
|
return [
|
|
2590
2651
|
3,
|
|
2591
|
-
|
|
2652
|
+
4
|
|
2592
2653
|
];
|
|
2593
|
-
case
|
|
2654
|
+
case 4:
|
|
2594
2655
|
return [
|
|
2595
2656
|
2
|
|
2596
2657
|
];
|
|
@@ -2694,53 +2755,48 @@ function sendAdImpressionTracking(_0, _1) {
|
|
|
2694
2755
|
switch(_state.label){
|
|
2695
2756
|
case 0:
|
|
2696
2757
|
context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
|
|
2758
|
+
if (!canPublish(licenseKey)) return [
|
|
2759
|
+
2
|
|
2760
|
+
];
|
|
2697
2761
|
_state.label = 1;
|
|
2698
2762
|
case 1:
|
|
2699
2763
|
_state.trys.push([
|
|
2700
2764
|
1,
|
|
2701
|
-
|
|
2765
|
+
3,
|
|
2702
2766
|
,
|
|
2703
|
-
|
|
2767
|
+
4
|
|
2704
2768
|
]);
|
|
2705
2769
|
return [
|
|
2706
2770
|
4,
|
|
2707
|
-
buildPlayerMetricEvent(
|
|
2771
|
+
buildPlayerMetricEvent(context, {
|
|
2708
2772
|
captureAt: adImpressionInfo.timestamp
|
|
2709
2773
|
})
|
|
2710
2774
|
];
|
|
2711
2775
|
case 2:
|
|
2712
2776
|
metricEvent = _state.sent();
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
capture_at: adImpressionInfo.timestamp
|
|
2725
|
-
}
|
|
2726
|
-
]
|
|
2727
|
-
})
|
|
2728
|
-
])
|
|
2729
|
-
];
|
|
2730
|
-
case 3:
|
|
2731
|
-
_state.sent();
|
|
2777
|
+
publishTracking(licenseKey, "heartbeat", metricEvent);
|
|
2778
|
+
publishTracking(licenseKey, "impressions", {
|
|
2779
|
+
events: [
|
|
2780
|
+
{
|
|
2781
|
+
player_id: metricEvent.player_id,
|
|
2782
|
+
ad_played_count: 1,
|
|
2783
|
+
ad_url: adImpressionInfo.adUrl,
|
|
2784
|
+
capture_at: adImpressionInfo.timestamp
|
|
2785
|
+
}
|
|
2786
|
+
]
|
|
2787
|
+
});
|
|
2732
2788
|
return [
|
|
2733
2789
|
3,
|
|
2734
|
-
|
|
2790
|
+
4
|
|
2735
2791
|
];
|
|
2736
|
-
case
|
|
2792
|
+
case 3:
|
|
2737
2793
|
error = _state.sent();
|
|
2738
2794
|
console.error("[StormcloudVideoPlayer] Error sending ad impression tracking:", error);
|
|
2739
2795
|
return [
|
|
2740
2796
|
3,
|
|
2741
|
-
|
|
2797
|
+
4
|
|
2742
2798
|
];
|
|
2743
|
-
case
|
|
2799
|
+
case 4:
|
|
2744
2800
|
return [
|
|
2745
2801
|
2
|
|
2746
2802
|
];
|
|
@@ -2756,38 +2812,36 @@ function sendHeartbeat(_0) {
|
|
|
2756
2812
|
switch(_state.label){
|
|
2757
2813
|
case 0:
|
|
2758
2814
|
context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, flags = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
|
|
2815
|
+
if (!canPublish(licenseKey)) return [
|
|
2816
|
+
2
|
|
2817
|
+
];
|
|
2759
2818
|
_state.label = 1;
|
|
2760
2819
|
case 1:
|
|
2761
2820
|
_state.trys.push([
|
|
2762
2821
|
1,
|
|
2763
|
-
|
|
2822
|
+
3,
|
|
2764
2823
|
,
|
|
2765
|
-
|
|
2824
|
+
4
|
|
2766
2825
|
]);
|
|
2767
2826
|
return [
|
|
2768
2827
|
4,
|
|
2769
|
-
buildPlayerMetricEvent(
|
|
2828
|
+
buildPlayerMetricEvent(context, flags)
|
|
2770
2829
|
];
|
|
2771
2830
|
case 2:
|
|
2772
2831
|
heartbeatData = _state.sent();
|
|
2773
|
-
|
|
2774
|
-
4,
|
|
2775
|
-
postJson(HEARTBEAT_URL, licenseKey, heartbeatData)
|
|
2776
|
-
];
|
|
2777
|
-
case 3:
|
|
2778
|
-
_state.sent();
|
|
2832
|
+
publishTracking(licenseKey, "heartbeat", heartbeatData);
|
|
2779
2833
|
return [
|
|
2780
2834
|
3,
|
|
2781
|
-
|
|
2835
|
+
4
|
|
2782
2836
|
];
|
|
2783
|
-
case
|
|
2837
|
+
case 3:
|
|
2784
2838
|
error = _state.sent();
|
|
2785
2839
|
console.error("[StormcloudVideoPlayer] Error sending heartbeat:", error);
|
|
2786
2840
|
return [
|
|
2787
2841
|
3,
|
|
2788
|
-
|
|
2842
|
+
4
|
|
2789
2843
|
];
|
|
2790
|
-
case
|
|
2844
|
+
case 4:
|
|
2791
2845
|
return [
|
|
2792
2846
|
2
|
|
2793
2847
|
];
|
|
@@ -4726,6 +4780,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4726
4780
|
key: "initializeTracking",
|
|
4727
4781
|
value: function initializeTracking() {
|
|
4728
4782
|
var _this = this;
|
|
4783
|
+
if (isMQTTEnabled()) {
|
|
4784
|
+
initMQTTClient();
|
|
4785
|
+
}
|
|
4729
4786
|
sendInitialTracking(this.config.licenseKey, this.getAnalyticsContext()).then(function() {
|
|
4730
4787
|
_this.heartbeatInterval = window.setInterval(function() {
|
|
4731
4788
|
_this.sendHeartbeatIfNeeded();
|
|
@@ -6405,6 +6462,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6405
6462
|
clearInterval(this.heartbeatInterval);
|
|
6406
6463
|
this.heartbeatInterval = void 0;
|
|
6407
6464
|
}
|
|
6465
|
+
if (isMQTTEnabled()) {
|
|
6466
|
+
disconnectMQTT();
|
|
6467
|
+
}
|
|
6408
6468
|
(_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.destroy();
|
|
6409
6469
|
(_this_adLayer = this.adLayer) === null || _this_adLayer === void 0 ? void 0 : _this_adLayer.destroy();
|
|
6410
6470
|
this.consecutiveFailures = 0;
|
|
@@ -8845,6 +8905,7 @@ var StormcloudPlayer = createStormcloudPlayer(players_default, players_default[p
|
|
|
8845
8905
|
var StormcloudPlayer_default = StormcloudPlayer;
|
|
8846
8906
|
// Annotate the CommonJS export names for ESM import in node:
|
|
8847
8907
|
0 && (module.exports = {
|
|
8908
|
+
DEFAULT_MQTT_CONFIG: DEFAULT_MQTT_CONFIG,
|
|
8848
8909
|
IS_BROWSER: IS_BROWSER,
|
|
8849
8910
|
IS_GLOBAL: IS_GLOBAL,
|
|
8850
8911
|
IS_IOS: IS_IOS,
|
|
@@ -8854,22 +8915,35 @@ var StormcloudPlayer_default = StormcloudPlayer;
|
|
|
8854
8915
|
StormcloudPlayer: StormcloudPlayer,
|
|
8855
8916
|
StormcloudVideoPlayer: StormcloudVideoPlayer,
|
|
8856
8917
|
StormcloudVideoPlayerComponent: StormcloudVideoPlayerComponent,
|
|
8918
|
+
applyMQTTConfig: applyMQTTConfig,
|
|
8919
|
+
buildMQTTBrokerUrl: buildMQTTBrokerUrl,
|
|
8920
|
+
buildPlayerTopic: buildPlayerTopic,
|
|
8857
8921
|
canPlay: canPlay,
|
|
8922
|
+
configureMQTT: configureMQTT,
|
|
8858
8923
|
createStormcloudPlayer: createStormcloudPlayer,
|
|
8859
8924
|
createVastAdLayer: createVastAdLayer,
|
|
8860
8925
|
createVastManager: createVastManager,
|
|
8861
8926
|
detectBrowser: detectBrowser,
|
|
8927
|
+
disconnectMQTT: disconnectMQTT,
|
|
8928
|
+
ensureMQTTClient: ensureMQTTClient,
|
|
8862
8929
|
getBrowserConfigOverrides: getBrowserConfigOverrides,
|
|
8863
8930
|
getBrowserID: getBrowserID,
|
|
8864
8931
|
getClientInfo: getClientInfo,
|
|
8932
|
+
getMQTTStatus: getMQTTStatus,
|
|
8933
|
+
initMQTTClient: initMQTTClient,
|
|
8865
8934
|
initializePolyfills: initializePolyfills,
|
|
8935
|
+
isMQTTConfigured: isMQTTConfigured,
|
|
8936
|
+
isMQTTConnected: isMQTTConnected,
|
|
8937
|
+
isMQTTEnabled: isMQTTEnabled,
|
|
8866
8938
|
isMediaStream: isMediaStream,
|
|
8867
8939
|
lazy: lazy,
|
|
8868
8940
|
logBrowserInfo: logBrowserInfo,
|
|
8869
8941
|
merge: merge,
|
|
8942
|
+
mqttConfig: mqttConfig,
|
|
8870
8943
|
omit: omit,
|
|
8871
8944
|
parseQuery: parseQuery,
|
|
8872
8945
|
players: players,
|
|
8946
|
+
publishMQTT: publishMQTT,
|
|
8873
8947
|
randomString: randomString,
|
|
8874
8948
|
sendHeartbeat: sendHeartbeat,
|
|
8875
8949
|
sendInitialTracking: sendInitialTracking,
|