videomail-client 13.3.3 → 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.
package/dist/umd/index.js CHANGED
@@ -10670,7 +10670,7 @@
10670
10670
  var client = __webpack_require__("./node_modules/superagent/lib/client.js");
10671
10671
  var client_default = /*#__PURE__*/ __webpack_require__.n(client);
10672
10672
  var package_namespaceObject = {
10673
- rE: "13.3.3"
10673
+ rE: "13.4.0"
10674
10674
  };
10675
10675
  var defined = __webpack_require__("./node_modules/defined/index.js");
10676
10676
  var defined_default = /*#__PURE__*/ __webpack_require__.n(defined);
@@ -14827,7 +14827,8 @@
14827
14827
  height: void 0,
14828
14828
  facingMode: "user",
14829
14829
  facingModeButton: false,
14830
- stretch: false
14830
+ stretch: false,
14831
+ mobileBreakPoint: void 0
14831
14832
  },
14832
14833
  image: {
14833
14834
  quality: 0.42,
@@ -14967,13 +14968,17 @@
14967
14968
  var document_visibility = __webpack_require__("./node_modules/document-visibility/index.js");
14968
14969
  var document_visibility_default = /*#__PURE__*/ __webpack_require__.n(document_visibility);
14969
14970
  function limitHeight(height, options, calledFrom) {
14971
+ const dimension = {
14972
+ unit: "px"
14973
+ };
14970
14974
  let limitedHeight = document.documentElement.clientHeight;
14971
14975
  if (height) limitedHeight = Math.min(height, limitedHeight);
14972
14976
  if (limitedHeight < 1) throw error_createError({
14973
14977
  message: `Limited height ${limitedHeight} cannot be less than 1! (Called from ${calledFrom})`,
14974
14978
  options
14975
14979
  });
14976
- return limitedHeight;
14980
+ dimension.value = limitedHeight;
14981
+ return dimension;
14977
14982
  }
14978
14983
  const dimensions_limitHeight = limitHeight;
14979
14984
  function getOuterWidth(element) {
@@ -14987,6 +14992,9 @@
14987
14992
  }
14988
14993
  const dimensions_getOuterWidth = getOuterWidth;
14989
14994
  function limitWidth(element, options, width) {
14995
+ const limitedDimension = {
14996
+ unit: "px"
14997
+ };
14990
14998
  let limitedWidth;
14991
14999
  const outerWidth = dimensions_getOuterWidth(element);
14992
15000
  limitedWidth = width && "number" == typeof width ? outerWidth > 0 && outerWidth < width ? outerWidth : width : outerWidth;
@@ -14994,9 +15002,22 @@
14994
15002
  message: "Limited width cannot be less than 1!",
14995
15003
  options
14996
15004
  });
14997
- return limitedWidth;
15005
+ limitedDimension.value = limitedWidth;
15006
+ return limitedDimension;
14998
15007
  }
14999
15008
  const dimensions_limitWidth = limitWidth;
15009
+ function useFullWidth(mobileBreakPoint) {
15010
+ if (void 0 === mobileBreakPoint) return;
15011
+ const viewportWidth = window.innerWidth;
15012
+ if (viewportWidth < mobileBreakPoint) {
15013
+ const dimension = {
15014
+ unit: "%",
15015
+ value: 100
15016
+ };
15017
+ return dimension;
15018
+ }
15019
+ }
15020
+ const dimensions_useFullWidth = useFullWidth;
15000
15021
  var contains = __webpack_require__("./node_modules/contains/index.js");
15001
15022
  var contains_default = /*#__PURE__*/ __webpack_require__.n(contains);
15002
15023
  function disableElement(element) {
@@ -15924,15 +15945,25 @@
15924
15945
  this.notify("Connected");
15925
15946
  if (this.options.loadUserMediaOnRecord) this.hide();
15926
15947
  });
15948
+ this.on("WINDOW_RESIZE", ()=>{
15949
+ this.correctNotifierDimensions();
15950
+ });
15927
15951
  }
