videomail-client 13.3.2 → 13.4.0

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.
@@ -10664,7 +10664,7 @@ var __webpack_exports__ = {};
10664
10664
  var client = __webpack_require__("./node_modules/superagent/lib/client.js");
10665
10665
  var client_default = /*#__PURE__*/ __webpack_require__.n(client);
10666
10666
  var package_namespaceObject = {
10667
- rE: "13.3.2"
10667
+ rE: "13.4.0"
10668
10668
  };
10669
10669
  var defined = __webpack_require__("./node_modules/defined/index.js");
10670
10670
  var defined_default = /*#__PURE__*/ __webpack_require__.n(defined);
@@ -14952,7 +14952,8 @@ var __webpack_exports__ = {};
14952
14952
  height: void 0,
14953
14953
  facingMode: "user",
14954
14954
  facingModeButton: false,
14955
- stretch: false
14955
+ stretch: false,
14956
+ mobileBreakPoint: void 0
14956
14957
  },
14957
14958
  image: {
14958
14959
  quality: 0.42,
@@ -15102,13 +15103,17 @@ var __webpack_exports__ = {};
15102
15103
  var document_visibility = __webpack_require__("./node_modules/document-visibility/index.js");
15103
15104
  var document_visibility_default = /*#__PURE__*/ __webpack_require__.n(document_visibility);
15104
15105
  function limitHeight(height, options, calledFrom) {
15106
+ const dimension = {
15107
+ unit: "px"
15108
+ };
15105
15109
  let limitedHeight = document.documentElement.clientHeight;
15106
15110
  if (height) limitedHeight = Math.min(height, limitedHeight);
15107
15111
  if (limitedHeight < 1) throw error_createError({
15108
15112
  message: `Limited height ${limitedHeight} cannot be less than 1! (Called from ${calledFrom})`,
15109
15113
  options
15110
15114
  });
15111
- return limitedHeight;
15115
+ dimension.value = limitedHeight;
15116
+ return dimension;
15112
15117
  }
15113
15118
  const dimensions_limitHeight = limitHeight;
15114
15119
  function getOuterWidth(element) {
@@ -15122,6 +15127,9 @@ var __webpack_exports__ = {};
15122
15127
  }
15123
15128
  const dimensions_getOuterWidth = getOuterWidth;
15124
15129
  function limitWidth(element, options, width) {
15130
+ const limitedDimension = {
15131
+ unit: "px"
15132
+ };
15125
15133
  let limitedWidth;
15126
15134
  const outerWidth = dimensions_getOuterWidth(element);
15127
15135
  limitedWidth = width && "number" == typeof width ? outerWidth > 0 && outerWidth < width ? outerWidth : width : outerWidth;
@@ -15129,9 +15137,22 @@ var __webpack_exports__ = {};
15129
15137
  message: "Limited width cannot be less than 1!",
15130
15138
  options
15131
15139
  });
15132
- return limitedWidth;
15140
+ limitedDimension.value = limitedWidth;
15141
+ return limitedDimension;
15133
15142
  }
15134
15143
  const dimensions_limitWidth = limitWidth;
15144
+ function useFullWidth(mobileBreakPoint) {
15145
+ if (void 0 === mobileBreakPoint) return;
15146
+ const viewportWidth = window.innerWidth;
15147
+ if (viewportWidth < mobileBreakPoint) {
15148
+ const dimension = {
15149
+ unit: "%",
15150
+ value: 100
15151
+ };
15152
+ return dimension;
15153
+ }
15154
+ }
15155
+ const dimensions_useFullWidth = useFullWidth;
15135
15156
  var contains = __webpack_require__("./node_modules/contains/index.js");
15136
15157
  var contains_default = /*#__PURE__*/ __webpack_require__.n(contains);
15137
15158
  function disableElement(element) {
@@ -16151,15 +16172,25 @@ var __webpack_exports__ = {};
16151
16172
  this.notify("Connected");
16152
16173
  if (this.options.loadUserMediaOnRecord) this.hide();
16153
16174
  });
16175
+ this.on("WINDOW_RESIZE", ()=>{
16176
+ this.correctNotifierDimensions();
16177
+ });
16154
16178
  }
