stormcloud-video-player 0.8.53 → 0.8.55

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.
Files changed (70) hide show
  1. package/dist/stormcloud-vp.min.js +1 -1
  2. package/lib/index.cjs +204 -110
  3. package/lib/index.cjs.map +1 -1
  4. package/lib/index.d.cts +2 -0
  5. package/lib/index.d.ts +2 -0
  6. package/lib/index.js +204 -110
  7. package/lib/index.js.map +1 -1
  8. package/lib/player/AdBreakOrchestrator.cjs +69 -66
  9. package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
  10. package/lib/player/AdBreakOrchestrator.d.cts +1 -1
  11. package/lib/player/AdConfigManager.cjs +38 -33
  12. package/lib/player/AdConfigManager.cjs.map +1 -1
  13. package/lib/player/AdConfigManager.d.cts +1 -1
  14. package/lib/player/AdTimingService.cjs +18 -25
  15. package/lib/player/AdTimingService.cjs.map +1 -1
  16. package/lib/player/AdTimingService.d.cts +1 -1
  17. package/lib/player/HlsEngine.cjs +86 -30
  18. package/lib/player/HlsEngine.cjs.map +1 -1
  19. package/lib/player/HlsEngine.d.cts +6 -1
  20. package/lib/player/PlaceholderLayer.cjs +1 -3
  21. package/lib/player/PlaceholderLayer.cjs.map +1 -1
  22. package/lib/player/PlayerControls.cjs.map +1 -1
  23. package/lib/player/PlayerControls.d.cts +1 -1
  24. package/lib/player/Scte35CueManager.cjs +2 -4
  25. package/lib/player/Scte35CueManager.cjs.map +1 -1
  26. package/lib/player/Scte35CueManager.d.cts +1 -1
  27. package/lib/player/Scte35Parser.cjs +6 -12
  28. package/lib/player/Scte35Parser.cjs.map +1 -1
  29. package/lib/player/Scte35Parser.d.cts +1 -1
  30. package/lib/player/StormcloudVideoPlayer.cjs +194 -96
  31. package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
  32. package/lib/player/StormcloudVideoPlayer.d.cts +2 -1
  33. package/lib/player/playerTypes.cjs.map +1 -1
  34. package/lib/player/playerTypes.d.cts +1 -1
  35. package/lib/players/FilePlayer.cjs +17 -26
  36. package/lib/players/FilePlayer.cjs.map +1 -1
  37. package/lib/players/HlsPlayer.cjs +204 -110
  38. package/lib/players/HlsPlayer.cjs.map +1 -1
  39. package/lib/players/HlsPlayer.d.cts +1 -1
  40. package/lib/players/index.cjs +204 -110
  41. package/lib/players/index.cjs.map +1 -1
  42. package/lib/sdk/hlsAdPlayer.cjs +42 -19
  43. package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
  44. package/lib/sdk/hlsAdPlayer.d.cts +1 -1
  45. package/lib/sdk/pal.cjs +6 -9
  46. package/lib/sdk/pal.cjs.map +1 -1
  47. package/lib/{types-cTqIKw_D.d.cts → types-DpbgEvSH.d.cts} +1 -0
  48. package/lib/ui/StormcloudVideoPlayer.cjs +194 -96
  49. package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
  50. package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
  51. package/lib/utils/browserCompat.cjs +3 -6
  52. package/lib/utils/browserCompat.cjs.map +1 -1
  53. package/lib/utils/ctvVastSignals.cjs +3 -6
  54. package/lib/utils/ctvVastSignals.cjs.map +1 -1
  55. package/lib/utils/devUrl.cjs.map +1 -1
  56. package/lib/utils/mqttClient.cjs +1 -3
  57. package/lib/utils/mqttClient.cjs.map +1 -1
  58. package/lib/utils/mqttConfig.cjs +1 -3
  59. package/lib/utils/mqttConfig.cjs.map +1 -1
  60. package/lib/utils/polyfills.cjs +4 -7
  61. package/lib/utils/polyfills.cjs.map +1 -1
  62. package/lib/utils/tracking.cjs +27 -20
  63. package/lib/utils/tracking.cjs.map +1 -1
  64. package/lib/utils/tracking.d.cts +1 -1
  65. package/lib/utils/vastEnvironmentSignals.cjs +7 -6
  66. package/lib/utils/vastEnvironmentSignals.cjs.map +1 -1
  67. package/lib/utils/vastEnvironmentSignals.d.cts +2 -1
  68. package/lib/utils/vastMacros.cjs +4 -2
  69. package/lib/utils/vastMacros.cjs.map +1 -1
  70. package/package.json +1 -1
