videomail-client 15.7.17 → 15.7.19

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.
@@ -10972,7 +10972,7 @@ var __webpack_exports__ = {};
10972
10972
  var client = __webpack_require__("Q");
10973
10973
  var client_default = /*#__PURE__*/ __webpack_require__.n(client);
10974
10974
  var package_namespaceObject = {
10975
- rE: "15.7.17"
10975
+ rE: "15.7.19"
10976
10976
  };
10977
10977
  function isAudioEnabled(options) {
10978
10978
  return Boolean(options.audio.enabled);
@@ -14783,18 +14783,18 @@ var __webpack_exports__ = {};
14783
14783
  if (showParams) this.options.logger.debug(`${this.name} emits ${eventName} with ${util_pretty(params)}`);
14784
14784
  else this.options.logger.debug(`${this.name} emits ${eventName}`);
14785
14785
  try {
14786
- Despot.EMITTER.emit(eventName, ...params);
14786
+ this.emitter.emit(eventName, ...params);
14787
14787
  } catch (exc) {
14788
- if (exc instanceof error_VideomailError) Despot.EMITTER.emit("ERROR", {
14788
+ if (exc instanceof error_VideomailError) this.emitter.emit("ERROR", {
14789
14789
  err: exc
14790
14790
  });
14791
- else Despot.EMITTER.emit("ERROR", {
14791
+ else this.emitter.emit("ERROR", {
14792
14792
  exc
14793
14793
  });
14794
14794
  }
14795
14795
  }
14796
14796
  on(eventName, callback) {
14797
- return Despot.EMITTER.on(eventName, callback);
14797
+ return this.emitter.on(eventName, callback);
14798
14798
  }
14799
14799
  once(eventName, listener) {
14800
14800
  const callback = (...params)=>{
@@ -14804,23 +14804,30 @@ var __webpack_exports__ = {};
14804
14804
  const unbind = this.on(eventName, callback);
14805
14805
  return unbind;
14806
14806
  }
14807
- static getListeners(eventName) {
14808
- return Despot.EMITTER.events[eventName];
14807
+ getListeners(eventName) {
14808
+ return this.emitter.events[eventName];
14809
14809
  }
14810
- static removeListener(eventName) {
14811
- delete Despot.EMITTER.events[eventName];
14810
+ removeListener(eventName) {
14811
+ delete this.emitter.events[eventName];
14812
14812
  }
14813
- static removeAllListeners() {
14814
- Despot.EMITTER.events = {};
14813
+ removeAllListeners() {
14814
+ this.emitter.events = {};
14815
14815
  }
14816
14816
  constructor(name, options){
14817
14817
  Despot_define_property(this, "name", void 0);
14818
+ Despot_define_property(this, "emitter", void 0);
14818
14819
  Despot_define_property(this, "options", void 0);
14819
14820
  this.name = name;
14820
14821
  this.options = options;
14822
+ let emitter = Despot.emitters.get(options);
14823
+ if (!emitter) {
14824
+ emitter = createNanoEvents();
14825
+ Despot.emitters.set(options, emitter);
14826
+ }
14827
+ this.emitter = emitter;
14821
14828
  }
14822
14829
  }
14823
- Despot_define_property(Despot, "EMITTER", createNanoEvents());
14830
+ Despot_define_property(Despot, "emitters", new WeakMap());
14824
14831
  const util_Despot = Despot;
14825
14832
  function getValidity(element) {
14826
14833
  const validity = "validity" in element ? element.validity : void 0;
@@ -14931,27 +14938,33 @@ var __webpack_exports__ = {};
14931
14938
  this.options.logger.debug("Form: loadVideomail()");
14932
14939
  for (const formControl of this.formElement.elements){
14933
14940
  const name = formControl.getAttribute("name");
14934
- if (name) {
14941
+ if (name && this.isRegisteredFormField(formControl)) {
14935
14942
  let value = videomail[name];
14936
14943
  const tagName = formControl.tagName;
14937
14944
  if (this.options.callbacks.adjustFormValueBeforePopulating) value = this.options.callbacks.adjustFormValueBeforePopulating(name, value, videomail);
14938
- switch(tagName){
14945
+ if (null != value) switch(tagName){
14939
14946
  case "INPUT":
14940
14947
  {
14941
14948
  const inputControl = formControl;
14942
14949
  if (Array.isArray(value)) inputControl.value = value.join(", ");
14943
- else inputControl.value = value;
14950
+ else inputControl.value = String(value);
14944
14951
  break;
14945
14952
  }
14946
14953
  case "TEXTAREA":
14947
14954
  {
14948
14955
  const textArea = formControl;
14949
- textArea.value = value;
14956
+ textArea.value = String(value);
14957
+ break;
14958
+ }
14959
+ case "SELECT":
14960
+ {
14961
+ const select = formControl;
14962
+ select.value = String(value);
14950
14963
  break;
14951
14964
  }
14952
14965
  default:
14953
14966
  throw error_createError({
14954
- message: `Unsupported form control tag name $${tagName} found`,
14967
+ message: `Unsupported form control tag name ${tagName} found`,
14955
14968
  options: this.options
14956
14969
  });
14957
14970
  }
@@ -15000,8 +15013,8 @@ var __webpack_exports__ = {};
15000
15013
  for(let i = 0, len = inputElements.length; i < len; i++){
15001
15014
  const inputElement = inputElements[i];
15002
15015
  const type = null == inputElement ? void 0 : inputElement.getAttribute("type");
15003
- if ("radio" === type || "select" === type) null == inputElement || inputElement.addEventListener("change", this.container.validate.bind(this.container));
15004
- else null == inputElement || inputElement.addEventListener("input", this.container.validate.bind(this.container));
15016
+ if ("radio" === type || (null == inputElement ? void 0 : inputElement.tagName) === "SELECT") null == inputElement || inputElement.addEventListener("change", this.validate);
15017
+ else null == inputElement || inputElement.addEventListener("input", this.validate);
15005
15018
  }
15006
15019
  }
15007
15020
  this.on("PREVIEW", (params)=>{
@@ -15046,8 +15059,8 @@ var __webpack_exports__ = {};
15046
15059
  const inputElements = this.getRegisteredFormElements();
15047
15060
  for (const inputElement of inputElements){
15048
15061
  const type = inputElement.getAttribute("type");
15049
- if ("radio" === type || "select" === type) inputElement.removeEventListener("change", this.container.validate.bind(this.container));
15050
- else inputElement.removeEventListener("input", this.container.validate.bind(this.container));
15062
+ if ("radio" === type || "SELECT" === inputElement.tagName) inputElement.removeEventListener("change", this.validate);
15063
+ else inputElement.removeEventListener("input", this.validate);
15051
15064
  }
15052
15065
  }
15053
15066
  hideSubmitButton() {
@@ -15057,7 +15070,7 @@ var __webpack_exports__ = {};
15057
15070
  unload() {
15058
15071
  this.options.logger.debug("Form: unload()");
15059
15072
  this.removeAllInputListeners();
15060
- util_Despot.removeAllListeners();
15073
+ this.removeAllListeners();
15061
15074
  this.stopListeningToSubmitEvents();
15062
15075
  this.resetForm();
15063
15076
  }
@@ -15067,7 +15080,7 @@ var __webpack_exports__ = {};
15067
15080
  const inputElements = this.getRegisteredFormElements();
15068
15081
  for (const inputElement of inputElements){
15069
15082
  const type = inputElement.getAttribute("type");
15070
- if ((null == type ? void 0 : type.toLowerCase()) === "hidden") inputElement.setAttribute("value", "");
15083
+ if ((null == type ? void 0 : type.toLowerCase()) === "hidden") inputElement.value = "";
15071
15084
  }
15072
15085
  }
15073
15086
  startListeningToSubmitEvents() {
@@ -15120,7 +15133,9 @@ var __webpack_exports__ = {};
15120
15133
  html_showElement(this.formElement);
15121
15134
  }
15122
15135
  constructor(container, formElement, options){
15123
- super("Form", options), form_define_property(this, "container", void 0), form_define_property(this, "formElement", void 0), form_define_property(this, "keyInput", void 0), form_define_property(this, "FORM_FIELDS", {});
15136
+ super("Form", options), form_define_property(this, "container", void 0), form_define_property(this, "formElement", void 0), form_define_property(this, "validate", (event)=>{
15137
+ this.container.validate(event);
15138
+ }), form_define_property(this, "keyInput", void 0), form_define_property(this, "FORM_FIELDS", {});
15124
15139
  this.container = container;
15125
15140
  this.formElement = formElement;
15126
15141
  this.FORM_FIELDS = {
@@ -18063,7 +18078,7 @@ var __webpack_exports__ = {};
18063
18078
  if (this.built) {
18064
18079
  this.reset();
18065
18080
  this.options.logger.debug("Buttons: unload()");
18066
- util_Despot.removeAllListeners();
18081
+ this.removeAllListeners();
18067
18082
  this.hide();
18068
18083
  this.built = false;
18069
18084
  }
@@ -18113,7 +18128,8 @@ var __webpack_exports__ = {};
18113
18128
  fire(cb) {
18114
18129
  this.unload();
18115
18130
  this.hide();
18116
- setTimeout(function() {
18131
+ this.fireTimeoutId = window.setTimeout(()=>{
18132
+ this.fireTimeoutId = void 0;
18117
18133
  cb();
18118
18134
  }, 0);
18119
18135
  }
@@ -18123,15 +18139,16 @@ var __webpack_exports__ = {};
18123
18139
  if (void 0 !== this.countdown) {
18124
18140
  this.countdown--;
18125
18141
  if (this.countdown < 1) this.fire(cb);
18126
- else if (this.countdownElement) this.countdownElement.innerHTML = this.countdown.toString();
18142
+ else if (this.countdownElement) this.countdownElement.textContent = this.countdown.toString();
18127
18143
  }
18128
18144
  }
18129
18145
  }
18130
18146
  start(cb) {
18131
18147
  if (!this.countdownElement) throw new Error("Unable to start countdown without an element");
18132
18148
  if ("number" != typeof this.options.video.countdown) throw new TypeError(`The defined countdown is not a valid number: ${this.options.video.countdown}`);
18149
+ this.unload();
18133
18150
  this.countdown = this.options.video.countdown;
18134
- this.countdownElement.innerHTML = this.countdown.toString();
18151
+ this.countdownElement.textContent = this.countdown.toString();
18135
18152
  this.show();
18136
18153
  this.intervalId = window.setInterval(this.countBackward.bind(this, cb), 950);
18137
18154
  }
@@ -18156,12 +18173,14 @@ var __webpack_exports__ = {};
18156
18173
  html_showElement(this.countdownElement);
18157
18174
  }
18158
18175
  isCountingDown() {
18159
- return Boolean(this.intervalId);
18176
+ return void 0 !== this.intervalId;
18160
18177
  }
18161
18178
  unload() {
18162
- clearInterval(this.intervalId);
18179
+ if (void 0 !== this.intervalId) window.clearInterval(this.intervalId);
18180
+ if (void 0 !== this.fireTimeoutId) window.clearTimeout(this.fireTimeoutId);
18163
18181
  this.paused = false;
18164
18182
  this.intervalId = void 0;
18183
+ this.fireTimeoutId = void 0;
18165
18184
  }
18166
18185
  hide() {
18167
18186
  html_hideElement(this.countdownElement);
@@ -18172,6 +18191,7 @@ var __webpack_exports__ = {};
18172
18191
  countdown_define_property(this, "options", void 0);
18173
18192
  countdown_define_property(this, "countdownElement", void 0);
18174
18193
  countdown_define_property(this, "intervalId", void 0);
18194
+ countdown_define_property(this, "fireTimeoutId", void 0);
18175
18195
  countdown_define_property(this, "countdown", void 0);
18176
18196
  countdown_define_property(this, "paused", false);
18177
18197
  this.visuals = visuals;
@@ -19256,9 +19276,10 @@ var __webpack_exports__ = {};
19256
19276
  setVisualStream(localMediaStream) {
19257
19277
  if (localMediaStream) this.attachMediaStream(localMediaStream);
19258
19278
  else {
19259
- var _this_rawVisualUserMedia, _this_rawVisualUserMedia1;
19260
- null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) || _this_rawVisualUserMedia.removeAttribute("srcObject");
19261
- null == (_this_rawVisualUserMedia1 = this.rawVisualUserMedia) || _this_rawVisualUserMedia1.removeAttribute("src");
19279
+ if (this.rawVisualUserMedia) {
19280
+ this.rawVisualUserMedia.srcObject = null;
19281
+ this.rawVisualUserMedia.removeAttribute("src");
19282
+ }
19262
19283
  this.currentVisualStream = void 0;
19263
19284
  }
19264
19285
  }
@@ -19268,30 +19289,24 @@ var __webpack_exports__ = {};
19268
19289
  return !(null == (_this_currentVisualStream = this.currentVisualStream) ? void 0 : _this_currentVisualStream.active);
19269
19290
  }
19270
19291
  hasInvalidDimensions() {
19271
- var _this_rawVisualUserMedia, _this_rawVisualUserMedia1;
19272
- if ((null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) ? void 0 : _this_rawVisualUserMedia.videoWidth) && this.rawVisualUserMedia.videoWidth < 3 || (null == (_this_rawVisualUserMedia1 = this.rawVisualUserMedia) ? void 0 : _this_rawVisualUserMedia1.height) && this.rawVisualUserMedia.height < 3) return true;
19273
- return false;
19292
+ if (!this.rawVisualUserMedia) return false;
19293
+ return this.rawVisualUserMedia.videoWidth < 3 || this.rawVisualUserMedia.videoHeight < 3;
19274
19294
  }
19275
19295
  logEvent(eventType, params) {
19276
19296
  this.options.logger.debug(`UserMedia: ... ${EVENT_ASCII} event ${eventType}: ${util_pretty(params)}`);
19277
19297
  }
19278
- outputEvent(e) {
19279
- var _this_rawVisualUserMedia, _this_rawVisualUserMedia1;
19280
- this.logEvent(e.type, {
19281
- readyState: null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) ? void 0 : _this_rawVisualUserMedia.readyState
19282
- });
19283
- null == (_this_rawVisualUserMedia1 = this.rawVisualUserMedia) || _this_rawVisualUserMedia1.removeEventListener(e.type, this.outputEvent.bind(this));
19284
- }
19285
19298
  unloadRemainingEventListeners() {
19299
+ var _this_rawVisualUserMedia;
19286
19300
  this.options.logger.debug("UserMedia: unloadRemainingEventListeners()");
19287
19301
  mediaEvents.forEach((eventName)=>{
19288
19302
  var _this_rawVisualUserMedia;
19289
- null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) || _this_rawVisualUserMedia.removeEventListener(eventName, this.outputEvent.bind(this));
19303
+ null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) || _this_rawVisualUserMedia.removeEventListener(eventName, this.outputEvent);
19290
19304
  });
19305
+ null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) || _this_rawVisualUserMedia.removeEventListener("error", this.handleMediaError);
19291
19306
  }
19292
19307
  audioRecord(audioCallback) {
19293
19308
  var _this_audioRecorder;
19294
- util_Despot.removeListener("SENDING_FIRST_FRAME");
19309
+ this.removeListener("SENDING_FIRST_FRAME");
19295
19310
  null == (_this_audioRecorder = this.audioRecorder) || _this_audioRecorder.record(audioCallback);
19296
19311
  }
19297
19312
  init(localMediaStream, videoCallback, audioCallback, endedEarlyCallback, switchingFacingMode) {
@@ -19308,7 +19323,7 @@ var __webpack_exports__ = {};
19308
19323
  var _this_rawVisualUserMedia, _this_rawVisualUserMedia1;
19309
19324
  this.options.logger.debug("UserMedia: unloadAllEventListeners()");
19310
19325
  this.unloadRemainingEventListeners();
19311
- util_Despot.removeListener("SENDING_FIRST_FRAME");
19326
+ this.removeListener("SENDING_FIRST_FRAME");
19312
19327
  null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) || _this_rawVisualUserMedia.removeEventListener("play", onPlay);
19313
19328
  null == (_this_rawVisualUserMedia1 = this.rawVisualUserMedia) || _this_rawVisualUserMedia1.removeEventListener("loadedmetadata", onLoadedMetaData);
19314
19329
  };
@@ -19398,7 +19413,7 @@ var __webpack_exports__ = {};
19398
19413
  }
19399
19414
  };
19400
19415
  try {
19401
- var _this_rawVisualUserMedia, _this_rawVisualUserMedia1, _this_rawVisualUserMedia2;
19416
+ var _this_rawVisualUserMedia, _this_rawVisualUserMedia1, _this_rawVisualUserMedia2, _this_rawVisualUserMedia3;
19402
19417
  const videoTrack = media_getFirstVideoTrack(localMediaStream);
19403
19418
  this.videoTrackLabel = null == videoTrack ? void 0 : videoTrack.label;
19404
19419
  if (videoTrack) if (videoTrack.enabled) if (util_isVirtualCamera(videoTrack)) throw error_createError({
@@ -19420,9 +19435,8 @@ var __webpack_exports__ = {};
19420
19435
  else this.options.logger.debug("UserMedia: detected (but no video tracks exist");
19421
19436
  null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) || _this_rawVisualUserMedia.addEventListener("loadedmetadata", onLoadedMetaData);
19422
19437
  null == (_this_rawVisualUserMedia1 = this.rawVisualUserMedia) || _this_rawVisualUserMedia1.addEventListener("play", onPlay);
19423
- null == (_this_rawVisualUserMedia2 = this.rawVisualUserMedia) || _this_rawVisualUserMedia2.addEventListener("error", (err)=>{
19424
- this.options.logger.warn(`Caught video element error event: ${util_pretty(err)}`);
19425
- });
19438
+ null == (_this_rawVisualUserMedia2 = this.rawVisualUserMedia) || _this_rawVisualUserMedia2.removeEventListener("error", this.handleMediaError);
19439
+ null == (_this_rawVisualUserMedia3 = this.rawVisualUserMedia) || _this_rawVisualUserMedia3.addEventListener("error", this.handleMediaError);
19426
19440
  this.setVisualStream(localMediaStream);
19427
19441
  play();
19428
19442
  } catch (exc) {
@@ -19435,8 +19449,8 @@ var __webpack_exports__ = {};
19435
19449
  return this.videoTrackLabel;
19436
19450
  }
19437
19451
  isReady() {
19438
- var _this_rawVisualUserMedia;
19439
- return Boolean(null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) ? void 0 : _this_rawVisualUserMedia.src);
19452
+ var _this_rawVisualUserMedia, _this_rawVisualUserMedia1;
19453
+ return Boolean((null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) ? void 0 : _this_rawVisualUserMedia.srcObject) || (null == (_this_rawVisualUserMedia1 = this.rawVisualUserMedia) ? void 0 : _this_rawVisualUserMedia1.currentSrc));
19440
19454
  }
19441
19455
  stop(visualStream, params) {
19442
19456
  try {
@@ -19540,12 +19554,20 @@ var __webpack_exports__ = {};
19540
19554
  };
19541
19555
  }
19542
19556
  constructor(recorder, options){
19543
- super("UserMedia", options), userMedia_define_property(this, "recorder", void 0), userMedia_define_property(this, "rawVisualUserMedia", void 0), userMedia_define_property(this, "paused", false), userMedia_define_property(this, "recording", false), userMedia_define_property(this, "audioRecorder", void 0), userMedia_define_property(this, "currentVisualStream", void 0), userMedia_define_property(this, "onPlayReached", false), userMedia_define_property(this, "onLoadedMetaDataReached", false), userMedia_define_property(this, "playingPromiseReached", false), userMedia_define_property(this, "videoTrackLabel", void 0);
19557
+ super("UserMedia", options), userMedia_define_property(this, "recorder", void 0), userMedia_define_property(this, "rawVisualUserMedia", void 0), userMedia_define_property(this, "paused", false), userMedia_define_property(this, "recording", false), userMedia_define_property(this, "audioRecorder", void 0), userMedia_define_property(this, "currentVisualStream", void 0), userMedia_define_property(this, "onPlayReached", false), userMedia_define_property(this, "onLoadedMetaDataReached", false), userMedia_define_property(this, "playingPromiseReached", false), userMedia_define_property(this, "videoTrackLabel", void 0), userMedia_define_property(this, "outputEvent", (e)=>{
19558
+ var _this_rawVisualUserMedia, _this_rawVisualUserMedia1;
19559
+ this.logEvent(e.type, {
19560
+ readyState: null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) ? void 0 : _this_rawVisualUserMedia.readyState
19561
+ });
19562
+ null == (_this_rawVisualUserMedia1 = this.rawVisualUserMedia) || _this_rawVisualUserMedia1.removeEventListener(e.type, this.outputEvent);
19563
+ }), userMedia_define_property(this, "handleMediaError", (event)=>{
19564
+ this.options.logger.warn(`Caught video element error event: ${util_pretty(event)}`);
19565
+ });
19544
19566
  this.recorder = recorder;
19545
19567
  this.rawVisualUserMedia = recorder.getRawVisualUserMedia();
19546
19568
  mediaEvents.forEach((eventName)=>{
19547
19569
  var _this_rawVisualUserMedia;
19548
- null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) || _this_rawVisualUserMedia.addEventListener(eventName, this.outputEvent.bind(this), false);
19570
+ null == (_this_rawVisualUserMedia = this.rawVisualUserMedia) || _this_rawVisualUserMedia.addEventListener(eventName, this.outputEvent, false);
19549
19571
  });
19550
19572
  }
19551
19573
  }
