videomail-client 9.5.7 → 9.5.9

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/README.md CHANGED
@@ -170,7 +170,7 @@ Automatically fills the DOM with a form for video recording. By default the HTML
170
170
 
171
171
  <a name="replay"></a>
172
172
 
173
- ### videomailClient.replay(videomail[, parentElement])
173
+ ### videomailClient.replay(videomail[, parentElementId])
174
174
 
175
175
  Manually adds a video container for the given videomail inside the parent element. This is mostly called after a successful submission. See `/prototype/direct_submit.html` or `/prototype/contact_form.html` for some inspiration.
176
176
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "videomail-client",
3
- "version": "9.5.7",
3
+ "version": "9.5.9",
4
4
  "description": "A wicked npm package to record videos directly in the browser, wohooo!",
5
5
  "keywords": [
6
6
  "webcam",
@@ -71,6 +71,8 @@
71
71
  "@babel/eslint-parser": "7.25.1",
72
72
  "@babel/plugin-transform-runtime": "7.25.4",
73
73
  "@babel/preset-env": "7.25.4",
74
+ "@tsconfig/node22": "22.0.0",
75
+ "@tsconfig/strictest": "2.0.5",
74
76
  "audit-ci": "7.1.0",
75
77
  "autoprefixer": "10.4.20",
76
78
  "babelify": "10.0.0",
@@ -112,6 +114,7 @@
112
114
  "tape": "5.9.0",
113
115
  "tape-catch": "1.0.6",
114
116
  "tape-run": "11.0.0",
117
+ "typescript": "5.6.2",
115
118
  "vinyl-buffer": "1.0.1",
116
119
  "vinyl-source-stream": "2.0.0",
117
120
  "watchify": "4.0.0"
@@ -53,120 +53,117 @@
53
53
 
54
54
  // just a copy paste of json of the videomail
55
55
  // you normally would get from a xhr get request
56
- videomailClient.replay(
57
- {
58
- subject: "test example mofo",
59
- from: "automatic@videomail.io",
60
- to: ["automatic@videomail.io"],
61
- body: "",
62
- recordingStats: {
63
- avgFps: 16.39344262295082,
64
- wantedFps: 15,
65
- avgInterval: 66.19285714285714,
66
- wantedInterval: 66.66666666666667,
67
- intervalSum: 9267,
68
- framesCount: 140,
69
- videoType: "webm",
70
- waitingTime: 1378,
71
- },
72
- width: 400,
73
- height: 300,
74
- videomailClientVersion: "2.1.26",
75
- siteName: "videomail.io",
76
- sending: true,
77
- alias: "test-example-mofo-485573266478",
78
- dateCreated: 1511570565748,
79
- format: {
80
- nb_streams: 1,
81
- nb_programs: 0,
82
- format_name: "mov,mp4,m4a,3gp,3g2,mj2",
83
- format_long_name: "QuickTime / MOV",
84
- start_time: 0,
85
- duration: 8.537,
86
- size: 1349099,
87
- bit_rate: 1264237,
88
- probe_score: 100,
89
- tags: {
90
- major_brand: "isom",
91
- minor_version: "512",
92
- compatible_brands: "isomiso2avc1mp41",
93
- encoder: "Lavf57.71.100",
94
- },
56
+ videomailClient.replay({
57
+ subject: "test example mofo",
58
+ from: "automatic@videomail.io",
59
+ to: ["automatic@videomail.io"],
60
+ body: "",
61
+ recordingStats: {
62
+ avgFps: 16.39344262295082,
63
+ wantedFps: 15,
64
+ avgInterval: 66.19285714285714,
65
+ wantedInterval: 66.66666666666667,
66
+ intervalSum: 9267,
67
+ framesCount: 140,
68
+ videoType: "webm",
69
+ waitingTime: 1378,
70
+ },
71
+ width: 400,
72
+ height: 300,
73
+ videomailClientVersion: "2.1.26",
74
+ siteName: "videomail.io",
75
+ sending: true,
76
+ alias: "test-example-mofo-485573266478",
77
+ dateCreated: 1511570565748,
78
+ format: {
79
+ nb_streams: 1,
80
+ nb_programs: 0,
81
+ format_name: "mov,mp4,m4a,3gp,3g2,mj2",
82
+ format_long_name: "QuickTime / MOV",
83
+ start_time: 0,
84
+ duration: 8.537,
85
+ size: 1349099,
86
+ bit_rate: 1264237,
87
+ probe_score: 100,
88
+ tags: {
89
+ major_brand: "isom",
90
+ minor_version: "512",
91
+ compatible_brands: "isomiso2avc1mp41",
92
+ encoder: "Lavf57.71.100",
95
93
  },
96
- dateUpdated: 1511570574377,
97
- accepted: ["automatic@videomail.io"],
98
- url: "https://videomail.io/videomail/test-example-mofo-485573266478",
99
- key: "11e7-d179-62e4cfa0-8f72-6ff7f0c1e906",
100
- mp4: "https://videomail.io/videomail/test-example-mofo-485573266478/type/mp4/",
101
- webm: "https://videomail.io/videomail/test-example-mofo-485573266478/type/webm/",
102
- poster: "https://videomail.io/videomail/test-example-mofo-485573266478/poster/",
103
- reply: {
104
- parentKey: "11e7-d179-62e4cfa0-8f72-6ff7f0c1e906",
105
- subject: "RE: test example mofo",
106
- to: ["automatic@videomail.io"],
94
+ },
95
+ dateUpdated: 1511570574377,
96
+ accepted: ["automatic@videomail.io"],
97
+ url: "https://videomail.io/videomail/test-example-mofo-485573266478",
98
+ key: "11e7-d179-62e4cfa0-8f72-6ff7f0c1e906",
99
+ mp4: "https://videomail.io/videomail/test-example-mofo-485573266478/type/mp4/",
100
+ webm: "https://videomail.io/videomail/test-example-mofo-485573266478/type/webm/",
101
+ poster: "https://videomail.io/videomail/test-example-mofo-485573266478/poster/",
102
+ reply: {
103
+ parentKey: "11e7-d179-62e4cfa0-8f72-6ff7f0c1e906",
104
+ subject: "RE: test example mofo",
105
+ to: ["automatic@videomail.io"],
106
+ from: "automatic@videomail.io",
107
+ parent: {
108
+ subject: "test example mofo",
107
109
  from: "automatic@videomail.io",
108
- parent: {
109
- subject: "test example mofo",
110
- from: "automatic@videomail.io",
111
- to: ["automatic@videomail.io"],
112
- body: "",
113
- recordingStats: {
114
- avgFps: 16.39344262295082,
115
- wantedFps: 15,
116
- avgInterval: 66.19285714285714,
117
- wantedInterval: 66.66666666666667,
118
- intervalSum: 9267,
119
- framesCount: 140,
120
- videoType: "webm",
121
- waitingTime: 1378,
122
- },
123
- width: 400,
124
- height: 300,
125
- videomailClientVersion: "2.1.26",
126
- siteName: "videomail.io",
127
- sending: true,
128
- alias: "test-example-mofo-485573266478",
129
- dateCreated: 1511570565748,
130
- format: {
131
- nb_streams: 1,
132
- nb_programs: 0,
133
- format_name: "mov,mp4,m4a,3gp,3g2,mj2",
134
- format_long_name: "QuickTime / MOV",
135
- start_time: 0,
136
- duration: 8.537,
137
- size: 1349099,
138
- bit_rate: 1264237,
139
- probe_score: 100,
140
- tags: {
141
- major_brand: "isom",
142
- minor_version: "512",
143
- compatible_brands: "isomiso2avc1mp41",
144
- encoder: "Lavf57.71.100",
145
- },
146
- },
147
- dateUpdated: 1511570574377,
148
- accepted: ["automatic@videomail.io"],
149
- url: "https://videomail.io/videomail/test-example-mofo-485573266478",
150
- key: "11e7-d179-62e4cfa0-8f72-6ff7f0c1e906",
151
- reply: {
152
- parentKey: "11e7-d179-62e4cfa0-8f72-6ff7f0c1e906",
153
- subject: "RE: test example mofo",
154
- to: ["automatic@videomail.io"],
155
- from: "automatic@videomail.io",
110
+ to: ["automatic@videomail.io"],
111
+ body: "",
112
+ recordingStats: {
113
+ avgFps: 16.39344262295082,
114
+ wantedFps: 15,
115
+ avgInterval: 66.19285714285714,
116
+ wantedInterval: 66.66666666666667,
117
+ intervalSum: 9267,
118
+ framesCount: 140,
119
+ videoType: "webm",
120
+ waitingTime: 1378,
121
+ },
122
+ width: 400,
123
+ height: 300,
124
+ videomailClientVersion: "2.1.26",
125
+ siteName: "videomail.io",
126
+ sending: true,
127
+ alias: "test-example-mofo-485573266478",
128
+ dateCreated: 1511570565748,
129
+ format: {
130
+ nb_streams: 1,
131
+ nb_programs: 0,
132
+ format_name: "mov,mp4,m4a,3gp,3g2,mj2",
133
+ format_long_name: "QuickTime / MOV",
134
+ start_time: 0,
135
+ duration: 8.537,
136
+ size: 1349099,
137
+ bit_rate: 1264237,
138
+ probe_score: 100,
139
+ tags: {
140
+ major_brand: "isom",
141
+ minor_version: "512",
142
+ compatible_brands: "isomiso2avc1mp41",
143
+ encoder: "Lavf57.71.100",
156
144
  },
157
- replyUrl: "/reply/test-example-mofo-485573266478",
158
- correctUrl: "https://videomail.io/correct/test-example-mofo-485573266478",
159
- dateCreatedPretty: "Nov 25, 2017, 1:42 PM",
160
- sendingToPretty: "automatic@videomail.io",
161
145
  },
146
+ dateUpdated: 1511570574377,
147
+ accepted: ["automatic@videomail.io"],
148
+ url: "https://videomail.io/videomail/test-example-mofo-485573266478",
149
+ key: "11e7-d179-62e4cfa0-8f72-6ff7f0c1e906",
150
+ reply: {
151
+ parentKey: "11e7-d179-62e4cfa0-8f72-6ff7f0c1e906",
152
+ subject: "RE: test example mofo",
153
+ to: ["automatic@videomail.io"],
154
+ from: "automatic@videomail.io",
155
+ },
156
+ replyUrl: "/reply/test-example-mofo-485573266478",
157
+ correctUrl: "https://videomail.io/correct/test-example-mofo-485573266478",
158
+ dateCreatedPretty: "Nov 25, 2017, 1:42 PM",
159
+ sendingToPretty: "automatic@videomail.io",
162
160
  },
163
- replyUrl: "/reply/test-example-mofo-485573266478",
164
- correctUrl: "https://videomail.io/correct/test-example-mofo-485573266478",
165
- dateCreatedPretty: "Nov 25, 2017, 1:42 PM",
166
- sendingToPretty: "automatic@videomail.io",
167
161
  },
168
- "videomail",
169
- );
162
+ replyUrl: "/reply/test-example-mofo-485573266478",
163
+ correctUrl: "https://videomail.io/correct/test-example-mofo-485573266478",
164
+ dateCreatedPretty: "Nov 25, 2017, 1:42 PM",
165
+ sendingToPretty: "automatic@videomail.io",
166
+ });
170
167
  </script>
171
168
  </body>
172
169
  </html>
@@ -16434,7 +16434,7 @@ function wrappy (fn, cb) {
16434
16434
  },{}],110:[function(_dereq_,module,exports){
16435
16435
  module.exports={
16436
16436
  "name": "videomail-client",
16437
- "version": "9.5.7",
16437
+ "version": "9.5.9",
16438
16438
  "description": "A wicked npm package to record videos directly in the browser, wohooo!",
16439
16439
  "keywords": [
16440
16440
  "webcam",
@@ -16505,6 +16505,8 @@ module.exports={
16505
16505
  "@babel/eslint-parser": "7.25.1",
16506
16506
  "@babel/plugin-transform-runtime": "7.25.4",
16507
16507
  "@babel/preset-env": "7.25.4",
16508
+ "@tsconfig/node22": "22.0.0",
16509
+ "@tsconfig/strictest": "2.0.5",
16508
16510
  "audit-ci": "7.1.0",
16509
16511
  "autoprefixer": "10.4.20",
16510
16512
  "babelify": "10.0.0",
@@ -16546,6 +16548,7 @@ module.exports={
16546
16548
  "tape": "5.9.0",
16547
16549
  "tape-catch": "1.0.6",
16548
16550
  "tape-run": "11.0.0",
16551
+ "typescript": "5.6.2",
16549
16552
  "vinyl-buffer": "1.0.1",
16550
16553
  "vinyl-source-stream": "2.0.0",
16551
16554
  "watchify": "4.0.0"
@@ -16604,17 +16607,22 @@ var VideomailClient = function VideomailClient(options) {
16604
16607
  if (!container.isBuilt()) {
16605
16608
  this.build();
16606
16609
  }
16607
- container.show();
16610
+ return container.show();
16608
16611
  };
16609
16612
 
16610
16613
  /*
16611
16614
  * Automatically adds a <video> element inside the given parentElement and
16612
16615
  * loads it with the videomail
16613
16616
  */
16614
- this.replay = function (videomail, replayParentElement) {
16615
- if (!container.isBuilt()) {
16616
- container.build(true, replayParentElement);
16617
- }
16617
+ this.replay = function (videomail, replayParentElementId) {
16618
+ if (container.isBuilt()) {
16619
+ // Auto unload
16620
+ this.unload();
16621
+ }
16622
+ container.build({
16623
+ playerOnly: true,
16624
+ replayParentElementId: replayParentElementId
16625
+ });
16618
16626
  if (videomail) {
16619
16627
  videomail = container.addPlayerDimensions(videomail);
16620
16628
  }
@@ -16627,6 +16635,7 @@ var VideomailClient = function VideomailClient(options) {
16627
16635
  });
16628
16636
  var replay = container.getReplay();
16629
16637
  replay.setVideomail(videomail, true);
16638
+ return replay.getElement();
16630
16639
  };
16631
16640
  this.startOver = function (params) {
16632
16641
  var replay = container.getReplay();
@@ -18984,7 +18993,7 @@ var Container = function Container(options) {
18984
18993
  function buildChildren() {
18985
18994
  var playerOnly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
18986
18995
  var replayParentElement = arguments.length > 1 ? arguments[1] : undefined;
18987
- debug("Container: buildChildren (playerOnly = ".concat(playerOnly).concat(replayParentElement ? ", replayParentElement=\"".concat(replayParentElement, "\"") : "", ")"));
18996
+ debug("Container: buildChildren (playerOnly = ".concat(playerOnly).concat(replayParentElement ? ", replayParentElement=\"".concat(replayParentElement.id, "\"") : "", ")"));
18988
18997
  if (containerElement) {
18989
18998
  containerElement.classList.add(options.selectors.containerClass);
18990
18999
  }
@@ -18998,7 +19007,7 @@ var Container = function Container(options) {
18998
19007
  if (err.stack) {
18999
19008
  options.logger.error(err.stack);
19000
19009
  } else {
19001
- options.logger.error(err);
19010
+ options.logger.error(err.message);
19002
19011
  }
19003
19012
  if (options.displayErrors) {
19004
19013
  visuals.error(err);
@@ -19037,7 +19046,8 @@ var Container = function Container(options) {
19037
19046
  if (options.enableSpace) {
19038
19047
  if (!playerOnly) {
19039
19048
  window.addEventListener("keypress", function (e) {
19040
- var tagName = e.target.tagName;
19049
+ var _e$target;
19050
+ var tagName = (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.tagName;
19041
19051
  var isEditable = e.target.isContentEditable || e.target.contentEditable === "true" || e.target.contentEditable === true;
19042
19052
 
19043
19053
  // beware of rich text editors, hence the isEditable check (wordpress plugin issue)
@@ -19062,7 +19072,7 @@ var Container = function Container(options) {
19062
19072
  */
19063
19073
  self.on(_events.default.ERROR, function (err) {
19064
19074
  processError(err);
19065
- unloadChildren(err);
19075
+ self.endWaiting();
19066
19076
  if (err.removeDimensions && err.removeDimensions()) {
19067
19077
  removeDimensions();
19068
19078
  }
@@ -19118,9 +19128,7 @@ var Container = function Container(options) {
19118
19128
  }
19119
19129
  function submitVideomail(formData, method, cb) {
19120
19130
  var videomailFormData = form.transformFormData(formData);
19121
-
19122
- // when method is undefined, treat it as a post
19123
- if (isPost(method) || !method) {
19131
+ if (isPost(method)) {
19124
19132
  videomailFormData.recordingStats = visuals.getRecordingStats();
19125
19133
  videomailFormData.width = visuals.getRecorderWidth(true);
19126
19134
  videomailFormData.height = visuals.getRecorderHeight(true);
@@ -19238,34 +19246,42 @@ var Container = function Container(options) {
19238
19246
  });
19239
19247
  }
19240
19248
  this.build = function () {
19241
- var playerOnly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
19242
- var replayParentElement = arguments.length > 1 ? arguments[1] : undefined;
19243
- debug("Container: build (playerOnly = ".concat(playerOnly).concat(replayParentElement ? ", replayParentElement=\"".concat(replayParentElement, "\"") : "", ")"));
19249
+ var buildOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
19250
+ playerOnly: false,
19251
+ replayParentElementId: undefined,
19252
+ replayParentElement: undefined
19253
+ };
19254
+ debug("Container: build (".concat((0, _safeJsonStringify.default)(buildOptions), ")"));
19244
19255
  try {
19245
19256
  options.insertCss && prependDefaultCss();
19246
-
19247
- // Note, it can be undefined when e.g. just replaying a videomail
19248
- containerElement = document.getElementById(options.selectors.containerId);
19257
+ var containerId = options.selectors.containerId;
19258
+ if (containerId) {
19259
+ // Note, it can be undefined when e.g. just replaying a videomail or for storybooks
19260
+ containerElement = document.getElementById(options.selectors.containerId);
19261
+ } else {
19262
+ containerElement = document.createElement("div");
19263
+ }
19264
+ var replayParentElement;
19265
+ if (buildOptions.replayParentElement) {
19266
+ replayParentElement = buildOptions.replayParentElement;
19267
+ } else if (buildOptions.replayParentElementId) {
19268
+ replayParentElement = document.getElementById(buildOptions.replayParentElementId);
19269
+ }
19249
19270
 
19250
19271
  // Check if the replayParentElement could act as the container element perhaps?
19251
19272
  if (!containerElement && replayParentElement) {
19252
19273
  var _replayParentElement;
19253
- if (typeof replayParentElement === "string") {
19254
- replayParentElement = document.getElementById(replayParentElement);
19255
- }
19256
19274
  if ((_replayParentElement = replayParentElement) !== null && _replayParentElement !== void 0 && _replayParentElement.classList.contains(options.selectors.containerClass)) {
19257
19275
  containerElement = replayParentElement;
19258
19276
  }
19259
19277
  }
19260
- !built && initEvents(playerOnly);
19278
+ !built && initEvents(buildOptions.playerOnly);
19261
19279
  correctDimensions();
19262
19280
 
19263
19281
  // Building form also applies for when `playerOnly` because of
19264
19282
  // correcting mode on Videomail. This function will skip if there is no form. Easy.
19265
19283
  self.buildForm();
19266
-
19267
- // If a container element has been found, no need to pass on replayParentElement further
19268
- buildChildren(playerOnly, containerElement ? undefined : replayParentElement);
19284
+ buildChildren(buildOptions.playerOnly, buildOptions.playerOnly ? replayParentElement || containerElement : undefined);
19269
19285
  if (!hasError) {
19270
19286
  debug("Container: built.");
19271
19287
  built = true;
@@ -19276,6 +19292,7 @@ var Container = function Container(options) {
19276
19292
  } catch (exc) {
19277
19293
  self.emit(_events.default.ERROR, exc);
19278
19294
  }
19295
+ return containerElement;
19279
19296
  };
19280
19297
  this.getSubmitButton = function () {
19281
19298
  return buttons.getSubmitButton();
@@ -19294,7 +19311,7 @@ var Container = function Container(options) {
19294
19311
  htmlElement.classList && htmlElement.classList.remove("wait");
19295
19312
  };
19296
19313
  this.appendChild = function (child) {
19297
- if (!containerElement) {
19314
+ if (!containerElement || containerElement === child) {
19298
19315
  // Must be in player only mode
19299
19316
  return;
19300
19317
  }
@@ -19316,35 +19333,38 @@ var Container = function Container(options) {
19316
19333
  self.emit(_events.default.UNLOADING);
19317
19334
  unloadChildren(e);
19318
19335
  self.removeAllListeners();
19336
+ self.hide();
19319
19337
  built = submitted = false;
19320
19338
  } catch (exc) {
19321
19339
  self.emit(_events.default.ERROR, exc);
19322
19340
  }
19323
19341
  };
19324
19342
  this.show = function () {
19325
- if (containerElement) {
19326
- (0, _hidden.default)(containerElement, false);
19327
- visuals.show();
19328
- if (!hasError) {
19329
- var paused = self.isPaused();
19330
- if (paused) {
19331
- buttons.adjustButtonsForPause();
19332
- }
19343
+ if (!containerElement) {
19344
+ throw new Error("No container element exists.");
19345
+ }
19346
+ (0, _hidden.default)(containerElement, false);
19347
+ visuals.show();
19348
+ if (!hasError) {
19349
+ var paused = self.isPaused();
19350
+ if (paused) {
19351
+ buttons.adjustButtonsForPause();
19352
+ }
19333
19353
 
19334
- /*
19335
- * since https://github.com/binarykitchen/videomail-client/issues/60
19336
- * we hide areas to make it easier for the user
19337
- */
19338
- buttons.show();
19339
- if (self.isReplayShown()) {
19340
- self.emit(_events.default.PREVIEW);
19341
- } else {
19342
- self.emit(_events.default.FORM_READY, {
19343
- paused: paused
19344
- });
19345
- }
19354
+ /*
19355
+ * since https://github.com/binarykitchen/videomail-client/issues/60
19356
+ * we hide areas to make it easier for the user
19357
+ */
19358
+ buttons.show();
19359
+ if (self.isReplayShown()) {
19360
+ self.emit(_events.default.PREVIEW);
19361
+ } else {
19362
+ self.emit(_events.default.FORM_READY, {
19363
+ paused: paused
19364
+ });
19346
19365
  }
19347
19366
  }
19367
+ return containerElement;
19348
19368
  };
19349
19369
  this.hide = function () {
19350
19370
  debug("Container: hide()");