stormcloud-video-player 0.3.53 → 0.3.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.
package/lib/sdk/ima.cjs CHANGED
@@ -41,9 +41,17 @@ function _ts_generator(thisArg, body) {
41
41
  },
42
42
  trys: [],
43
43
  ops: []
44
- }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
45
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
46
- return this;
44
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
45
+ return d(g, "next", {
46
+ value: verb(0)
47
+ }), d(g, "throw", {
48
+ value: verb(1)
49
+ }), d(g, "return", {
50
+ value: verb(2)
51
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
52
+ value: function() {
53
+ return this;
54
+ }
47
55
  }), g;
48
56
  function verb(n) {
49
57
  return function(v) {
@@ -127,20 +135,20 @@ var __defProp = Object.defineProperty;
127
135
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
128
136
  var __getOwnPropNames = Object.getOwnPropertyNames;
129
137
  var __hasOwnProp = Object.prototype.hasOwnProperty;
130
- var __export = function(target, all) {
138
+ var __export = function __export(target, all) {
131
139
  for(var name in all)__defProp(target, name, {
132
140
  get: all[name],
133
141
  enumerable: true
134
142
  });
135
143
  };
136
- var __copyProps = function(to, from, except, desc) {
144
+ var __copyProps = function __copyProps(to, from, except, desc) {
137
145
  if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
138
146
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
139
147
  try {
140
148
  var _loop = function() {
141
149
  var key = _step.value;
142
150
  if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
143
- get: function() {
151
+ get: function get() {
144
152
  return from[key];
145
153
  },
146
154
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
@@ -164,7 +172,7 @@ var __copyProps = function(to, from, except, desc) {
164
172
  }
165
173
  return to;
166
174
  };
167
- var __toCommonJS = function(mod) {
175
+ var __toCommonJS = function __toCommonJS(mod) {
168
176
  return __copyProps(__defProp({}, "__esModule", {
169
177
  value: true
170
178
  }), mod);
@@ -172,7 +180,7 @@ var __toCommonJS = function(mod) {
172
180
  // src/sdk/ima.ts
173
181
  var ima_exports = {};
174
182
  __export(ima_exports, {
175
- createImaController: function() {
183
+ createImaController: function createImaController1() {
176
184
  return createImaController;
177
185
  }
178
186
  });
@@ -470,7 +478,7 @@ function createImaController(video, options) {
470
478
  var fn = _step.value;
471
479
  try {
472
480
  fn(payload);
473
- } catch (e) {}
481
+ } catch (unused) {}
474
482
  }
475
483
  } catch (err) {
476
484
  _didIteratorError = true;
@@ -508,7 +516,7 @@ function createImaController(video, options) {
508
516
  console.error("StormcloudVideoPlayer: The host page is inside a sandboxed iframe without 'allow-scripts'. Google IMA cannot run ads within sandboxed frames. Remove the sandbox attribute or include 'allow-scripts allow-same-origin'.");
509
517
  }
510
518
  }
511
- } catch (e) {}
519
+ } catch (unused) {}
512
520
  if (typeof window !== "undefined" && ((_window_google = window.google) === null || _window_google === void 0 ? void 0 : _window_google.ima)) return Promise.resolve();
513
521
  var existing = document.querySelector('script[data-ima="true"]');
514
522
  if (existing) {
@@ -550,9 +558,6 @@ function createImaController(video, options) {
550
558
  var adDisplayContainer;
551
559
  var adContainerEl;
552
560
  var lastAdTagUrl;
553
- var retryAttempts = 0;
554
- var maxRetries = 2;
555
- var backoffBaseMs = 500;
556
561
  var adsLoadedPromise;
557
562
  var adsLoadedResolve;
558
563
  var adsLoadedReject;
@@ -756,7 +761,7 @@ function createImaController(video, options) {
756
761
  if (adsManager) {
757
762
  try {
758
763
  adsManager.destroy();
759
- } catch (e) {}
764
+ } catch (unused) {}
760
765
  adsManager = void 0;
761
766
  }
762
767
  if (adVideoElement) {
@@ -767,7 +772,7 @@ function createImaController(video, options) {
767
772
  if (adsLoader) {
768
773
  try {
769
774
  adsLoader.destroy();
770
- } catch (e) {}
775
+ } catch (unused) {}
771
776
  adsLoader = void 0;
772
777
  }
773
778
  }
@@ -785,7 +790,7 @@ function createImaController(video, options) {
785
790
  try {
786
791
  var _adDisplayContainer_initialize;
787
792
  (_adDisplayContainer_initialize = adDisplayContainer.initialize) === null || _adDisplayContainer_initialize === void 0 ? void 0 : _adDisplayContainer_initialize.call(adDisplayContainer);
788
- } catch (e) {}
793
+ } catch (unused) {}
789
794
  }
790
795
  }).catch(function() {});
791
796
  },
@@ -849,7 +854,6 @@ function createImaController(video, options) {
849
854
  _state.sent();
850
855
  google = window.google;
851
856
  lastAdTagUrl = vastTagUrl;
852
- retryAttempts = 0;
853
857
  if (!adDisplayContainer) {
854
858
  container = document.createElement("div");
855
859
  container.style.position = "absolute";
@@ -933,32 +937,23 @@ function createImaController(video, options) {
933
937
  }
934
938
  }, 300);
935
939
  }
936
- hideContentVideo();
940
+ showContentVideo();
937
941
  if (adsLoadedReject) {
938
942
  adsLoadedReject(new Error("Ad playback error"));
939
943
  adsLoadedReject = void 0;
940
944
  adsLoadedResolve = void 0;
941
945
  }
942
- if (lastAdTagUrl && retryAttempts < maxRetries && !isNoFill) {
943
- var delay = backoffBaseMs * Math.pow(2, retryAttempts++);
944
- window.setTimeout(function() {
945
- try {
946
- makeAdsRequest(google, lastAdTagUrl);
947
- } catch (e) {}
948
- }, delay);
949
- } else {
950
- emit("ad_error", {
951
- code: errorCode,
952
- vastErrorCode: vastErrorCode,
953
- message: errorMessage,
954
- cause: innerError,
955
- isNoFill: isNoFill
956
- });
957
- if (!(options === null || options === void 0 ? void 0 : options.continueLiveStreamDuringAds)) {
958
- if (video.paused) {
959
- var _video_play;
960
- (_video_play = video.play()) === null || _video_play === void 0 ? void 0 : _video_play.catch(function() {});
961
- }
946
+ emit("ad_error", {
947
+ code: errorCode,
948
+ vastErrorCode: vastErrorCode,
949
+ message: errorMessage,
950
+ cause: innerError,
951
+ isNoFill: isNoFill
952
+ });
953
+ if (!(options === null || options === void 0 ? void 0 : options.continueLiveStreamDuringAds)) {
954
+ if (video.paused) {
955
+ var _video_play;
956
+ (_video_play = video.play()) === null || _video_play === void 0 ? void 0 : _video_play.catch(function() {});
962
957
  }
963
958
  }
964
959
  });
@@ -976,7 +971,7 @@ function createImaController(video, options) {
976
971
  if (adsManager) {
977
972
  try {
978
973
  adsManager.setVolume(adVolume);
979
- } catch (e) {}
974
+ } catch (unused) {}
980
975
  }
981
976
  emit("content_pause");
982
977
  });
@@ -990,7 +985,7 @@ function createImaController(video, options) {
990
985
  if (adsManager) {
991
986
  try {
992
987
  adsManager.setVolume(originalMutedState ? 0 : adVolume);
993
- } catch (e) {}
988
+ } catch (unused) {}
994
989
  }
995
990
  }
996
991
  if (adContainerEl) {
@@ -1004,7 +999,7 @@ function createImaController(video, options) {
1004
999
  adsManager.addEventListener(AdEvent.CONTENT_RESUME_REQUESTED, function() {
1005
1000
  adPlaying = false;
1006
1001
  setAdPlayingFlag(false);
1007
- hideContentVideo();
1002
+ showContentVideo();
1008
1003
  emit("content_resume");
1009
1004
  });
1010
1005
  adsManager.addEventListener(AdEvent.ALL_ADS_COMPLETED, function() {
@@ -1020,7 +1015,7 @@ function createImaController(video, options) {
1020
1015
  }
1021
1016
  }, 300);
1022
1017
  }
1023
- hideContentVideo();
1018
+ showContentVideo();
1024
1019
  emit("all_ads_completed");
1025
1020
  });
