videomail-client 13.3.3 → 13.4.1

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.1"
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,27 @@
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
+ else this.notifyElement.style.removeProperty("width");
15967
+ if (heightDimension) this.notifyElement.style.height = `${heightDimension.value}${heightDimension.unit}`;
15968
+ else this.notifyElement.style.removeProperty("height");
15936
15969
  }
15937
15970
  }
15938
15971
  show() {
@@ -16134,7 +16167,7 @@
16134
16167
  function figureMinHeight(height, options) {
16135
16168
  let minHeight;
16136
16169
  if (options.video.height) {
16137
- minHeight = Math.min(options.video.height, height);
16170
+ minHeight = height ? Math.min(options.video.height, height) : options.video.height;
16138
16171
  if (minHeight < 1) throw error_createError({
16139
16172
  message: `Got a min height less than 1 (${minHeight})!`,
16140
16173
  options
@@ -16155,24 +16188,38 @@
16155
16188
  }
16156
16189
  const dimensions_getRatio = getRatio;
16157
16190
  function calculateHeight(responsive, videoWidth, options, target, ratio, element) {
16191
+ const dimension = {
16192
+ unit: "px"
16193
+ };
16158
16194
  let width = videoWidth;
16159
16195
  if (width < 1) throw error_createError({
16160
16196
  message: `Unable to calculate height for target ${target} when width is less than 1 (= ${width}) and responsive mode is set to ${responsive}`,
16161
16197
  options
16162
16198
  });
16163
- if (responsive && element) width = dimensions_limitWidth(element, options, width);
16199
+ if (responsive && element) {
16200
+ const limitedDimension = dimensions_limitWidth(element, options, width);
16201
+ width = limitedDimension.value;
16202
+ }
16164
16203
  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({
16204
+ const height = width ? Math.round(width * chosenRatio) : void 0;
16205
+ if (height && Number.isInteger(height) && height < 1) throw error_createError({
16167
16206
  message: "Just calculated a height less than 1 which is wrong.",
16168
16207
  options
16169
16208
  });
16170
- return dimensions_figureMinHeight(height, options);
16209
+ const minHeight = dimensions_figureMinHeight(height, options);
16210
+ dimension.value = minHeight;
16211
+ return dimension;
16171
16212
  }
16172
16213
  const dimensions_calculateHeight = calculateHeight;
16173
16214
  function calculateWidth(responsive, videoHeight, options, ratio) {
16215
+ const dimension = {
16216
+ unit: "px"
16217
+ };
16174
16218
  let height = dimensions_figureMinHeight(videoHeight, options);
16175
- if (responsive) height = dimensions_limitHeight(height, options, "calculateWidth");
16219
+ if (responsive) {
16220
+ const limitedDimension = dimensions_limitHeight(height, options, "calculateWidth");
16221
+ height = limitedDimension.value;
16222
+ }
16176
16223
  if (!height || height < 1) throw error_createError({
16177
16224
  message: `Height ${height} cannot be smaller than 1 when calculating width.`,
16178
16225
  options
@@ -16183,7 +16230,8 @@
16183
16230
  message: "Calculated width cannot be smaller than 1!",
16184
16231
  options
16185
16232
  });
16186
- return calculatedWidth;
16233
+ dimension.value = calculatedWidth;
16234
+ return dimension;
16187
16235
  }
16188
16236
  const dimensions_calculateWidth = calculateWidth;
16189
16237
  class audio_sample_modern_t {
@@ -16523,8 +16571,8 @@
16523
16571
  }
16524
16572
  createCanvas() {
16525
16573
  const canvas = document.createElement("canvas");
16526
- const rawWidth = this.getRawWidth(true);
16527
- if (rawWidth) canvas.width = rawWidth;
16574
+ const dimension = this.getRawWidth(true);
16575
+ if (dimension.value) canvas.width = dimension.value;
16528
16576
  const rawHeight = this.getRawHeight(true);
16529
16577
  if (rawHeight) canvas.height = rawHeight;
16530
16578
  return canvas;
@@ -16543,14 +16591,25 @@
16543
16591
  }
16544
16592
  getRawWidth(responsive) {
16545
16593
  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;
16594
+ const dimension = {
16595
+ unit: "px"
16596
+ };
16597
+ if (this.options.video.width || this.options.video.height) if (responsive) {
16598
+ const dimension = this.recorder.calculateWidth(responsive);
16599
+ rawWidth = dimension.value;
16600
+ } else rawWidth = this.options.video.width;
16601
+ if (responsive) {
16602
+ const dimension = this.recorder.limitWidth(rawWidth);
16603
+ rawWidth = dimension?.value;
16604
+ }
16605
+ dimension.value = rawWidth;
16606
+ return dimension;
16549
16607
  }
16550
16608
  getRawHeight(responsive) {
16551
16609
  let rawHeight;
16552
16610
  if (this.options.video.width || this.options.video.height) {
16553
- rawHeight = this.recorder.calculateHeight(responsive);
16611
+ const heightDimension = this.recorder.calculateHeight(responsive);
16612
+ rawHeight = heightDimension.value;
16554
16613
  if (!rawHeight || rawHeight < 1) throw error_createError({
16555
16614
  message: "Bad dimensions",
16556
16615
  explanation: "Calculated raw height cannot be less than 1!",
@@ -16564,7 +16623,10 @@
16564
16623
  options: this.options
16565
16624
  });
16566
16625
  }
16567
- if (responsive) rawHeight = this.recorder.limitHeight(rawHeight);
16626
+ if (responsive) {
16627
+ const heightDimension = this.recorder.limitHeight(rawHeight);
16628
+ rawHeight = heightDimension.value;
16629
+ }
16568
16630
  return rawHeight;
16569
16631
  }
16570
16632
  getRawVisuals() {
@@ -16783,13 +16845,13 @@
16783
16845
  if (args.mp4) this.replay.setMp4Source(`${args.mp4 + constants.SITE_NAME_LABEL}/${this.options.siteName}/videomail.mp4`, true);
16784
16846
  if (args.webm) this.replay.setWebMSource(`${args.webm + constants.SITE_NAME_LABEL}/${this.options.siteName}/videomail.webm`, true);
16785
16847
  this.hide();
16786
- const width = this.getRecorderWidth(true);
16787
- const height = this.getRecorderHeight(true);
16848
+ const widthDimension = this.getRecorderWidth(true);
16849
+ const heightDimension = this.getRecorderHeight(true);
16788
16850
  const duration = args.duration ?? -1;
16789
16851
  this.emit("PREVIEW", {
16790
16852
  key: this.key,
16791
- width,
16792
- height,
16853
+ width: widthDimension?.value,
16854
+ height: heightDimension.value,
16793
16855
  hasAudio,
16794
16856
  duration
16795
16857
  });
@@ -16970,8 +17032,8 @@
16970
17032
  };
16971
17033
  } else if (constraints.video && true !== constraints.video) {
16972
17034
  const limitedWidth = this.limitWidth();
16973
- if (limitedWidth) constraints.video.width = {
16974
- ideal: limitedWidth
17035
+ if (limitedWidth?.value) constraints.video.width = {
17036
+ ideal: limitedWidth.value
16975
17037
  };
16976
17038
  }
16977
17039
  if (this.options.video.height && constraints.video && true !== constraints.video) {
@@ -17385,13 +17447,21 @@
17385
17447
  }
17386
17448
  correctDimensions() {
17387
17449
  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;
17450
+ const widthDimension = dimensions_useFullWidth(this.options.video.mobileBreakPoint);
17451
+ if (this.options.video.stretch || widthDimension) {
17452
+ this.recorderElement.style.width = "100%";
17453
+ this.recorderElement.style.removeProperty("height");
17454
+ } else {
17455
+ if (this.options.video.width) {
17456
+ const recorderWidth = this.getRecorderWidth(true);
17457
+ if (recorderWidth?.value) this.recorderElement.width = recorderWidth.value;
17458
+ else this.recorderElement.style.removeProperty("width");
17459
+ }
17460
+ if (this.options.video.height) {
17461
+ const recorderHeight = this.getRecorderHeight(true);
17462
+ if (recorderHeight.value) this.recorderElement.height = recorderHeight.value;
17463
+ else this.recorderElement.style.removeProperty("height");
17464
+ }
17395
17465
  }
17396
17466
  }
17397
17467
  switchFacingMode() {
@@ -17439,6 +17509,9 @@
17439
17509
  this.on("SWITCH_FACING_MODE", ()=>{
17440
17510
  this.switchFacingMode();
17441
17511
  });
17512
+ this.on("WINDOW_RESIZE", ()=>{
17513
+ this.correctDimensions();
17514
+ });
17442
17515
  }
17443
17516
  buildElement() {
17444
17517
  this.recorderElement = document.createElement("video");
@@ -17456,7 +17529,6 @@
17456
17529
  this.recorderElement.style.transform = "rotateY(180deg)";
17457
17530
  this.recorderElement.style["-webkit-transform"] = "rotateY(180deg)";
17458
17531
  this.recorderElement.style["-moz-transform"] = "rotateY(180deg)";
17459
- if (this.options.video.stretch) this.recorderElement.style.width = "100%";
17460
17532
  this.userMedia ??= new visuals_userMedia(this, this.options);
17461
17533
  this.show();
17462
17534
  if (this.built) {
@@ -17488,13 +17560,36 @@
17488
17560
  getRecorderWidth(responsive) {
17489
17561
  if (this.userMedia?.hasVideoWidth()) return this.userMedia.getRawWidth(responsive);
17490
17562
  if (responsive && this.options.video.width) return this.limitWidth(this.options.video.width);
17491
- return this.options.video.width;
17563
+ const dimension = {
17564
+ unit: "px",
17565
+ value: this.options.video.width
17566
+ };
17567
+ return dimension;
17492
17568
  }
17493
17569
  getRecorderHeight(responsive, useBoundingClientRect) {
17494
- if (this.recorderElement && useBoundingClientRect) return this.recorderElement.getBoundingClientRect().height;
17495
- if (this.userMedia) return this.userMedia.getRawHeight(responsive);
17570
+ if (this.recorderElement && useBoundingClientRect) {
17571
+ const height = this.recorderElement.getBoundingClientRect().height;
17572
+ const dimension = {
17573
+ unit: "px",
17574
+ value: height
17575
+ };
17576
+ return dimension;
17577
+ }
17578
+ if (this.userMedia) {
17579
+ const height = this.userMedia.getRawHeight(responsive);
17580
+ const dimension = {
17581
+ unit: "px",
17582
+ value: height
17583
+ };
17584
+ return dimension;
17585
+ }
17496
17586
  if (responsive && this.options.video.height) return this.calculateHeight(responsive);
17497
- return this.options.video.height;
17587
+ const height = this.options.video.height;
17588
+ const dimension = {
17589
+ unit: "px",
17590
+ value: height
17591
+ };
17592
+ return dimension;
17498
17593
  }
17499
17594
  getRatio() {
17500
17595
  let ratio;
@@ -17845,13 +17940,24 @@
17845
17940
  this.on("ERROR", ()=>{
17846
17941
  if (util_getBrowser(this.options).isMobile()) this.removeDimensions();
17847
17942
  });
17943
+ this.on("WINDOW_RESIZE", ()=>{
17944
+ this.correctDimensions();
17945
+ });
17848
17946
  }
17849
17947
  }
17850
17948
  correctDimensions() {
17851
17949
  if (this.options.video.stretch) this.removeDimensions();
17852
17950
  else if (this.visualsElement) {
17853
- this.visualsElement.style.width = `${this.getRecorderWidth(true)}px`;
17854
- this.visualsElement.style.height = `${this.getRecorderHeight(true)}px`;
17951
+ let heightDimension;
17952
+ let widthDimension = dimensions_useFullWidth(this.options.video.mobileBreakPoint);
17953
+ if (!widthDimension) {
17954
+ widthDimension = this.getRecorderWidth(true);
17955
+ heightDimension = this.getRecorderHeight(true);
17956
+ }
17957
+ if (widthDimension) this.visualsElement.style.width = `${widthDimension.value}${widthDimension.unit}`;
17958
+ else this.visualsElement.style.removeProperty("width");
17959
+ if (heightDimension) this.visualsElement.style.height = `${heightDimension.value}${heightDimension.unit}`;
17960
+ else this.visualsElement.style.removeProperty("height");
17855
17961
  }
17856
17962
  }
17857
17963
  removeDimensions() {
@@ -18159,6 +18265,9 @@
18159
18265
  }
18160
18266
  initEvents(playerOnly = false) {
18161
18267
  this.options.logger.debug(`Container: initEvents (playerOnly = ${playerOnly})`);
18268
+ window.addEventListener("resize", ()=>{
18269
+ this.emit("WINDOW_RESIZE");
18270
+ });
18162
18271
  if (this.options.enableAutoUnload) window.addEventListener("beforeunload", (e)=>{
18163
18272
  this.unload({
18164
18273
  e
@@ -18196,6 +18305,9 @@
18196
18305
  const browser = util_getBrowser(this.options);
18197
18306
  if (browser.isMobile()) this.removeDimensions();
18198
18307
  });
18308
+ this.on("WINDOW_RESIZE", ()=>{
18309
+ this.correctDimensions();
18310
+ });
18199
18311
  if (!playerOnly) this.on("LOADED_META_DATA", ()=>{
18200
18312
  this.correctDimensions();
18201
18313
  });
@@ -18203,8 +18315,10 @@
18203
18315
  correctDimensions() {
18204
18316
  if (this.options.video.stretch) this.removeDimensions();
18205
18317
  else if (this.containerElement) {
18206
- const width = this.visuals.getRecorderWidth(true);
18207
- if (width) this.containerElement.style.width = `${width}px`;
18318
+ let widthDimension = dimensions_useFullWidth(this.options.video.mobileBreakPoint);
18319
+ if (!widthDimension) widthDimension = this.visuals.getRecorderWidth(true);
18320
+ if (widthDimension?.value) this.containerElement.style.width = `${widthDimension.value}${widthDimension.unit}`;
18321
+ else this.containerElement.style.removeProperty("width");
18208
18322
  }
18209
18323
  }
18210
18324
  removeDimensions() {
@@ -18228,8 +18342,10 @@
18228
18342
  if (!videomailFormData) throw new Error("No videomail form data defined");
18229
18343
  if (method === FormMethod.POST) {
18230
18344
  videomailFormData.recordingStats = this.visuals.getRecordingStats();
18231
- videomailFormData.width = this.visuals.getRecorderWidth(true);
18232
- videomailFormData.height = this.visuals.getRecorderHeight(true);
18345
+ const widthDimension = this.visuals.getRecorderWidth(true);
18346
+ const heightDimension = this.visuals.getRecorderHeight(true);
18347
+ videomailFormData.width = widthDimension?.value;
18348
+ videomailFormData.height = heightDimension.value;
18233
18349
  return await this.resource.post(videomailFormData);
18234
18350
  }
18235
18351
  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.1",
4
4
  "description": "A wicked npm package to record videos directly in the browser, wohooo!",
5
5
  "keywords": [
6
6
  "webcam",
@@ -88,10 +88,10 @@
88
88
  "@tsconfig/node22": "22.0.2",
89
89
  "@tsconfig/strictest": "2.0.7",
90
90
  "@types/defined": "1.0.2",
91
- "@types/node": "24.10.0",
91
+ "@types/node": "24.10.1",
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,14 +100,14 @@
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.68.0",
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",
110
- "jsdom": "27.1.0",
109
+ "globals": "16.5.0",
110
+ "jsdom": "27.2.0",
111
111
  "msw": "2.11.6",
112
112
  "msw-storybook-addon": "2.0.6",
113
113
  "prettier": "3.6.2",
@@ -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",