@@ -15,11 +15,8 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
15
15
  reject(error);
16
16
  return;
17
17
  }
18
- if (info.done) {
19
- resolve(value);
20
- } else {
21
- Promise.resolve(value).then(_next, _throw);
22
- }
18
+ if (info.done) resolve(value);
19
+ else Promise.resolve(value).then(_next, _throw);
23
20
  }
24
21
  function _async_to_generator(fn) {
25
22
  return function() {
@@ -37,9 +34,7 @@ function _async_to_generator(fn) {
37
34
  };
38
35
  }
39
36
  function _class_call_check(instance, Constructor) {
40
- if (!(instance instanceof Constructor)) {
41
- throw new TypeError("Cannot call a class as a function");
42
- }
37
+ if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
43
38
  }
44
39
  function _defineProperties(target, props) {
45
40
  for(var i = 0; i < props.length; i++){
@@ -63,16 +58,16 @@ function _define_property(obj, key, value) {
63
58
  configurable: true,
64
59
  writable: true
65
60
  });
66
- } else {
67
- obj[key] = value;
68
- }
61
+ } else obj[key] = value;
69
62
  return obj;
70
63
  }
71
64
  function _iterable_to_array(iter) {
72
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
65
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) {
66
+ return Array.from(iter);
67
+ }
73
68
  }
74
69
  function _non_iterable_spread() {
75
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
70
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
76
71
  }