1026
1021
  if (adsLoadedResolve) {
@@ -1042,7 +1037,7 @@ function createImaController(video, options) {
1042
1037
  }
1043
1038
  }, 300);
1044
1039
  }
1045
- hideContentVideo();
1040
+ showContentVideo();
1046
1041
  if (adsLoadedReject) {
1047
1042
  adsLoadedReject(new Error("Failed to setup ads manager"));
1048
1043
  adsLoadedReject = void 0;
@@ -1085,7 +1080,7 @@ function createImaController(video, options) {
1085
1080
  }
1086
1081
  }, 300);
1087
1082
  }
1088
- hideContentVideo();
1083
+ showContentVideo();
1089
1084
  if (adsLoadedReject) {
1090
1085
  adsLoadedReject(new Error(isNoFill ? "No ads available" : "Ads loader error"));
1091
1086
  adsLoadedReject = void 0;
@@ -1151,7 +1146,7 @@ function createImaController(video, options) {
1151
1146
  }
1152
1147
  try {
1153
1148
  adsManager.setVolume(originalMutedState ? 0 : adVolume);
1154
- } catch (e) {}
1149
+ } catch (unused) {}
1155
1150
  adsManager.start();
1156
1151
  return [
1157
1152
  2,
@@ -1233,7 +1228,7 @@ function createImaController(video, options) {
1233
1228
  try {
1234
1229
  ;
1235
1230
  adsManager === null || adsManager === void 0 ? void 0 : (_adsManager_stop = adsManager.stop) === null || _adsManager_stop === void 0 ? void 0 : _adsManager_stop.call(adsManager);
1236
- } catch (e) {}
1231
+ } catch (unused) {}
1237
1232
  destroyAdsManager();
1238
1233
  return [
1239
1234
  2
@@ -1264,7 +1259,7 @@ function createImaController(video, options) {
1264
1259
  try {
1265
1260
  var _adsLoader_destroy;
1266
1261
  adsLoader === null || adsLoader === void 0 ? void 0 : (_adsLoader_destroy = adsLoader.destroy) === null || _adsLoader_destroy === void 0 ? void 0 : _adsLoader_destroy.call(adsLoader);
1267
- } catch (e) {}
1262
+ } catch (unused) {}
1268
1263
  adDisplayContainer = void 0;
1269
1264
  adsLoader = void 0;
1270
1265
  contentVideoHidden = false;
@@ -1313,7 +1308,7 @@ function createImaController(video, options) {
1313
1308
  if (adsManager && adPlaying) {
1314
1309
  try {
1315
1310
  adsManager.setVolume(clampedVolume);
1316
- } catch (e) {}
1311
+ } catch (unused) {}
1317
1312
  }
1318
1313
  },
1319
1314
  getAdVolume: function getAdVolume() {