videomail-client 15.11.0 → 15.11.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/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,38 @@ 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>
83
-
84
78
  ## API
85
79
 
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>
80
+ - [`new VideomailClient()`](#new-videomailclientoptions)
81
+ - [`videomailClient.on()`](#videomailclienton)
82
+ - [`videomailClient.show()`](#videomailclientshow)
83
+ - [`videomailClient.hide()`](#videomailclienthide)
84
+ - [`videomailClient.record()`](#videomailclientrecord)
85
+ - [`videomailClient.replay()`](#videomailclientreplayvideomail-parentelementid)
86
+ - [`videomailClient.startOver()`](#videomailclientstartover)
87
+ - [`videomailClient.getByAlias()`](#videomailclientgetbyaliasalias)
88
+ - [`videomailClient.getByKey()`](#videomailclientgetbykeykey)
89
+ - [`videomailClient.getThreadByAlias()`](#videomailclientgetthreadbyaliasalias)
90
+ - [`videomailClient.getThreadByKey()`](#videomailclientgetthreadbykeykey)
91
+ - [`videomailClient.unload()`](#videomailclientunload)
92
+ - [`videomailClient.isDirty()`](#videomailclientisdirty)
93
+ - [`videomailClient.isRecording()`](#videomailclientisrecording)
94
+ - [`videomailClient.isBuilt()`](#videomailclientisbuilt)
95
+ - [`videomailClient.submit()`](#videomailclientsubmit)
96
+ - [`videomailClient.getLogLines()`](#videomailclientgetloglines)
97
+ - [`videomailClient.setLimitSeconds()`](#videomailclientsetlimitsecondslimitseconds)
106
98
 
107
99
  ### new VideomailClient([options])
108
100
 
109
101
  The constructor accepts an optional [options](#options) object:
110
102
 
111
103
  ```ts
112
- const videomailClient = new VideomailClient({ whitelistKey: "my whitelist key" });
104
+ const videomailClient = new VideomailClient({
105
+ whitelistKey: "my whitelist key",
106
+ });
113
107
  ```
114
108
 
115
- <a name="on"></a>
116
-
117
- ### videomailClient.on([event,] [callback])
109
+ ### videomailClient.on()
118
110
 
119
111
  `VideomailClient` provides an event-emitter-style API. `on()` returns an unsubscribe function:
120
112
 
@@ -138,20 +130,14 @@ The client includes default visual error handling. Applications can also subscri
138
130
 
139
131
  Videomail errors extend the native `Error` class and include additional diagnostic data.
140
132
 
141
- <a name="show"></a>
142
-
143
133
  ### videomailClient.show()
144
134
 
145
135
  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
136
 
147
- <a name="record"></a>
148
-
149
137
  ### videomailClient.record()
150
138
 
151
139
  Starts recording without requiring the user to press the record button.
152
140
 
153
- <a name="replay"></a>
154
-
155
141
  ### videomailClient.replay(videomail[, parentElementId])
156
142
 
157
143
  Adds a video player for the supplied videomail.
@@ -166,14 +152,10 @@ Also note that, when the parent element already contains a video container like
166
152
 
167
153
  the client reuses it instead of creating another DOM element.
168
154
 
169
- <a name="startOver"></a>
170
-
171
155
  ### videomailClient.startOver()
172
156
 
173
157
  Resets the client and returns it to the ready state so the same instance can record another videomail.
174
158
 
175
- <a name="getByAlias"></a>
176
-
177
159
  ### videomailClient.getByAlias(alias)
178
160
 
179
161
  Returns a videomail asynchronously for the given alias. You can obtain the alias from:
@@ -181,74 +163,50 @@ Returns a videomail asynchronously for the given alias. You can obtain the alias
181
163
  1. The form submission to your own server has it under `videomail_alias` in the form body.
182
164
  2. The `SUBMITTED` event payload.
183
165
 
184
- <a name="getByKey"></a>
185
-
186
166
  ### videomailClient.getByKey(key)
187
167
 
188
168
  Returns a videomail asynchronously for its unique key.
189
169
 
190
- <a name="getThreadByAlias"></a>
191
-
192
170
  ### videomailClient.getThreadByAlias(alias)
193
171
 
194
172
  Returns the videomail thread containing the given alias.
195
173
 
196
- <a name="getThreadByKey"></a>
197
-
198
174
  ### videomailClient.getThreadByKey(key)
199
175
 
200
176
  Returns the videomail thread containing the given key.
201
177
 
202
- <a name="unload"></a>
203
-
204
178
  ### videomailClient.unload()
205
179
 
206
180
  Manually unloads the webcam and all other internal event listeners.
207
181
 
208
- <a name="hide"></a>
209
-
210
182
  ### videomailClient.hide()
211
183
 
212
184
  Hides all the visuals (but does not unload anything).
213
185
 
214
- <a name="isDirty"></a>
215
-
216
186
  ### videomailClient.isDirty()
217
187
 
218
188
  Returns `true` when a video has been recorded but not submitted. This can be used before navigation to warn about an unsent recording.
219
189
 
220
- <a name="isRecording"></a>
221
-
222
190
  ### videomailClient.isRecording()
223
191
 
224
192
  Returns `true` while a video is being recorded.
225
193
 
226
- <a name="isBuilt"></a>
227
-
228
194
  ### videomailClient.isBuilt()
229
195
 
230
196
  Returns `true` after the client UI has been built and before it is unloaded.
231
197
 
232
- <a name="submit"></a>
233
-
234
198
  ### videomailClient.submit()
235
199
 
236
200
  Manually triggers submission when the client and form are valid. This is useful when another UI layer owns the visible submit control.
237
201
 
238
- <a name="getLogLines"></a>
239
-
240
202
  ### videomailClient.getLogLines()
241
203
 
242
204
  Returns the recently collected log lines when the configured logger supports collection.
243
205
 
244
- <a name="setLimitSeconds"></a>
245
-
246
206
  ### videomailClient.setLimitSeconds(limitSeconds)
247
207
 
248
208
  Updates the recording time limit for subsequent recording activity.
249
209
 
250
- <a name="whatisstored"></a>
251
-
252
210
  ## Stored videomail data
253
211
 
254
212
  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 +252,11 @@ For new recordings, submitted `width` and `height` describe the captured canvas
294
252
 
295
253
  You can also retrieve this data with `videomailClient.getByKey()`.
296
254
 
297
- <a name="form"></a>
298
-
299
255
  ## Form Submissions
300
256
 
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.
257
+ 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.
258
+
259
+ 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
260
 
303
261
  If this does not work, verify that the configured selectors identify the form and its submit button:
304
262
 
@@ -314,9 +272,7 @@ When these values are `undefined` (the defaults), the client detects the nearest
314
272
 
315
273
  ### Include videomail meta data in Form Submissions
316
274
 
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>
275
+ 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
276
 
321
277
  ## Privacy and error reporting
322
278
 
@@ -324,23 +280,17 @@ Recording sends webcam frames, and audio samples when enabled, to the configured
324
280
 
325
281
  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
282
 
327
- <a name="whitelist"></a>
328
-
329
283
  ## Whitelist
330
284
 
331
285
  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
286
 
333
287
  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
288
 
335
- <a name="compatibility"></a>
336
-
337
289
  ## Browser compatibility
338
290
 
339
291
  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
292
 
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>
293
+ 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
294
 
345
295
  ## Add-ons
346
296
 
@@ -348,8 +298,6 @@ There is also a Videomail WordPress add-on: <https://wordpress.org/plugins/video
348
298
 
349
299
  It extends the Ninja Forms form builder with a webcam input and submission integration.
350
300
 
351
- <a name="notes"></a>
352
-
353
301
  ## Notes
354
302
 
355
303
  ### Changelog