77
72
  function _object_spread(target) {
78
73
  for(var i = 1; i < arguments.length; i++){
@@ -92,18 +87,6 @@ function _object_spread(target) {
92
87
  function _to_consumable_array(arr) {
93
88
  return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
94
89
  }
95
- function _type_of(obj) {
96
- "@swc/helpers - typeof";
97
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
98
- }
99
- function _unsupported_iterable_to_array(o, minLen) {
100
- if (!o) return;
101
- if (typeof o === "string") return _array_like_to_array(o, minLen);
102
- var n = Object.prototype.toString.call(o).slice(8, -1);
103
- if (n === "Object" && o.constructor) n = o.constructor.name;
104
- if (n === "Map" || n === "Set") return Array.from(n);
105
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
106
- }
107
90
  function _ts_generator(thisArg, body) {
108
91
  var f, y, t, _ = {
109
92
  label: 0,
@@ -205,18 +188,36 @@ function _ts_generator(thisArg, body) {
205
188
  }
206
189
  function _ts_values(o) {
207
190
  var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
208
- if (m) return m.call(o);
209
- if (o && typeof o.length === "number") return {
210
- next: function() {
211
- if (o && i >= o.length) o = void 0;
212
- return {
213
- value: o && o[i++],
214
- done: !o
215
- };
216
- }
217
- };
191
+ if (m) {
192
+ return m.call(o);
193
+ }
194
+ if (o && typeof o.length === "number") {
195
+ return {
196
+ next: function() {
197
+ if (o && i >= o.length) {
198
+ o = void 0;
199
+ }
200
+ return {
201
+ value: o && o[i++],
202
+ done: !o
203
+ };
204
+ }
205
+ };
206
+ }
218
207
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
219
208
  }
209
+ function _type_of(obj) {
210
+ "@swc/helpers - typeof";
211
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
212
+ }
213
+ function _unsupported_iterable_to_array(o, minLen) {
214
+ if (!o) return;
215
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
216
+ var n = Object.prototype.toString.call(o).slice(8, -1);
217
+ if (n === "Object" && o.constructor) n = o.constructor.name;
218
+ if (n === "Map" || n === "Set") return Array.from(n);
219
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
220
+ }
220
221
  var __create = Object.create;
221
222
  var __defProp = Object.defineProperty;
222
223
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1144,7 +1145,7 @@ function buildPlayerMetricEvent() {
1144
1145
  if (debugAdTiming) {
1145
1146
  console.log("[StormcloudVideoPlayer] playerId: ", playerId);
1146
1147
  }
1147
- captureAt = (_flags_captureAt = flags.captureAt) !== null && _flags_captureAt !== void 0 ? _flags_captureAt : /* @__PURE__ */ new Date().toISOString();
1148
+ captureAt = (_flags_captureAt = flags.captureAt) !== null && _flags_captureAt !== void 0 ? _flags_captureAt : (/* @__PURE__ */ new Date()).toISOString();
1148
1149
  return [
1149
1150
  2,
1150
1151
  _object_spread({
@@ -1163,8 +1164,19 @@ function buildPlayerMetricEvent() {
1163
1164
  }).apply(this, arguments);
1164
1165
  }
1165
1166
  function publishTracking(licenseKey, channel, body) {
1167
+ var debug = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : false;
1166
1168
  ensureMQTTClient();
1167
- publishMQTT(buildPlayerTopic(licenseKey, channel), body);
1169
+ var topic = buildPlayerTopic(licenseKey, channel);
1170
+ var published = publishMQTT(topic, body);
1171
+ if (debug) {
1172
+ console.log("[StormcloudVideoPlayer] publishTracking:", JSON.stringify({
1173
+ licenseKey: licenseKey,
1174
+ channel: channel,
1175
+ topic: topic,
1176
+ body: body,
1177
+ published: published
1178
+ }, null, 2));
1179
+ }
1168
1180
  }
1169
1181
  function sendAdLoadedTracking(_0, _1) {
1170
1182
  return _async_to_generator(function(licenseKey, adLoadedInfo) {
@@ -1212,7 +1224,7 @@ function sendAdLoadedTracking(_0, _1) {
1212
1224
  }
1213
1225
  function sendAdImpressionTracking(_0, _1) {
1214
1226
  return _async_to_generator(function(licenseKey, adImpressionInfo) {
1215
- var context, metricEvent, error;
1227
+ var context, _adImpressionInfo_adUrl, metricEvent, error;
1216
1228
  var _arguments = arguments;
1217
1229
  return _ts_generator(this, function(_state) {
1218
1230
  switch(_state.label){
@@ -1237,17 +1249,18 @@ function sendAdImpressionTracking(_0, _1) {
1237
1249
  ];
1238
1250
  case 2:
1239
1251
  metricEvent = _state.sent();
1240
- publishTracking(licenseKey, "heartbeat", metricEvent);
1252
+ publishTracking(licenseKey, "heartbeat", metricEvent, !!context.debugAdTiming);
1241
1253
  publishTracking(licenseKey, "impressions", {
1242
1254
  events: [
1243
1255
  {
1256
+ event_id: createUuid(),
1244
1257
  player_id: metricEvent.player_id,
1245
1258
  ad_played_count: 1,
1246
- ad_url: adImpressionInfo.adUrl,
1259
+ ad_url: (_adImpressionInfo_adUrl = adImpressionInfo.adUrl) !== null && _adImpressionInfo_adUrl !== void 0 ? _adImpressionInfo_adUrl : adImpressionInfo.adId,
1247
1260
  capture_at: adImpressionInfo.timestamp
1248
1261
  }
1249
1262
  ]
1250
- });
1263
+ }, !!context.debugAdTiming);
1251
1264
  return [
1252
1265
  3,
1253
1266
  4
@@ -1292,7 +1305,7 @@ function sendHeartbeat(_0) {
1292
1305
  ];
1293
1306
  case 2:
1294
1307
  heartbeatData = _state.sent();
1295
- publishTracking(licenseKey, "heartbeat", heartbeatData);
1308
+ publishTracking(licenseKey, "heartbeat", heartbeatData, !!context.debugAdTiming);
1296
1309
  return [
1297
1310
  3,
1298
1311
  4
@@ -1372,27 +1385,22 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
1372
1385
  console.log("[POD] Playing pod ad ".concat((payload === null || payload === void 0 ? void 0 : payload.index) != null ? payload.index + 1 : "?", "/").concat((_ref = payload === null || payload === void 0 ? void 0 : payload.total) !== null && _ref !== void 0 ? _ref : "?"));
1373
1386
  }
1374
1387
  });
1375
- adPlayer.on("all_ads_completed", function() {
1376
- sendAdImpressionTracking(_this.host.config.licenseKey, {
1388
+ adPlayer.on("ad_impression", function(payload) {
1389
+ var impressionInfo = {
1377
1390
  source: "hls",
1378
1391
  adIndex: _this.timing.currentAdIndex,
1379
- timestamp: /* @__PURE__ */ new Date().toISOString()
1380
- }, _this.analyticsContext).catch(function() {});
1381
- _this.timing.recordPlayedAdDuration(_this.host.getAdPlayer());
1382
- var remaining = _this.timing.getRemainingAdMs();
1383
- _this.timing.consecutiveFailures = 0;
1384
- if (_this.debug) {
1385
- console.log("[StormcloudVideoPlayer] all_ads_completed event received - remaining=".concat(remaining, "ms, queued ads=").concat(_this.adRequestQueue.length), _this.adRequestQueue.length > 0 ? {
1386
- queuedUrls: _to_consumable_array(_this.adRequestQueue)
1387
- } : {});
1392
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
1393
+ };
1394
+ if (payload === null || payload === void 0 ? void 0 : payload.adId) impressionInfo.adId = payload.adId;
1395
+ if (payload === null || payload === void 0 ? void 0 : payload.mediaUrl) impressionInfo.adUrl = payload.mediaUrl;
1396
+ if ((payload === null || payload === void 0 ? void 0 : payload.durationSeconds) != null) {
1397
+ impressionInfo.durationSeconds = payload.durationSeconds;
1388
1398
  }
1389
- if (_this.inAdBreak) {
1390
- if (_this.timing.hasTimeToStartAnotherAd()) {
1391
- _this.tryNextAvailableAdWithRateLimit();
1392
- } else {
1393
- _this.handleAdPodComplete();
1399
+ sendAdImpressionTracking(_this.host.config.licenseKey, impressionInfo, _this.analyticsContext).catch(function(error) {
1400
+ if (_this.debug) {
1401
+ console.warn("[AdBreakOrchestrator] Failed to send ad impression tracking:", error);
1394
1402
  }
1395
- }
1403
+ });
1396
1404
  });
1397
1405
  adPlayer.on("ad_error", function(errorPayload) {
1398
1406
  var errorMessage = "Ad playback failed";
@@ -1435,11 +1443,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
1435
1443
  }
1436
1444
  });
1437
1445
  adPlayer.on("content_resume", function() {
1438
- sendAdImpressionTracking(_this.host.config.licenseKey, {
1439
- source: "hls",
1440
- adIndex: _this.timing.currentAdIndex,
1441
- timestamp: /* @__PURE__ */ new Date().toISOString()
1442
- }, _this.analyticsContext).catch(function() {});
1443
1446
  if (!_this.host.video.muted) {
1444
1447
  _this.host.video.muted = true;
1445
1448
  if (_this.debug) {
@@ -1677,7 +1680,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
1677
1680
  sendAdLoadedTracking(this.host.config.licenseKey, {
1678
1681
  source: "hls",
1679
1682
  vastUrl: podUrl,
1680
- timestamp: /* @__PURE__ */ new Date().toISOString()
1683
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
1681
1684
  }, this.analyticsContext).catch(function() {});
1682
1685
  this.timing.startAdFailsafeTimer(requestToken);
1683
1686
  return [
@@ -2197,7 +2200,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2197
2200
  sendAdLoadedTracking(this.host.config.licenseKey, {
2198
2201
  source: "hls",
2199
2202
  vastUrl: vastTagUrl,
2200
- timestamp: /* @__PURE__ */ new Date().toISOString()
2203
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
2201
2204
  }, this.analyticsContext).catch(function() {});
2202
2205
  this.timing.clearAdRequestWatchdog();
2203
2206
  if (this.timing.activeAdRequestToken !== requestToken) return [