15928
15952
  correctNotifierDimensions() {
15929
15953
  if (!this.notifyElement) return;
15930
15954
  if (this.options.video.stretch) {
15955
+ const heightDimension = this.visuals.getRecorderHeight(true, true);
15931
15956
  this.notifyElement.style.width = "auto";
15932
- this.notifyElement.style.height = `${this.visuals.getRecorderHeight(true, true)}px`;
15957
+ this.notifyElement.style.height = `${heightDimension.value}${heightDimension.unit}`;
15933
15958
  } else {
15934
- this.notifyElement.style.width = `${this.visuals.getRecorderWidth(true)}px`;
15935
- this.notifyElement.style.height = `${this.visuals.getRecorderHeight(true)}px`;
15959
+ let heightDimension;
15960
+ let widthDimension = dimensions_useFullWidth(this.options.video.mobileBreakPoint);
15961
+ if (!widthDimension) {
15962
+ widthDimension = this.visuals.getRecorderWidth(true);
15963
+ heightDimension = this.visuals.getRecorderHeight(true);
15964
+ }
15965
+ if (widthDimension) this.notifyElement.style.width = `${widthDimension.value}${widthDimension.unit}`;
15966
+ if (heightDimension) this.notifyElement.style.height = `${heightDimension.value}${heightDimension.unit}`;
15936
15967
  }
15937
15968
  }
