videomail-client 15.11.0 → 16.0.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/README.md CHANGED
@@ -1,33 +1,35 @@
1
1
  # videomail-client ✉
2
2
 
3
- [![Test Runner for videomail-client](https://github.com/binarykitchen/videomail-client/actions/workflows/ci.yml/badge.svg)](https://github.com/binarykitchen/videomail-client/actions/workflows/ci.yml)
3
+ [![Test Runner for videomail-client][ci-badge]][ci-workflow]
4
4
 
5
- [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![Netlify Status](https://api.netlify.com/api/v1/badges/3c9df5b4-8b85-4081-950a-d5df2dbd9926/deploy-status)](https://app.netlify.com/sites/videomail-client/deploys)
5
+ [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![Netlify Status][netlify-image]][netlify-url]
6
6
 
7
+ [ci-badge]: https://github.com/binarykitchen/videomail-client/actions/workflows/ci.yml/badge.svg
8
+ [ci-workflow]: https://github.com/binarykitchen/videomail-client/actions/workflows/ci.yml
7
9
  [npm-image]: https://img.shields.io/npm/v/videomail-client.svg?style=flat
8
10
  [npm-url]: https://npmjs.org/package/videomail-client
9
11
  [downloads-image]: https://img.shields.io/npm/dm/videomail-client.svg?style=flat
10
12
  [downloads-url]: https://npmjs.org/package/videomail-client
13
+ [netlify-image]: https://api.netlify.com/api/v1/badges/3c9df5b4-8b85-4081-950a-d5df2dbd9926/deploy-status
14
+ [netlify-url]: https://app.netlify.com/sites/videomail-client/deploys
11
15
 
12
16
  Record webcam videos in contact forms.
13
17
 
14
18
  The client captures image frames with `navigator.mediaDevices.getUserMedia()`, streams them to the Videomail service over WebSocket, and receives an encoded video. No browser plugins are required. The package includes ESM, CommonJS, UMD, and TypeScript declaration builds.
15
19
 
16
- - [Live demo](#demo)
17
- - [Storybook examples](#storybook)
20
+ - [Live demo](#live-demo)
21
+ - [Storybook examples](#storybook-examples)
18
22
  - [Installation](#installation)
19
23
  - [Options](#options)
20
24
  - [API](#api)
21
- - [Form submissions](#form)
22
- - [Privacy and error reporting](#privacy)
23
- - [Stored videomail data](#whatisstored)
25
+ - [Form submissions](#form-submissions)
26
+ - [Privacy and error reporting](#privacy-and-error-reporting)
27
+ - [Stored videomail data](#stored-videomail-data)
24
28
  - [Whitelist](#whitelist)
25
- - [Browser compatibility](#compatibility)
26
- - [Add-ons](#addons)
29
+ - [Browser compatibility](#browser-compatibility)
30
+ - [Add-ons](#add-ons)
27
31
  - [Notes](#notes)
28
32
 
29
- <a name="demo"></a>
30
-
31
33
  ## Live Demo
32
34
 
33
35
  Try it at [videomail-client.netlify.app](https://videomail-client.netlify.app).
@@ -42,8 +44,6 @@ And there is more:
42
44
  - [https://www.deaf.org.nz/contact](https://www.deaf.org.nz/contact)
43
45
  - And other sites using the package or its WordPress integration.
44
46
 
45
- <a name="storybook"></a>
46
-
47
47
  ## Storybook examples
48
48
 
49
49
  To check out some examples in your browser locally, just run these two commands:
@@ -53,8 +53,6 @@ To check out some examples in your browser locally, just run these two commands:
53
53
 
54
54
  Storybook starts an HTTPS development server at `https://localhost:8443` using the certificates in `etc/ssl-certs`.
55
55
 
56
- <a name="installation"></a>
57
-
58
56
  ## Installation
59
57
 
60
58
  ```sh
@@ -69,8 +67,6 @@ const videomailClient = new VideomailClient({
69
67
  });
70
68
  ```
71
69
 
72
- <a name="options"></a>
73
-
74
70
  ## Options
75
71
 
76
72
  You can pass options to the `VideomailClient` constructor. See the annotated defaults in [src/options.ts](https://github.com/binarykitchen/videomail-client/blob/master/src/options.ts).
@@ -79,42 +75,44 @@ The defaults suit most integrations. Set `whitelistKey` when deploying on your o
79
75
 
80
76
  The examples in [src/stories](https://github.com/binarykitchen/videomail-client/tree/master/src/stories) show common configurations.
81
77
 
82
- <a name="api"></a>
78
+ ### Audio
79
+
80
+ Audio recording is experimental and disabled by default. Set `audio.enabled` to `true` to enable it.
81
+
82
+ `audio.volume` controls recording gain from `0` (silence) to `1` (unchanged microphone level, the default). It does not control playback volume or enable audible microphone monitoring.
83
83
 
84
84
  ## API
85
85
 
86
- - <a href="#constructor">`new VideomailClient()`</a>
87
- - <a href="#on">`videomailClient.on()`</a>
88
- - <a href="#show">`videomailClient.show()`</a>
89
- - <a href="#hide">`videomailClient.hide()`</a>
90
- - <a href="#record">`videomailClient.record()`</a>
91
- - <a href="#replay">`videomailClient.replay()`</a>
92
- - <a href="#startOver">`videomailClient.startOver()`</a>
93
- - <a href="#getByAlias">`videomailClient.getByAlias()`</a>
94
- - <a href="#getByKey">`videomailClient.getByKey()`</a>
95
- - <a href="#getThreadByAlias">`videomailClient.getThreadByAlias()`</a>
96
- - <a href="#getThreadByKey">`videomailClient.getThreadByKey()`</a>
97
- - <a href="#unload">`videomailClient.unload()`</a>
98
- - <a href="#isDirty">`videomailClient.isDirty()`</a>
99
- - <a href="#isRecording">`videomailClient.isRecording()`</a>
100
- - <a href="#isBuilt">`videomailClient.isBuilt()`</a>
101
- - <a href="#submit">`videomailClient.submit()`</a>
102
- - <a href="#getLogLines">`videomailClient.getLogLines()`</a>
103
- - <a href="#setLimitSeconds">`videomailClient.setLimitSeconds()`</a>
104
-
105
- <a name="constructor"></a>
86
+ - [`new VideomailClient()`](#new-videomailclientoptions)
87
+ - [`videomailClient.on()`](#videomailclienton)
88
+ - [`videomailClient.show()`](#videomailclientshow)
89
+ - [`videomailClient.hide()`](#videomailclienthide)
90
+ - [`videomailClient.record()`](#videomailclientrecord)
91
+ - [`videomailClient.replay()`](#videomailclientreplayvideomail-parentelementid)
92
+ - [`videomailClient.startOver()`](#videomailclientstartover)
93
+ - [`videomailClient.getByAlias()`](#videomailclientgetbyaliasalias)
94
+ - [`videomailClient.getByKey()`](#videomailclientgetbykeykey)
95
+ - [`videomailClient.getThreadByAlias()`](#videomailclientgetthreadbyaliasalias)
96
+ - [`videomailClient.getThreadByKey()`](#videomailclientgetthreadbykeykey)
97
+ - [`videomailClient.unload()`](#videomailclientunload)
98
+ - [`videomailClient.isDirty()`](#videomailclientisdirty)
99
+ - [`videomailClient.isRecording()`](#videomailclientisrecording)
100
+ - [`videomailClient.isBuilt()`](#videomailclientisbuilt)
101
+ - [`videomailClient.submit()`](#videomailclientsubmit)
102
+ - [`videomailClient.getLogLines()`](#videomailclientgetloglines)
103
+ - [`videomailClient.setLimitSeconds()`](#videomailclientsetlimitsecondslimitseconds)
106
104
 
107
105
  ### new VideomailClient([options])
108
106
 
109
107
  The constructor accepts an optional [options](#options) object:
110
108
 
111
109
  ```ts
112
- const videomailClient = new VideomailClient({ whitelistKey: "my whitelist key" });
110
+ const videomailClient = new VideomailClient({
111
+ whitelistKey: "my whitelist key",
112
+ });
113
113
  ```
114
114
 
115
- <a name="on"></a>
116
-
117
- ### videomailClient.on([event,] [callback])
115
+ ### videomailClient.on()
118
116
 
119
117
  `VideomailClient` provides an event-emitter-style API. `on()` returns an unsubscribe function:
120
118
 
@@ -138,20 +136,14 @@ The client includes default visual error handling. Applications can also subscri
138
136
 
139
137
  Videomail errors extend the native `Error` class and include additional diagnostic data.
140
138
 
141
- <a name="show"></a>
142
-
143
139
  ### videomailClient.show()
144
140
 
145
141
  Automatically fills the DOM with a form for video recording. By default the HTML element with the ID `videomail` will be filled, see options.
146
142
 
147
- <a name="record"></a>
148
-
149
143
  ### videomailClient.record()
150
144
 
151
145
  Starts recording without requiring the user to press the record button.
152
146
 
153
- <a name="replay"></a>
154
-
155
147
  ### videomailClient.replay(videomail[, parentElementId])
156
148
 
157
149
  Adds a video player for the supplied videomail.
@@ -166,14 +158,10 @@ Also note that, when the parent element already contains a video container like
166
158
 
167
159
  the client reuses it instead of creating another DOM element.
168
160
 
169
- <a name="startOver"></a>
170
-
171
161
  ### videomailClient.startOver()
172
162
 
173
163
  Resets the client and returns it to the ready state so the same instance can record another videomail.
174
164
 
175
- <a name="getByAlias"></a>
176
-
177
165
  ### videomailClient.getByAlias(alias)
178
166
 
179
167
  Returns a videomail asynchronously for the given alias. You can obtain the alias from:
@@ -181,74 +169,50 @@ Returns a videomail asynchronously for the given alias. You can obtain the alias
181
169
  1. The form submission to your own server has it under `videomail_alias` in the form body.
182
170
  2. The `SUBMITTED` event payload.
183
171
 
184
- <a name="getByKey"></a>
185
-
186
172
  ### videomailClient.getByKey(key)
187
173
 
188
174
  Returns a videomail asynchronously for its unique key.
189
175
 
190
- <a name="getThreadByAlias"></a>
191
-
192
176
  ### videomailClient.getThreadByAlias(alias)
193
177
 
194
178
  Returns the videomail thread containing the given alias.
195
179
 
196
- <a name="getThreadByKey"></a>
197
-
198
180
  ### videomailClient.getThreadByKey(key)
199
181
 
200
182
  Returns the videomail thread containing the given key.
201
183
 
202
- <a name="unload"></a>
203
-
204
184
  ### videomailClient.unload()
205
185
 
206
186
  Manually unloads the webcam and all other internal event listeners.
207
187
 
208
- <a name="hide"></a>
209
-
210
188
  ### videomailClient.hide()
211
189
 
212
190
  Hides all the visuals (but does not unload anything).
213
191
 
214
- <a name="isDirty"></a>
215
-
216
192
  ### videomailClient.isDirty()
217
193
 
218
194
  Returns `true` when a video has been recorded but not submitted. This can be used before navigation to warn about an unsent recording.
219
195
 
220
- <a name="isRecording"></a>
221
-
222
196
  ### videomailClient.isRecording()
223
197
 
224
198
  Returns `true` while a video is being recorded.
225
199
 
226
- <a name="isBuilt"></a>
227
-
228
200
  ### videomailClient.isBuilt()
229
201
 
230
202
  Returns `true` after the client UI has been built and before it is unloaded.
231
203
 
232
- <a name="submit"></a>
233
-
234
204
  ### videomailClient.submit()
235
205
 
236
206
  Manually triggers submission when the client and form are valid. This is useful when another UI layer owns the visible submit control.
237
207
 
238
- <a name="getLogLines"></a>
239
-
240
208
  ### videomailClient.getLogLines()
241
209
 
242
210
  Returns the recently collected log lines when the configured logger supports collection.
243
211
 
244
- <a name="setLimitSeconds"></a>
245
-
246
212
  ### videomailClient.setLimitSeconds(limitSeconds)
247
213
 
248
214
  Updates the recording time limit for subsequent recording activity.
249
215
 
250
- <a name="whatisstored"></a>
251
-
252
216
  ## Stored videomail data
253
217
 
254
218
  The `SUBMITTED` event includes a `videomail` object. The exact response can evolve, but its shape follows the exported `Videomail` type. A shortened example is shown below:
@@ -294,11 +258,11 @@ For new recordings, submitted `width` and `height` describe the captured canvas
294
258
 
295
259
  You can also retrieve this data with `videomailClient.getByKey()`.
296
260
 
297
- <a name="form"></a>
298
-
299
261
  ## Form Submissions
300
262
 
301
- By default, the client prevents the initial form submission and submits the videomail to the Videomail server first. After the server returns the alias and metadata, the client submits the original form.
263
+ With `enableAutoSubmission` enabled (the default), a recorded video and an explicit form `action` produce two requests: the client sends Videomail first, then POSTs the original form fields to that action after success. Without a recorded video, the client POSTs the form directly to its action.
264
+
265
+ For first-party Videomail forms without an explicit `action`, a recorded video is sent in one request to the Videomail API; listen for `SUBMITTED` to handle the response. Set `enableAutoSubmission: false` when a host framework owns form submission, then let that integration resume its submission after `SUBMITTED`.
302
266
 
303
267
  If this does not work, verify that the configured selectors identify the form and its submit button:
304
268
 
@@ -314,9 +278,7 @@ When these values are `undefined` (the defaults), the client detects the nearest
314
278
 
315
279
  ### Include videomail meta data in Form Submissions
316
280
 
317
- Enable `submitWithVideomail` to include videomail metadata in the submission to your server. Otherwise the form body contains the videomail alias, which can later be resolved with `videomailClient.getByAlias(alias)`.
318
-
319
- <a name="privacy"></a>
281
+ When the client sends the second, host-form request, enable `submitWithVideomail` to include full videomail metadata under the `videomail` key. Otherwise the original form fields include the videomail alias, which can later be resolved with `videomailClient.getByAlias(alias)`.
320
282
 
321
283
  ## Privacy and error reporting
322
284
 
@@ -324,23 +286,17 @@ Recording sends webcam frames, and audio samples when enabled, to the configured
324
286
 
325
287
  The `reportErrors` option defaults to `true`. When an error occurs, the client can send the error, recent client logs, browser and operating-system details, page location, screen and orientation data, supported media constraints, and enumerated media-device information to the configured API. Set `reportErrors: false` if your privacy policy requires local-only error handling.
326
288
 
327
- <a name="whitelist"></a>
328
-
329
289
  ## Whitelist
330
290
 
331
291
  Examples work at [https://localhost:8443](https://localhost:8443) because localhost is allowed by the remote Videomail server. `https://localhost` and `https://localhost:443` are also available for local development. Other origins require their own whitelist entry.
332
292
 
333
293
  For a deployed domain, request access at [videomail.io/whitelist](https://videomail.io/whitelist). You will receive a whitelist key for the approved origins.
334
294
 
335
- <a name="compatibility"></a>
336
-
337
295
  ## Browser compatibility
338
296
 
339
297
  Recording requires a secure context (`https://` or localhost) and support for `navigator.mediaDevices.getUserMedia()`, WebSocket, Canvas, and Web Audio when audio is enabled. Current evergreen desktop and mobile browsers are supported. Internet Explorer is not supported.
340
298
 
341
- See [Can I Use: Media Capture from DOM Elements](https://caniuse.com/stream) and test the [live demo](#demo) in the browsers required by your integration.
342
-
343
- <a name="addons"></a>
299
+ See [Can I Use: Media Capture from DOM Elements](https://caniuse.com/stream) and test the [live demo](#live-demo) in the browsers required by your integration.
344
300
 
345
301
  ## Add-ons
346
302
 
@@ -348,8 +304,6 @@ There is also a Videomail WordPress add-on: <https://wordpress.org/plugins/video
348
304
 
349
305
  It extends the Ninja Forms form builder with a webcam input and submission integration.
350
306
 
351
- <a name="notes"></a>
352
-
353
307
  ## Notes
354
308
 
355
309
  ### Changelog