@@ -19978,7 +20000,7 @@ var __webpack_exports__ = {};
19978
20000
  this.clearUserMediaTimeout();
19979
20001
  const characteristics = null == (_this_userMedia = this.userMedia) ? void 0 : _this_userMedia.getCharacteristics();
19980
20002
  this.options.logger.debug(`Recorder: userMediaErrorCallback(), name: ${err.name}, message: ${err.message} and Webcam characteristics: ${characteristics ? util_pretty(characteristics) : "none"}`);
19981
- const errorListeners = util_Despot.getListeners("ERROR");
20003
+ const errorListeners = this.getListeners("ERROR");
19982
20004
  if (null == errorListeners ? void 0 : errorListeners.length) {
19983
20005
  if (err.name !== error_VideomailError.MEDIA_DEVICE_NOT_SUPPORTED) {
19984
20006
  const videomailError = error_createError({
@@ -20081,7 +20103,7 @@ var __webpack_exports__ = {};
20081
20103
  this.clearUserMediaTimeout();
20082
20104
  this.options.logger.debug("Recorder: failed to load genuine user media");
20083
20105
  this.userMediaLoading = false;
20084
- const errorListeners = util_Despot.getListeners("ERROR");
20106
+ const errorListeners = this.getListeners("ERROR");
20085
20107
  if (null == errorListeners ? void 0 : errorListeners.length) this.emit("ERROR", {
20086
20108
  exc
20087
20109
  });
@@ -20725,12 +20747,12 @@ var __webpack_exports__ = {};
20725
20747
  heightValue = this.videomail.height;
20726
20748
  if (widthValue && heightValue) ratio = heightValue / widthValue;
20727
20749
  }
20728
- if (!widthValue) {
20750
+ if (!widthValue && (videoHeight > 0 || this.options.video.height)) {
20729
20751
  const newWidthDimensions = dimensions_calculateWidth(responsive, this.options, videoHeight, ratio);
20730
20752
  const newWidth = newWidthDimensions.value;
20731
20753
  widthValue = newWidth;
20732
20754
  }
20733
- if (!heightValue) {
20755
+ if (!heightValue && (videoWidth > 0 || this.options.video.width)) {
20734
20756
  let element = this.visuals.getElement();
20735
20757
  if (!element) element = document.body;
20736
20758
  const newDimensions = dimensions_calculateHeight(responsive, videoWidth, this.options, ratio, element);
@@ -20742,14 +20764,15 @@ var __webpack_exports__ = {};
20742
20764
  else this.replayElement.style.height = "auto";
20743
20765
  }
20744
20766
  setVideomail(newVideomail, playerOnly = false) {
20745
- var _this_videomail_recordingStats;
20767
+ var _this_replayElement, _this_videomail_recordingStats;
20746
20768
  this.videomail = newVideomail;
20769
+ null == (_this_replayElement = this.replayElement) || _this_replayElement.setAttribute("controls", "controls");
20747
20770
  if (this.videomail.mp4) this.setMp4Source(this.videomail.mp4);
20748
20771
  if (this.videomail.webm) this.setWebMSource(this.videomail.webm);
20749
20772
  if (this.videomail.vtt) this.setTrackSource(this.videomail.vtt);
20750
20773
  if (this.videomail.poster) {
20751
- var _this_replayElement;
20752
- null == (_this_replayElement = this.replayElement) || _this_replayElement.setAttribute("poster", this.videomail.poster);
20774
+ var _this_replayElement1;
20775
+ null == (_this_replayElement1 = this.replayElement) || _this_replayElement1.setAttribute("poster", this.videomail.poster);
20753
20776
  }
20754
20777
  this.copyAttributes(this.videomail);
20755
20778
  const sampleRate = null == (_this_videomail_recordingStats = this.videomail.recordingStats) ? void 0 : _this_videomail_recordingStats.sampleRate;
@@ -20770,17 +20793,16 @@ var __webpack_exports__ = {};
20770
20793
  } else html_showElement(this.replayElement);
20771
20794
  if (playerOnly) html_showElement(this.replayElement.parentElement);
20772
20795
  else this.visuals.show();
20773
- if (hasAudio) this.replayElement.setAttribute("volume", "1");
20796
+ if (hasAudio) this.replayElement.volume = 1;
20774
20797
  else if (!isAudioEnabled(this.options)) this.replayElement.setAttribute("muted", "true");
20775
20798
  this.replayElement.load();
20776
- if (this.videomail) this.replayElement.addEventListener("canplaythrough", ()=>{
20777
- this.emit("REPLAY_SHOWN");
20778
- }, {
20779
- once: true
20780
- });
20781
- else this.replayElement.addEventListener("canplaythrough", ()=>{
20782
- this.emit("PREVIEW_SHOWN");
20783
- }, {
20799
+ if (this.canPlayThroughHandler) this.replayElement.removeEventListener("canplaythrough", this.canPlayThroughHandler);
20800
+ const eventName = this.videomail ? "REPLAY_SHOWN" : "PREVIEW_SHOWN";
20801
+ this.canPlayThroughHandler = ()=>{
20802
+ this.canPlayThroughHandler = void 0;
20803
+ this.emit(eventName);
20804
+ };
20805
+ this.replayElement.addEventListener("canplaythrough", this.canPlayThroughHandler, {
20784
20806
  once: true
20785
20807
  });
20786
20808
  }
@@ -20803,49 +20825,27 @@ var __webpack_exports__ = {};
20803
20825
  null == (_this_replayElement = this.replayElement) || _this_replayElement.setAttribute("controls", "controls");
20804
20826
  this.show(null == params ? void 0 : params.width, null == params ? void 0 : params.height, null == params ? void 0 : params.hasAudio);
20805
20827
  });
20806
- this.replayElement.addEventListener("touchstart", (e)=>{
20807
- var _this_replayElement;
20808
- e.preventDefault();
20809
- if (null == (_this_replayElement = this.replayElement) ? void 0 : _this_replayElement.paused) this.replayElement.play().catch((exc)=>{
20810
- throw error_createError({
20811
- message: "Failed to play replay video while paused upon touchstart event.",
20812
- exc,
20813
- options: this.options
20814
- });
20815
- });
20816
- else {
20817
- var _this_replayElement1;
20818
- null == (_this_replayElement1 = this.replayElement) || _this_replayElement1.pause();
20819
- }
20820
- }, {
20821
- passive: true
20822
- });
20823
- this.replayElement.addEventListener("click", (e)=>{
20824
- var _this_replayElement;
20825
- e.preventDefault();
20826
- if (null == (_this_replayElement = this.replayElement) ? void 0 : _this_replayElement.paused) this.replayElement.play().catch((exc)=>{
20827
- throw error_createError({
20828
- message: "Failed to play replay video while paused upon click event.",
20829
- exc,
20830
- options: this.options
20831
- });
20832
- });
20833
- else {
20834
- var _this_replayElement1;
20835
- null == (_this_replayElement1 = this.replayElement) || _this_replayElement1.pause();
20836
- }
20837
- });
20828
+ this.replayElement.addEventListener("touchstart", this.togglePlayback);
20829
+ this.replayElement.addEventListener("click", this.togglePlayback);
20838
20830
  }
20839
20831
  this.built = true;
20840
20832
  this.options.logger.debug("Replay: built.");
20841
20833
  }
20842
20834
  unload(params) {
20835
+ var _this_replayElement, _this_replayElement1;
20843
20836
  this.options.logger.debug("Replay: unload()");
20844
- util_Despot.removeAllListeners();
20837
+ if (this.canPlayThroughHandler) {
20838
+ var _this_replayElement2;
20839
+ null == (_this_replayElement2 = this.replayElement) || _this_replayElement2.removeEventListener("canplaythrough", this.canPlayThroughHandler);
20840
+ this.canPlayThroughHandler = void 0;
20841
+ }
20842
+ null == (_this_replayElement = this.replayElement) || _this_replayElement.removeEventListener("touchstart", this.togglePlayback);
20843
+ null == (_this_replayElement1 = this.replayElement) || _this_replayElement1.removeEventListener("click", this.togglePlayback);
20844
+ this.removeAllListeners();
20845
20845
  if (null == params ? void 0 : params.startingOver) this.hide();
20846
20846
  else {
20847
- var _this_replayElement;
20848
- null == (_this_replayElement = this.replayElement) || _this_replayElement.remove();
20847
+ var _this_replayElement3;
20848
+ null == (_this_replayElement3 = this.replayElement) || _this_replayElement3.remove();
20849
20849
  this.replayElement = void 0;
20850
20850
  }
20851
20851
  this.videomail = void 0;
@@ -20887,7 +20887,7 @@ var __webpack_exports__ = {};
20887
20887
  let source = this.getVideoSource(type);
20888
20888
  let url = src;
20889
20889
  if (url && bustCache) url += `?${Date.now()}`;
20890
- if (source) if (src) source.setAttribute("src", src);
20890
+ if (source) if (url) source.setAttribute("src", url);
20891
20891
  else source.remove();
20892
20892
  else if (src) {
20893
20893
  const { fps } = this.options.video;
@@ -20951,7 +20951,24 @@ var __webpack_exports__ = {};
20951
20951
  return this.replayElement;
20952
20952
  }
20953
20953
  constructor(visuals, options){
20954
- super("Replay", options), replay_define_property(this, "visuals", void 0), replay_define_property(this, "built", false), replay_define_property(this, "replayElement", void 0), replay_define_property(this, "videomail", void 0);
20954
+ super("Replay", options), replay_define_property(this, "visuals", void 0), replay_define_property(this, "built", false), replay_define_property(this, "replayElement", void 0), replay_define_property(this, "videomail", void 0), replay_define_property(this, "canPlayThroughHandler", void 0), replay_define_property(this, "togglePlayback", (e)=>{
20955
+ var _this_replayElement;
20956
+ e.preventDefault();
20957
+ if (null == (_this_replayElement = this.replayElement) ? void 0 : _this_replayElement.paused) this.replayElement.play().catch((exc)=>{
20958
+ const err = error_createError({
20959
+ message: `Failed to play replay video upon ${e.type} event.`,
20960
+ exc,
20961
+ options: this.options
20962
+ });
20963
+ this.emit("ERROR", {
20964
+ err
20965
+ });
20966
+ });
20967
+ else {
20968
+ var _this_replayElement1;
20969
+ null == (_this_replayElement1 = this.replayElement) || _this_replayElement1.pause();
20970
+ }
20971
+ });
20955
20972
  this.visuals = visuals;
20956
20973
  }
20957
20974
  }
@@ -21515,7 +21532,7 @@ var __webpack_exports__ = {};
21515
21532
  exc
21516
21533
  });
21517
21534
  } finally{
21518
- util_Despot.removeAllListeners();
21535
+ this.removeAllListeners();
21519
21536
  this.built = this.submitted = false;
21520
21537
  }
21521
21538
  }