16155
16179
  correctNotifierDimensions() {
16156
16180
  if (!this.notifyElement) return;
16157
16181
  if (this.options.video.stretch) {
16182
+ const heightDimension = this.visuals.getRecorderHeight(true, true);
16158
16183
  this.notifyElement.style.width = "auto";
16159
- this.notifyElement.style.height = `${this.visuals.getRecorderHeight(true, true)}px`;
16184
+ this.notifyElement.style.height = `${heightDimension.value}${heightDimension.unit}`;
16160
16185
  } else {
16161
- this.notifyElement.style.width = `${this.visuals.getRecorderWidth(true)}px`;
16162
- this.notifyElement.style.height = `${this.visuals.getRecorderHeight(true)}px`;
16186
+ let heightDimension;
16187
+ let widthDimension = dimensions_useFullWidth(this.options.video.mobileBreakPoint);
16188
+ if (!widthDimension) {
16189
+ widthDimension = this.visuals.getRecorderWidth(true);
16190
+ heightDimension = this.visuals.getRecorderHeight(true);
16191
+ }
16192
+ if (widthDimension) this.notifyElement.style.width = `${widthDimension.value}${widthDimension.unit}`;
16193
+ if (heightDimension) this.notifyElement.style.height = `${heightDimension.value}${heightDimension.unit}`;
16163
16194
  }
16164
16195
  }