15938
15969
  show() {
@@ -16134,7 +16165,7 @@
16134
16165
  function figureMinHeight(height, options) {
16135
16166
  let minHeight;
16136
16167
  if (options.video.height) {
16137
- minHeight = Math.min(options.video.height, height);
16168
+ minHeight = height ? Math.min(options.video.height, height) : options.video.height;
16138
16169
  if (minHeight < 1) throw error_createError({
16139
16170
  message: `Got a min height less than 1 (${minHeight})!`,
16140
16171
  options
@@ -16155,24 +16186,38 @@
16155
16186
  }
16156
16187
  const dimensions_getRatio = getRatio;
16157
16188
  function calculateHeight(responsive, videoWidth, options, target, ratio, element) {
16189
+ const dimension = {
16190
+ unit: "px"
16191
+ };
16158
16192
  let width = videoWidth;
16159
16193
  if (width < 1) throw error_createError({
16160
16194
  message: `Unable to calculate height for target ${target} when width is less than 1 (= ${width}) and responsive mode is set to ${responsive}`,
16161
16195
  options
16162
16196
  });
16163
- if (responsive && element) width = dimensions_limitWidth(element, options, width);
16197
+ if (responsive && element) {
16198
+ const limitedDimension = dimensions_limitWidth(element, options, width);
16199
+ width = limitedDimension.value;
16200
+ }
16164
16201
  const chosenRatio = ratio ?? dimensions_getRatio(options, void 0, videoWidth);
16165
- const height = Math.round(width * chosenRatio);
16166
- if (Number.isInteger(height) && height < 1) throw error_createError({
16202
+ const height = width ? Math.round(width * chosenRatio) : void 0;
16203
+ if (height && Number.isInteger(height) && height < 1) throw error_createError({
16167
16204
  message: "Just calculated a height less than 1 which is wrong.",
16168
16205
  options
16169
16206
  });
16170
- return dimensions_figureMinHeight(height, options);
16207
+ const minHeight = dimensions_figureMinHeight(height, options);
16208
+ dimension.value = minHeight;
16209
+ return dimension;
16171
16210
  }
16172
16211
  const dimensions_calculateHeight = calculateHeight;
16173
16212
  function calculateWidth(responsive, videoHeight, options, ratio) {
16213
+ const dimension = {
16214
+ unit: "px"
16215
+ };
16174
16216
  let height = dimensions_figureMinHeight(videoHeight, options);
16175
- if (responsive) height = dimensions_limitHeight(height, options, "calculateWidth");
16217
+ if (responsive) {
16218
+ const limitedDimension = dimensions_limitHeight(height, options, "calculateWidth");
16219
+ height = limitedDimension.value;
16220
+ }
16176
16221
  if (!height || height < 1) throw error_createError({
16177
16222
  message: `Height ${height} cannot be smaller than 1 when calculating width.`,
16178
16223
  options
@@ -16183,7 +16228,8 @@
16183
16228
  message: "Calculated width cannot be smaller than 1!",
16184
16229
  options
16185
16230
  });
16186
- return calculatedWidth;
16231
+ dimension.value = calculatedWidth;
16232
+ return dimension;
16187
16233
  }
16188
16234
  const dimensions_calculateWidth = calculateWidth;
16189
16235
  class audio_sample_modern_t {
@@ -16523,8 +16569,8 @@
16523
16569
  }
16524
16570
  createCanvas() {
16525
16571
  const canvas = document.createElement("canvas");
16526
- const rawWidth = this.getRawWidth(true);
16527
- if (rawWidth) canvas.width = rawWidth;
16572
+ const dimension = this.getRawWidth(true);
16573
+ if (dimension.value) canvas.width = dimension.value;
16528
16574
  const rawHeight = this.getRawHeight(true);
16529
16575
  if (rawHeight) canvas.height = rawHeight;
16530
16576
  return canvas;
@@ -16543,14 +16589,25 @@
16543
16589
  }
16544
16590
  getRawWidth(responsive) {
16545
16591
  let rawWidth = this.getVideoWidth();
16546
- if (this.options.video.width || this.options.video.height) rawWidth = responsive ? this.recorder.calculateWidth(responsive) : this.options.video.width;
16547
- if (responsive) rawWidth = this.recorder.limitWidth(rawWidth);
16548
- return rawWidth;
16592
+ const dimension = {
16593
+ unit: "px"
16594
+ };
16595
+ if (this.options.video.width || this.options.video.height) if (responsive) {
16596
+ const dimension = this.recorder.calculateWidth(responsive);
16597
+ rawWidth = dimension.value;
16598
+ } else rawWidth = this.options.video.width;
16599
+ if (responsive) {
16600
+ const dimension = this.recorder.limitWidth(rawWidth);
16601
+ rawWidth = dimension?.value;
16602
+ }
16603
+ dimension.value = rawWidth;
16604
+ return dimension;
16549
16605
  }
16550
16606
  getRawHeight(responsive) {
16551
16607
  let rawHeight;
16552
16608
  if (this.options.video.width || this.options.video.height) {
16553
- rawHeight = this.recorder.calculateHeight(responsive);
16609
+ const heightDimension = this.recorder.calculateHeight(responsive);
16610
+ rawHeight = heightDimension.value;
16554
16611
  if (!rawHeight || rawHeight < 1) throw error_createError({
16555
16612
  message: "Bad dimensions",
16556
16613
  explanation: "Calculated raw height cannot be less than 1!",
@@ -16564,7 +16621,10 @@
16564
16621
  options: this.options
16565
16622
  });
16566
16623
  }
16567
- if (responsive) rawHeight = this.recorder.limitHeight(rawHeight);
16624
+ if (responsive) {
16625
+ const heightDimension = this.recorder.limitHeight(rawHeight);
16626
+ rawHeight = heightDimension.value;
16627
+ }
16568
16628
  return rawHeight;
16569
16629
  }
16570
16630
  getRawVisuals() {
@@ -16783,13 +16843,13 @@
16783
16843
  if (args.mp4) this.replay.setMp4Source(`${args.mp4 + constants.SITE_NAME_LABEL}/${this.options.siteName}/videomail.mp4`, true);
16784
16844
  if (args.webm) this.replay.setWebMSource(`${args.webm + constants.SITE_NAME_LABEL}/${this.options.siteName}/videomail.webm`, true);
16785
16845
  this.hide();
16786
- const width = this.getRecorderWidth(true);
16787
- const height = this.getRecorderHeight(true);
16846
+ const widthDimension = this.getRecorderWidth(true);
16847
+ const heightDimension = this.getRecorderHeight(true);
16788
16848
  const duration = args.duration ?? -1;
16789
16849
  this.emit("PREVIEW", {
16790
16850
  key: this.key,
16791
- width,
16792
- height,
16851
+ width: widthDimension?.value,
16852
+ height: heightDimension.value,
16793
16853
  hasAudio,
16794
16854
  duration
16795
16855
  });
@@ -16970,8 +17030,8 @@
16970
17030
  };
16971
17031
  } else if (constraints.video && true !== constraints.video) {
16972
17032
  const limitedWidth = this.limitWidth();
16973
- if (limitedWidth) constraints.video.width = {
16974
- ideal: limitedWidth
17033
+ if (limitedWidth?.value) constraints.video.width = {
17034
+ ideal: limitedWidth.value
16975
17035
  };
16976
17036
  }
16977
17037
  if (this.options.video.height && constraints.video && true !== constraints.video) {
@@ -17385,13 +17445,17 @@
17385
17445
  }
17386
17446
  correctDimensions() {
17387
17447
  if (!this.recorderElement) return;
17388
- if (this.options.video.width) {
17389
- const recorderWidth = this.getRecorderWidth(true);
17390
- if (recorderWidth) this.recorderElement.width = recorderWidth;
17391
- }
17392
- if (this.options.video.height) {
17393
- const recorderHeight = this.getRecorderHeight(true);
17394
- if (recorderHeight) this.recorderElement.height = recorderHeight;
17448
+ const widthDimension = dimensions_useFullWidth(this.options.video.mobileBreakPoint);
17449
+ if (this.options.video.stretch || widthDimension) this.recorderElement.style.width = "100%";
17450
+ else {
17451
+ if (this.options.video.width) {
17452
+ const recorderWidth = this.getRecorderWidth(true);
17453
+ if (recorderWidth?.value) this.recorderElement.width = recorderWidth.value;
17454
+ }
17455
+ if (this.options.video.height) {
17456
+ const recorderHeight = this.getRecorderHeight(true);
17457
+ if (recorderHeight.value) this.recorderElement.height = recorderHeight.value;
17458
+ }
17395
17459
  }
17396
17460
  }
17397
17461
  switchFacingMode() {
@@ -17439,6 +17503,9 @@
17439
17503
  this.on("SWITCH_FACING_MODE", ()=>{
17440
17504
  this.switchFacingMode();
17441
17505
  });
17506
+ this.on("WINDOW_RESIZE", ()=>{
17507
+ this.correctDimensions();
17508
+ });
17442
17509
  }
17443
17510
  buildElement() {
17444
17511
  this.recorderElement = document.createElement("video");
@@ -17456,7 +17523,6 @@
17456
17523
  this.recorderElement.style.transform = "rotateY(180deg)";
17457
17524
  this.recorderElement.style["-webkit-transform"] = "rotateY(180deg)";
17458
17525
  this.recorderElement.style["-moz-transform"] = "rotateY(180deg)";
17459
- if (this.options.video.stretch) this.recorderElement.style.width = "100%";
17460
17526
  this.userMedia ??= new visuals_userMedia(this, this.options);
17461
17527
  this.show();
17462
17528
  if (this.built) {
@@ -17488,13 +17554,36 @@
17488
17554
  getRecorderWidth(responsive) {
17489
17555
  if (this.userMedia?.hasVideoWidth()) return this.userMedia.getRawWidth(responsive);
17490
17556
  if (responsive && this.options.video.width) return this.limitWidth(this.options.video.width);
17491
- return this.options.video.width;
17557
+ const dimension = {
17558
+ unit: "px",
17559
+ value: this.options.video.width
17560
+ };
17561
+ return dimension;
17492
17562
  }
17493
17563
  getRecorderHeight(responsive, useBoundingClientRect) {
17494
- if (this.recorderElement && useBoundingClientRect) return this.recorderElement.getBoundingClientRect().height;
17495
- if (this.userMedia) return this.userMedia.getRawHeight(responsive);
17564
+ if (this.recorderElement && useBoundingClientRect) {
17565
+ const height = this.recorderElement.getBoundingClientRect().height;
17566
+ const dimension = {
17567
+ unit: "px",
17568
+ value: height
17569
+ };
17570
+ return dimension;
17571
+ }
17572
+ if (this.userMedia) {
17573
+ const height = this.userMedia.getRawHeight(responsive);
17574
+ const dimension = {
17575
+ unit: "px",
17576
+ value: height
17577
+ };
17578
+ return dimension;
17579
+ }
17496
17580
  if (responsive && this.options.video.height) return this.calculateHeight(responsive);
17497
- return this.options.video.height;
17581
+ const height = this.options.video.height;
17582
+ const dimension = {
17583
+ unit: "px",
17584
+ value: height
17585
+ };
17586
+ return dimension;
17498
17587
  }
17499
17588
  getRatio() {
17500
17589
  let ratio;
@@ -17845,13 +17934,22 @@
17845
17934
  this.on("ERROR", ()=>{
17846
17935
  if (util_getBrowser(this.options).isMobile()) this.removeDimensions();
17847
17936
  });
17937
+ this.on("WINDOW_RESIZE", ()=>{
17938
+ this.correctDimensions();
17939
+ });
17848
17940
  }
17849
17941
  }
17850
17942
  correctDimensions() {
17851
17943
  if (this.options.video.stretch) this.removeDimensions();
17852
17944
  else if (this.visualsElement) {
17853
- this.visualsElement.style.width = `${this.getRecorderWidth(true)}px`;
17854
- this.visualsElement.style.height = `${this.getRecorderHeight(true)}px`;
17945
+ let heightDimension;
17946
+ let widthDimension = dimensions_useFullWidth(this.options.video.mobileBreakPoint);
17947
+ if (!widthDimension) {
17948
+ widthDimension = this.getRecorderWidth(true);
17949
+ heightDimension = this.getRecorderHeight(true);
17950
+ }
17951
+ if (widthDimension) this.visualsElement.style.width = `${widthDimension.value}${widthDimension.unit}`;
17952
+ if (heightDimension) this.visualsElement.style.height = `${heightDimension.value}${heightDimension.unit}`;
17855
17953
  }
17856
17954
  }
17857
17955
  removeDimensions() {
@@ -18159,6 +18257,9 @@
18159
18257
  }
18160
18258
  initEvents(playerOnly = false) {
18161
18259
  this.options.logger.debug(`Container: initEvents (playerOnly = ${playerOnly})`);
18260
+ window.addEventListener("resize", ()=>{
18261
+ this.emit("WINDOW_RESIZE");
18262
+ });
18162
18263
  if (this.options.enableAutoUnload) window.addEventListener("beforeunload", (e)=>{
18163
18264
  this.unload({
18164
18265
  e
@@ -18196,6 +18297,9 @@
18196
18297
  const browser = util_getBrowser(this.options);
18197
18298
  if (browser.isMobile()) this.removeDimensions();
18198
18299
  });
18300
+ this.on("WINDOW_RESIZE", ()=>{
18301
+ this.correctDimensions();
18302
+ });
18199
18303
  if (!playerOnly) this.on("LOADED_META_DATA", ()=>{
18200
18304
  this.correctDimensions();
18201
18305
  });
@@ -18203,8 +18307,9 @@
18203
18307
  correctDimensions() {
18204
18308
  if (this.options.video.stretch) this.removeDimensions();
18205
18309
  else if (this.containerElement) {
18206
- const width = this.visuals.getRecorderWidth(true);
18207
- if (width) this.containerElement.style.width = `${width}px`;
18310
+ let dimension = dimensions_useFullWidth(this.options.video.mobileBreakPoint);
18311
+ if (!dimension) dimension = this.visuals.getRecorderWidth(true);
18312
+ if (dimension?.value) this.containerElement.style.width = `${dimension.value}${dimension.unit}`;
18208
18313
  }
18209
18314
  }
18210
18315
  removeDimensions() {
@@ -18228,8 +18333,10 @@
18228
18333
  if (!videomailFormData) throw new Error("No videomail form data defined");
18229
18334
  if (method === FormMethod.POST) {
18230
18335
  videomailFormData.recordingStats = this.visuals.getRecordingStats();
18231
- videomailFormData.width = this.visuals.getRecorderWidth(true);
18232
- videomailFormData.height = this.visuals.getRecorderHeight(true);
18336
+ const widthDimension = this.visuals.getRecorderWidth(true);
18337
+ const heightDimension = this.visuals.getRecorderHeight(true);
18338
+ videomailFormData.width = widthDimension?.value;
18339
+ videomailFormData.height = heightDimension.value;
18233
18340
  return await this.resource.post(videomailFormData);
18234
18341
  }
18235
18342
  if (method === FormMethod.PUT) return await this.resource.put(videomailFormData);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "videomail-client",
3
- "version": "13.3.3",
3
+ "version": "13.4.0",
4
4
  "description": "A wicked npm package to record videos directly in the browser, wohooo!",
5
5
  "keywords": [
6
6
  "webcam",
@@ -91,7 +91,7 @@
91
91
  "@types/node": "24.10.0",
92
92
  "@types/superagent": "8.1.9",
93
93
  "@types/ua-parser-js": "0.7.39",
94
- "@vitest/eslint-plugin": "1.4.1",
94
+ "@vitest/eslint-plugin": "1.4.2",
95
95
  "audit-ci": "7.1.0",
96
96
  "chromatic": "13.3.3",
97
97
  "cross-env": "10.1.0",
@@ -100,13 +100,13 @@
100
100
  "eslint-plugin-de-morgan": "2.0.0",
101
101
  "eslint-plugin-depend": "1.3.1",
102
102
  "eslint-plugin-import-x": "4.16.1",
103
- "eslint-plugin-package-json": "0.64.0",
103
+ "eslint-plugin-package-json": "0.65.3",
104
104
  "eslint-plugin-promise": "7.2.1",
105
105
  "eslint-plugin-regexp": "2.10.0",
106
106
  "eslint-plugin-security": "3.0.1",
107
107
  "eslint-plugin-simple-import-sort": "12.1.1",
108
108
  "eslint-plugin-storybook": "9.1.16",
109
- "globals": "16.4.0",
109
+ "globals": "16.5.0",
110
110
  "jsdom": "27.1.0",
111
111
  "msw": "2.11.6",
112
112
  "msw-storybook-addon": "2.0.6",
@@ -120,7 +120,7 @@
120
120
  "type-fest": "5.2.0",
121
121
  "typescript": "5.9.3",
122
122
  "typescript-eslint": "8.41.0",
123
- "vitest": "4.0.7"
123
+ "vitest": "4.0.8"
124
124
  },
125
125
  "engines": {
126
126
  "node": "^24.11.0",