16165
16196
  show() {
@@ -16373,7 +16404,7 @@ var __webpack_exports__ = {};
16373
16404
  function figureMinHeight(height, options) {
16374
16405
  let minHeight;
16375
16406
  if (options.video.height) {
16376
- minHeight = Math.min(options.video.height, height);
16407
+ minHeight = height ? Math.min(options.video.height, height) : options.video.height;
16377
16408
  if (minHeight < 1) throw error_createError({
16378
16409
  message: `Got a min height less than 1 (${minHeight})!`,
16379
16410
  options
@@ -16394,24 +16425,38 @@ var __webpack_exports__ = {};
16394
16425
  }
16395
16426
  const dimensions_getRatio = getRatio;
16396
16427
  function calculateHeight(responsive, videoWidth, options, target, ratio, element) {
16428
+ const dimension = {
16429
+ unit: "px"
16430
+ };
16397
16431
  let width = videoWidth;
16398
16432
  if (width < 1) throw error_createError({
16399
16433
  message: `Unable to calculate height for target ${target} when width is less than 1 (= ${width}) and responsive mode is set to ${responsive}`,
16400
16434
  options
16401
16435
  });
16402
- if (responsive && element) width = dimensions_limitWidth(element, options, width);
16436
+ if (responsive && element) {
16437
+ const limitedDimension = dimensions_limitWidth(element, options, width);
16438
+ width = limitedDimension.value;
16439
+ }
16403
16440
  const chosenRatio = null != ratio ? ratio : dimensions_getRatio(options, void 0, videoWidth);
16404
- const height = Math.round(width * chosenRatio);
16405
- if (Number.isInteger(height) && height < 1) throw error_createError({
16441
+ const height = width ? Math.round(width * chosenRatio) : void 0;
16442
+ if (height && Number.isInteger(height) && height < 1) throw error_createError({
16406
16443
  message: "Just calculated a height less than 1 which is wrong.",
16407
16444
  options
16408
16445
  });
16409
- return dimensions_figureMinHeight(height, options);
16446
+ const minHeight = dimensions_figureMinHeight(height, options);
16447
+ dimension.value = minHeight;
16448
+ return dimension;
16410
16449
  }
16411
16450
  const dimensions_calculateHeight = calculateHeight;
16412
16451
  function calculateWidth(responsive, videoHeight, options, ratio) {
16452
+ const dimension = {
16453
+ unit: "px"
16454
+ };
16413
16455
  let height = dimensions_figureMinHeight(videoHeight, options);
16414
- if (responsive) height = dimensions_limitHeight(height, options, "calculateWidth");
16456
+ if (responsive) {
16457
+ const limitedDimension = dimensions_limitHeight(height, options, "calculateWidth");
16458
+ height = limitedDimension.value;
16459
+ }
16415
16460
  if (!height || height < 1) throw error_createError({
16416
16461
  message: `Height ${height} cannot be smaller than 1 when calculating width.`,
16417
16462
  options
@@ -16422,7 +16467,8 @@ var __webpack_exports__ = {};
16422
16467
  message: "Calculated width cannot be smaller than 1!",
16423
16468
  options
16424
16469
  });
16425
- return calculatedWidth;
16470
+ dimension.value = calculatedWidth;
16471
+ return dimension;
16426
16472
  }
16427
16473
  const dimensions_calculateWidth = calculateWidth;
16428
16474
  class audio_sample_modern_t {
@@ -16779,8 +16825,8 @@ var __webpack_exports__ = {};
16779
16825
  }
16780
16826
  createCanvas() {
16781
16827
  const canvas = document.createElement("canvas");
16782
- const rawWidth = this.getRawWidth(true);
16783
- if (rawWidth) canvas.width = rawWidth;
16828
+ const dimension = this.getRawWidth(true);
16829
+ if (dimension.value) canvas.width = dimension.value;
16784
16830
  const rawHeight = this.getRawHeight(true);
16785
16831
  if (rawHeight) canvas.height = rawHeight;
16786
16832
  return canvas;
@@ -16799,14 +16845,25 @@ var __webpack_exports__ = {};
16799
16845
  }
16800
16846
  getRawWidth(responsive) {
16801
16847
  let rawWidth = this.getVideoWidth();
16802
- if (this.options.video.width || this.options.video.height) rawWidth = responsive ? this.recorder.calculateWidth(responsive) : this.options.video.width;
16803
- if (responsive) rawWidth = this.recorder.limitWidth(rawWidth);
16804
- return rawWidth;
16848
+ const dimension = {
16849
+ unit: "px"
16850
+ };
16851
+ if (this.options.video.width || this.options.video.height) if (responsive) {
16852
+ const dimension = this.recorder.calculateWidth(responsive);
16853
+ rawWidth = dimension.value;
16854
+ } else rawWidth = this.options.video.width;
16855
+ if (responsive) {
16856
+ const dimension = this.recorder.limitWidth(rawWidth);
16857
+ rawWidth = null == dimension ? void 0 : dimension.value;
16858
+ }
16859
+ dimension.value = rawWidth;
16860
+ return dimension;
16805
16861
  }
16806
16862
  getRawHeight(responsive) {
16807
16863
  let rawHeight;
16808
16864
  if (this.options.video.width || this.options.video.height) {
16809
- rawHeight = this.recorder.calculateHeight(responsive);
16865
+ const heightDimension = this.recorder.calculateHeight(responsive);
16866
+ rawHeight = heightDimension.value;
16810
16867
  if (!rawHeight || rawHeight < 1) throw error_createError({
16811
16868
  message: "Bad dimensions",
16812
16869
  explanation: "Calculated raw height cannot be less than 1!",
@@ -16820,7 +16877,10 @@ var __webpack_exports__ = {};
16820
16877
  options: this.options
16821
16878
  });
16822
16879
  }
16823
- if (responsive) rawHeight = this.recorder.limitHeight(rawHeight);
16880
+ if (responsive) {
16881
+ const heightDimension = this.recorder.limitHeight(rawHeight);
16882
+ rawHeight = heightDimension.value;
16883
+ }
16824
16884
  return rawHeight;
16825
16885
  }
16826
16886
  getRawVisuals() {
@@ -17020,14 +17080,14 @@ var __webpack_exports__ = {};
17020
17080
  if (args.mp4) this.replay.setMp4Source(`${args.mp4 + constants.SITE_NAME_LABEL}/${this.options.siteName}/videomail.mp4`, true);
17021
17081
  if (args.webm) this.replay.setWebMSource(`${args.webm + constants.SITE_NAME_LABEL}/${this.options.siteName}/videomail.webm`, true);
17022
17082
  this.hide();
17023
- const width = this.getRecorderWidth(true);
17024
- const height = this.getRecorderHeight(true);
17083
+ const widthDimension = this.getRecorderWidth(true);
17084
+ const heightDimension = this.getRecorderHeight(true);
17025
17085
  var _args_duration;
17026
17086
  const duration = null != (_args_duration = args.duration) ? _args_duration : -1;
17027
17087
  this.emit("PREVIEW", {
17028
17088
  key: this.key,
17029
- width,
17030
- height,
17089
+ width: null == widthDimension ? void 0 : widthDimension.value,
17090
+ height: heightDimension.value,
17031
17091
  hasAudio,
17032
17092
  duration
17033
17093
  });
@@ -17210,8 +17270,8 @@ var __webpack_exports__ = {};
17210
17270
  };
17211
17271
  } else if (constraints.video && true !== constraints.video) {
17212
17272
  const limitedWidth = this.limitWidth();
17213
- if (limitedWidth) constraints.video.width = {
17214
- ideal: limitedWidth
17273
+ if (null == limitedWidth ? void 0 : limitedWidth.value) constraints.video.width = {
17274
+ ideal: limitedWidth.value
17215
17275
  };
17216
17276
  }
17217
17277
  if (this.options.video.height && constraints.video && true !== constraints.video) {
@@ -17635,13 +17695,17 @@ var __webpack_exports__ = {};
17635
17695
  }
17636
17696
  correctDimensions() {
17637
17697
  if (!this.recorderElement) return;
17638
- if (this.options.video.width) {
17639
- const recorderWidth = this.getRecorderWidth(true);
17640
- if (recorderWidth) this.recorderElement.width = recorderWidth;
17641
- }
17642
- if (this.options.video.height) {
17643
- const recorderHeight = this.getRecorderHeight(true);
17644
- if (recorderHeight) this.recorderElement.height = recorderHeight;
17698
+ const widthDimension = dimensions_useFullWidth(this.options.video.mobileBreakPoint);
17699
+ if (this.options.video.stretch || widthDimension) this.recorderElement.style.width = "100%";
17700
+ else {
17701
+ if (this.options.video.width) {
17702
+ const recorderWidth = this.getRecorderWidth(true);
17703
+ if (null == recorderWidth ? void 0 : recorderWidth.value) this.recorderElement.width = recorderWidth.value;
17704
+ }
17705
+ if (this.options.video.height) {
17706
+ const recorderHeight = this.getRecorderHeight(true);
17707
+ if (recorderHeight.value) this.recorderElement.height = recorderHeight.value;
17708
+ }
17645
17709
  }
17646
17710
  }
17647
17711
  switchFacingMode() {
@@ -17689,6 +17753,9 @@ var __webpack_exports__ = {};
17689
17753
  this.on("SWITCH_FACING_MODE", ()=>{
17690
17754
  this.switchFacingMode();
17691
17755
  });
17756
+ this.on("WINDOW_RESIZE", ()=>{
17757
+ this.correctDimensions();
17758
+ });
17692
17759
  }
17693
17760
  buildElement() {
17694
17761
  this.recorderElement = document.createElement("video");
@@ -17707,7 +17774,6 @@ var __webpack_exports__ = {};
17707
17774
  this.recorderElement.style.transform = "rotateY(180deg)";
17708
17775
  this.recorderElement.style["-webkit-transform"] = "rotateY(180deg)";
17709
17776
  this.recorderElement.style["-moz-transform"] = "rotateY(180deg)";
17710
- if (this.options.video.stretch) this.recorderElement.style.width = "100%";
17711
17777
  null != this.userMedia || (this.userMedia = new visuals_userMedia(this, this.options));
17712
17778
  this.show();
17713
17779
  if (this.built) {
@@ -17742,13 +17808,36 @@ var __webpack_exports__ = {};
17742
17808
  var _this_userMedia;
17743
17809
  if (null == (_this_userMedia = this.userMedia) ? void 0 : _this_userMedia.hasVideoWidth()) return this.userMedia.getRawWidth(responsive);
17744
17810
  if (responsive && this.options.video.width) return this.limitWidth(this.options.video.width);
17745
- return this.options.video.width;
17811
+ const dimension = {
17812
+ unit: "px",
17813
+ value: this.options.video.width
17814
+ };
17815
+ return dimension;
17746
17816
  }
17747
17817
  getRecorderHeight(responsive, useBoundingClientRect) {
17748
- if (this.recorderElement && useBoundingClientRect) return this.recorderElement.getBoundingClientRect().height;
17749
- if (this.userMedia) return this.userMedia.getRawHeight(responsive);
17818
+ if (this.recorderElement && useBoundingClientRect) {
17819
+ const height = this.recorderElement.getBoundingClientRect().height;
17820
+ const dimension = {
17821
+ unit: "px",
17822
+ value: height
17823
+ };
17824
+ return dimension;
17825
+ }
17826
+ if (this.userMedia) {
17827
+ const height = this.userMedia.getRawHeight(responsive);
17828
+ const dimension = {
17829
+ unit: "px",
17830
+ value: height
17831
+ };
17832
+ return dimension;
17833
+ }
17750
17834
  if (responsive && this.options.video.height) return this.calculateHeight(responsive);
17751
- return this.options.video.height;
17835
+ const height = this.options.video.height;
17836
+ const dimension = {
17837
+ unit: "px",
17838
+ value: height
17839
+ };
17840
+ return dimension;
17752
17841
  }
17753
17842
  getRatio() {
17754
17843
  let ratio;
@@ -18126,13 +18215,22 @@ var __webpack_exports__ = {};
18126
18215
  this.on("ERROR", ()=>{
18127
18216
  if (util_getBrowser(this.options).isMobile()) this.removeDimensions();
18128
18217
  });
18218
+ this.on("WINDOW_RESIZE", ()=>{
18219
+ this.correctDimensions();
18220
+ });
18129
18221
  }
18130
18222
  }
18131
18223
  correctDimensions() {
18132
18224
  if (this.options.video.stretch) this.removeDimensions();
18133
18225
  else if (this.visualsElement) {
18134
- this.visualsElement.style.width = `${this.getRecorderWidth(true)}px`;
18135
- this.visualsElement.style.height = `${this.getRecorderHeight(true)}px`;
18226
+ let heightDimension;
18227
+ let widthDimension = dimensions_useFullWidth(this.options.video.mobileBreakPoint);
18228
+ if (!widthDimension) {
18229
+ widthDimension = this.getRecorderWidth(true);
18230
+ heightDimension = this.getRecorderHeight(true);
18231
+ }
18232
+ if (widthDimension) this.visualsElement.style.width = `${widthDimension.value}${widthDimension.unit}`;
18233
+ if (heightDimension) this.visualsElement.style.height = `${heightDimension.value}${heightDimension.unit}`;
18136
18234
  }
18137
18235
  }
18138
18236
  removeDimensions() {
@@ -18473,6 +18571,9 @@ var __webpack_exports__ = {};
18473
18571
  }
18474
18572
  initEvents(playerOnly = false) {
18475
18573
  this.options.logger.debug(`Container: initEvents (playerOnly = ${playerOnly})`);
18574
+ window.addEventListener("resize", ()=>{
18575
+ this.emit("WINDOW_RESIZE");
18576
+ });
18476
18577
  if (this.options.enableAutoUnload) window.addEventListener("beforeunload", (e)=>{
18477
18578
  this.unload({
18478
18579
  e
@@ -18510,6 +18611,9 @@ var __webpack_exports__ = {};
18510
18611
  const browser = util_getBrowser(this.options);
18511
18612
  if (browser.isMobile()) this.removeDimensions();
18512
18613
  });
18614
+ this.on("WINDOW_RESIZE", ()=>{
18615
+ this.correctDimensions();
18616
+ });
18513
18617
  if (!playerOnly) this.on("LOADED_META_DATA", ()=>{
18514
18618
  this.correctDimensions();
18515
18619
  });
@@ -18517,8 +18621,9 @@ var __webpack_exports__ = {};
18517
18621
  correctDimensions() {
18518
18622
  if (this.options.video.stretch) this.removeDimensions();
18519
18623
  else if (this.containerElement) {
18520
- const width = this.visuals.getRecorderWidth(true);
18521
- if (width) this.containerElement.style.width = `${width}px`;
18624
+ let dimension = dimensions_useFullWidth(this.options.video.mobileBreakPoint);
18625
+ if (!dimension) dimension = this.visuals.getRecorderWidth(true);
18626
+ if (null == dimension ? void 0 : dimension.value) this.containerElement.style.width = `${dimension.value}${dimension.unit}`;
18522
18627
  }
18523
18628
  }
18524
18629
  removeDimensions() {
@@ -18544,8 +18649,10 @@ var __webpack_exports__ = {};
18544
18649
  if (!videomailFormData) throw new Error("No videomail form data defined");
18545
18650
  if (method === FormMethod.POST) {
18546
18651
  videomailFormData.recordingStats = this.visuals.getRecordingStats();
18547
- videomailFormData.width = this.visuals.getRecorderWidth(true);
18548
- videomailFormData.height = this.visuals.getRecorderHeight(true);
18652
+ const widthDimension = this.visuals.getRecorderWidth(true);
18653
+ const heightDimension = this.visuals.getRecorderHeight(true);
18654
+ videomailFormData.width = null == widthDimension ? void 0 : widthDimension.value;
18655
+ videomailFormData.height = heightDimension.value;
18549
18656
  return yield this.resource.post(videomailFormData);
18550
18657
  }
18551
18658
  if (method === FormMethod.PUT) return yield this.resource.put(videomailFormData);