videomail-client 15.7.15 → 15.7.17
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 +126 -91
- package/dist/cjs/index.cjs +2038 -38
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +28 -23
- package/dist/esm/resource.d.ts +1 -1
- package/dist/esm/types/command.d.ts +0 -1
- package/dist/esm/types/events/params.d.ts +1 -1
- package/dist/esm/util/summarize.d.ts +1 -2
- package/dist/umd/index.js +2038 -38
- package/package.json +13 -7
package/README.md
CHANGED
|
@@ -11,29 +11,30 @@
|
|
|
11
11
|
[downloads-image]: https://img.shields.io/npm/dm/videomail-client.svg?style=flat
|
|
12
12
|
[downloads-url]: https://npmjs.org/package/videomail-client
|
|
13
13
|
|
|
14
|
-
Record videos in contact forms
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
14
|
+
Record webcam videos in contact forms.
|
|
15
|
+
|
|
16
|
+
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.
|
|
17
|
+
|
|
18
|
+
- [Live demo](#demo)
|
|
19
|
+
- [Storybook examples](#storybook)
|
|
20
|
+
- [Installation](#installation)
|
|
21
|
+
- [Options](#options)
|
|
22
|
+
- [API](#api)
|
|
23
|
+
- [Form submissions](#form)
|
|
24
|
+
- [Privacy and error reporting](#privacy)
|
|
25
|
+
- [Stored videomail data](#whatisstored)
|
|
26
|
+
- [Whitelist](#whitelist)
|
|
27
|
+
- [Browser compatibility](#compatibility)
|
|
28
|
+
- [Add-ons](#addons)
|
|
29
|
+
- [Notes](#notes)
|
|
29
30
|
|
|
30
31
|
<a name="demo"></a>
|
|
31
32
|
|
|
32
33
|
## Live Demo
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
Try it at [videomail-client.netlify.app](https://videomail-client.netlify.app).
|
|
35
36
|
|
|
36
|
-
### Real
|
|
37
|
+
### Real-world usage
|
|
37
38
|
|
|
38
39
|
There is a full version with all its features on [videomail.io](https://videomail.io).
|
|
39
40
|
|
|
@@ -41,30 +42,44 @@ And there is more:
|
|
|
41
42
|
|
|
42
43
|
- [https://wfdeaf.org/contact](https://wfdeaf.org/contact)
|
|
43
44
|
- [https://www.deaf.org.nz/contact](https://www.deaf.org.nz/contact)
|
|
44
|
-
-
|
|
45
|
-
|
|
46
|
-
And many more out there. We are rolling ...
|
|
45
|
+
- And other sites using the package or its WordPress integration.
|
|
47
46
|
|
|
48
47
|
<a name="storybook"></a>
|
|
49
48
|
|
|
50
|
-
## Storybook
|
|
49
|
+
## Storybook examples
|
|
51
50
|
|
|
52
51
|
To check out some examples in your browser locally, just run these two commands:
|
|
53
52
|
|
|
54
53
|
1. `npm install`
|
|
55
54
|
2. `npm run storybook`
|
|
56
55
|
|
|
57
|
-
|
|
56
|
+
Storybook starts an HTTPS development server at `https://localhost:8443` using the certificates in `etc/ssl-certs`.
|
|
57
|
+
|
|
58
|
+
<a name="installation"></a>
|
|
59
|
+
|
|
60
|
+
## Installation
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
npm install videomail-client
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
import { VideomailClient } from "videomail-client";
|
|
68
|
+
|
|
69
|
+
const videomailClient = new VideomailClient({
|
|
70
|
+
whitelistKey: "your-whitelist-key",
|
|
71
|
+
});
|
|
72
|
+
```
|
|
58
73
|
|
|
59
74
|
<a name="options"></a>
|
|
60
75
|
|
|
61
76
|
## Options
|
|
62
77
|
|
|
63
|
-
|
|
78
|
+
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).
|
|
64
79
|
|
|
65
|
-
|
|
80
|
+
The defaults suit most integrations. Set `whitelistKey` when deploying on your own site; see [Whitelist](#whitelist).
|
|
66
81
|
|
|
67
|
-
|
|
82
|
+
The examples in [src/stories](https://github.com/binarykitchen/videomail-client/tree/master/src/stories) show common configurations.
|
|
68
83
|
|
|
69
84
|
<a name="api"></a>
|
|
70
85
|
|
|
@@ -79,8 +94,9 @@ Looking at the examples in the `/src/stories` folder should give you some ideas
|
|
|
79
94
|
- <a href="#startOver">`videomailClient.startOver()`</a>
|
|
80
95
|
- <a href="#getByAlias">`videomailClient.getByAlias()`</a>
|
|
81
96
|
- <a href="#getByKey">`videomailClient.getByKey()`</a>
|
|
97
|
+
- <a href="#getThreadByAlias">`videomailClient.getThreadByAlias()`</a>
|
|
98
|
+
- <a href="#getThreadByKey">`videomailClient.getThreadByKey()`</a>
|
|
82
99
|
- <a href="#unload">`videomailClient.unload()`</a>
|
|
83
|
-
- <a href="#hide">`videomailClient.hide()`</a>
|
|
84
100
|
- <a href="#isDirty">`videomailClient.isDirty()`</a>
|
|
85
101
|
- <a href="#isRecording">`videomailClient.isRecording()`</a>
|
|
86
102
|
- <a href="#isBuilt">`videomailClient.isBuilt()`</a>
|
|
@@ -92,7 +108,7 @@ Looking at the examples in the `/src/stories` folder should give you some ideas
|
|
|
92
108
|
|
|
93
109
|
### new VideomailClient([options])
|
|
94
110
|
|
|
95
|
-
The constructor accepts
|
|
111
|
+
The constructor accepts an optional [options](#options) object:
|
|
96
112
|
|
|
97
113
|
```ts
|
|
98
114
|
const videomailClient = new VideomailClient({ whitelistKey: "my whitelist key" });
|
|
@@ -102,16 +118,15 @@ const videomailClient = new VideomailClient({ whitelistKey: "my whitelist key" }
|
|
|
102
118
|
|
|
103
119
|
### videomailClient.on([event,] [callback])
|
|
104
120
|
|
|
105
|
-
|
|
121
|
+
`VideomailClient` provides an event-emitter-style API. `on()` returns an unsubscribe function:
|
|
106
122
|
|
|
107
123
|
```ts
|
|
108
124
|
videomailClient.on("FORM_READY", () => {
|
|
109
|
-
// form is ready for recording
|
|
125
|
+
// The form is ready for recording.
|
|
110
126
|
});
|
|
111
127
|
|
|
112
128
|
videomailClient.on("SUBMITTED", ({ videomail, response }) => {
|
|
113
|
-
//
|
|
114
|
-
// something else further after form submission.
|
|
129
|
+
// Continue with application-specific submission handling.
|
|
115
130
|
});
|
|
116
131
|
```
|
|
117
132
|
|
|
@@ -119,11 +134,11 @@ videomailClient.on("SUBMITTED", ({ videomail, response }) => {
|
|
|
119
134
|
|
|
120
135
|
Check them out at [src/types/events/index.ts](https://github.com/binarykitchen/videomail-client/blob/master/src/types/events/index.ts)
|
|
121
136
|
|
|
122
|
-
|
|
137
|
+
Some events include typed parameters exported by the package.
|
|
123
138
|
|
|
124
|
-
The
|
|
139
|
+
The client includes default visual error handling. Applications can also subscribe to the `ERROR` event for custom logging or recovery.
|
|
125
140
|
|
|
126
|
-
|
|
141
|
+
Videomail errors extend the native `Error` class and include additional diagnostic data.
|
|
127
142
|
|
|
128
143
|
<a name="show"></a>
|
|
129
144
|
|
|
@@ -135,15 +150,15 @@ Automatically fills the DOM with a form for video recording. By default the HTML
|
|
|
135
150
|
|
|
136
151
|
### videomailClient.record()
|
|
137
152
|
|
|
138
|
-
|
|
153
|
+
Starts recording without requiring the user to press the record button.
|
|
139
154
|
|
|
140
155
|
<a name="replay"></a>
|
|
141
156
|
|
|
142
157
|
### videomailClient.replay(videomail[, parentElementId])
|
|
143
158
|
|
|
144
|
-
|
|
159
|
+
Adds a video player for the supplied videomail.
|
|
145
160
|
|
|
146
|
-
If
|
|
161
|
+
If `replayParentElementId` is supplied, the player is inserted into that element. Otherwise, the client uses or creates a replay container within the configured container.
|
|
147
162
|
|
|
148
163
|
Also note that, when the parent element already contains a video container like this
|
|
149
164
|
|
|
@@ -151,22 +166,40 @@ Also note that, when the parent element already contains a video container like
|
|
|
151
166
|
<video class="replay"></video>
|
|
152
167
|
```
|
|
153
168
|
|
|
154
|
-
|
|
169
|
+
the client reuses it instead of creating another DOM element.
|
|
155
170
|
|
|
156
171
|
<a name="startOver"></a>
|
|
157
172
|
|
|
158
173
|
### videomailClient.startOver()
|
|
159
174
|
|
|
160
|
-
|
|
175
|
+
Resets the client and returns it to the ready state so the same instance can record another videomail.
|
|
161
176
|
|
|
162
177
|
<a name="getByAlias"></a>
|
|
163
178
|
|
|
164
179
|
### videomailClient.getByAlias(alias)
|
|
165
180
|
|
|
166
|
-
|
|
181
|
+
Returns a videomail asynchronously for the given alias. You can obtain the alias from:
|
|
167
182
|
|
|
168
183
|
1. The form submission to your own server has it under `videomail_alias` in the form body.
|
|
169
|
-
2.
|
|
184
|
+
2. The `SUBMITTED` event payload.
|
|
185
|
+
|
|
186
|
+
<a name="getByKey"></a>
|
|
187
|
+
|
|
188
|
+
### videomailClient.getByKey(key)
|
|
189
|
+
|
|
190
|
+
Returns a videomail asynchronously for its unique key.
|
|
191
|
+
|
|
192
|
+
<a name="getThreadByAlias"></a>
|
|
193
|
+
|
|
194
|
+
### videomailClient.getThreadByAlias(alias)
|
|
195
|
+
|
|
196
|
+
Returns the videomail thread containing the given alias.
|
|
197
|
+
|
|
198
|
+
<a name="getThreadByKey"></a>
|
|
199
|
+
|
|
200
|
+
### videomailClient.getThreadByKey(key)
|
|
201
|
+
|
|
202
|
+
Returns the videomail thread containing the given key.
|
|
170
203
|
|
|
171
204
|
<a name="unload"></a>
|
|
172
205
|
|
|
@@ -184,39 +217,43 @@ Hides all the visuals (but does not unload anything).
|
|
|
184
217
|
|
|
185
218
|
### videomailClient.isDirty()
|
|
186
219
|
|
|
187
|
-
Returns true when a video has been recorded
|
|
220
|
+
Returns `true` when a video has been recorded but not submitted. This can be used before navigation to warn about an unsent recording.
|
|
188
221
|
|
|
189
222
|
<a name="isRecording"></a>
|
|
190
223
|
|
|
191
224
|
### videomailClient.isRecording()
|
|
192
225
|
|
|
193
|
-
Returns true
|
|
226
|
+
Returns `true` while a video is being recorded.
|
|
227
|
+
|
|
228
|
+
<a name="isBuilt"></a>
|
|
229
|
+
|
|
230
|
+
### videomailClient.isBuilt()
|
|
231
|
+
|
|
232
|
+
Returns `true` after the client UI has been built and before it is unloaded.
|
|
194
233
|
|
|
195
234
|
<a name="submit"></a>
|
|
196
235
|
|
|
197
236
|
### videomailClient.submit()
|
|
198
237
|
|
|
199
|
-
|
|
200
|
-
Calling this function will manually trigger a submission of the recorded videomail. But only when everything else is valid. Nothing will happen when invalid.
|
|
238
|
+
Manually triggers submission when the client and form are valid. This is useful when another UI layer owns the visible submit control.
|
|
201
239
|
|
|
202
240
|
<a name="getLogLines"></a>
|
|
203
241
|
|
|
204
242
|
### videomailClient.getLogLines()
|
|
205
243
|
|
|
206
|
-
|
|
244
|
+
Returns the recently collected log lines when the configured logger supports collection.
|
|
207
245
|
|
|
208
246
|
<a name="setLimitSeconds"></a>
|
|
209
247
|
|
|
210
|
-
### videomailClient.setLimitSeconds()
|
|
248
|
+
### videomailClient.setLimitSeconds(limitSeconds)
|
|
211
249
|
|
|
212
|
-
|
|
250
|
+
Updates the recording time limit for subsequent recording activity.
|
|
213
251
|
|
|
214
252
|
<a name="whatisstored"></a>
|
|
215
253
|
|
|
216
|
-
##
|
|
254
|
+
## Stored videomail data
|
|
217
255
|
|
|
218
|
-
|
|
219
|
-
It's emitted in the SUBMITTED event under the videomail object:
|
|
256
|
+
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:
|
|
220
257
|
|
|
221
258
|
```json
|
|
222
259
|
{
|
|
@@ -235,83 +272,82 @@ It's emitted in the SUBMITTED event under the videomail object:
|
|
|
235
272
|
},
|
|
236
273
|
"width": 320,
|
|
237
274
|
"height": 240,
|
|
238
|
-
"videomailClientVersion": "2.4.11",
|
|
239
275
|
"whitelistKey": "videomail-client-demo",
|
|
240
276
|
"alias": "some-subject-183622500964",
|
|
241
277
|
"dateCreated": 1541130589811,
|
|
242
278
|
"url": "https://videomail.io/videomail/some-subject-150322500964",
|
|
243
279
|
"key": "11e8-de52-55ac2630-b22b-71959562a989",
|
|
244
|
-
"expirationPretty": "1 hour",
|
|
245
280
|
"expiresAfter": 1541134189811,
|
|
281
|
+
"expiresAfterIso": "2018-11-02T04:49:49.811Z",
|
|
282
|
+
"expiresAfterServerPretty": "Nov 2, 2018, 5:49 PM",
|
|
246
283
|
"siteName": "Videomail Client Example",
|
|
247
284
|
"webm": "https://videomail.io/videomail/some-subject-183622500964/type/webm/",
|
|
248
285
|
"poster": "https://videomail.io/videomail/some-subject-183622500964/poster/",
|
|
249
|
-
"
|
|
250
|
-
"
|
|
251
|
-
"
|
|
286
|
+
"dateCreatedServerPretty": "Nov 2, 2018, 4:49 PM",
|
|
287
|
+
"replyUrl": "https://videomail.io/reply/some-subject-183622500964",
|
|
288
|
+
"sending": false,
|
|
289
|
+
"versions": {
|
|
290
|
+
"videomailClient": "15.7.14"
|
|
291
|
+
}
|
|
252
292
|
}
|
|
253
293
|
```
|
|
254
294
|
|
|
255
|
-
You
|
|
295
|
+
You can also retrieve this data with `videomailClient.getByKey()`.
|
|
256
296
|
|
|
257
297
|
<a name="form"></a>
|
|
258
298
|
|
|
259
299
|
## Form Submissions
|
|
260
300
|
|
|
261
|
-
By default the
|
|
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.
|
|
262
302
|
|
|
263
|
-
If this
|
|
303
|
+
If this does not work, verify that the configured selectors identify the form and its submit button:
|
|
264
304
|
|
|
265
305
|
```ts
|
|
266
306
|
selectors: {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}
|
|
307
|
+
formId: undefined,
|
|
308
|
+
submitButtonId: undefined,
|
|
309
|
+
submitButtonSelector: undefined,
|
|
310
|
+
}
|
|
271
311
|
```
|
|
272
312
|
|
|
273
|
-
When these are
|
|
313
|
+
When these values are `undefined` (the defaults), the client detects the nearest form and a button with `type="submit"` automatically.
|
|
274
314
|
|
|
275
315
|
### Include videomail meta data in Form Submissions
|
|
276
316
|
|
|
277
|
-
|
|
278
|
-
|
|
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>
|
|
320
|
+
|
|
321
|
+
## Privacy and error reporting
|
|
322
|
+
|
|
323
|
+
Recording sends webcam frames, and audio samples when enabled, to the configured Videomail service for encoding. The package does not provide offline recording.
|
|
324
|
+
|
|
325
|
+
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.
|
|
279
326
|
|
|
280
327
|
<a name="whitelist"></a>
|
|
281
328
|
|
|
282
329
|
## Whitelist
|
|
283
330
|
|
|
284
|
-
Examples
|
|
331
|
+
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.
|
|
285
332
|
|
|
286
|
-
|
|
333
|
+
For a deployed domain, request access at [videomail.io/whitelist](https://videomail.io/whitelist). You will receive a whitelist key for the approved origins.
|
|
287
334
|
|
|
288
335
|
<a name="compatibility"></a>
|
|
289
336
|
|
|
290
|
-
##
|
|
291
|
-
|
|
292
|
-
Forget the old IE, Safari below version 11 and ancient iPhones/iPads because they don't support `getUserMedia()`. Do not blame me but Apple + Microsoft _chuckle_ - for now, these browsers work like a charm:
|
|
293
|
-
|
|
294
|
-
- Firefox >= 34
|
|
295
|
-
- Google Chrome >= 32
|
|
296
|
-
- Microsoft Edge >= 12
|
|
297
|
-
- Internet Explorer >= 12
|
|
298
|
-
- Opera >= 26
|
|
299
|
-
- Chrome for Android >= 39
|
|
300
|
-
- Android Browser >= 37
|
|
301
|
-
- Safari >= 11
|
|
337
|
+
## Browser compatibility
|
|
302
338
|
|
|
303
|
-
|
|
339
|
+
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.
|
|
304
340
|
|
|
305
|
-
|
|
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.
|
|
306
342
|
|
|
307
343
|
<a name="addons"></a>
|
|
308
344
|
|
|
309
|
-
##
|
|
345
|
+
## Add-ons
|
|
310
346
|
|
|
311
|
-
There is a Videomail WordPress
|
|
347
|
+
There is also a Videomail WordPress add-on:
|
|
312
348
|
<https://wordpress.org/plugins/videomail-for-ninja-forms/>
|
|
313
349
|
|
|
314
|
-
It
|
|
350
|
+
It extends the Ninja Forms form builder with a webcam input and submission integration.
|
|
315
351
|
|
|
316
352
|
<a name="notes"></a>
|
|
317
353
|
|
|
@@ -319,12 +355,11 @@ It's an extension of the popular form builder called Ninja Forms. When the video
|
|
|
319
355
|
|
|
320
356
|
### Changelog
|
|
321
357
|
|
|
322
|
-
|
|
323
|
-
<https://github.com/binarykitchen/videomail-client/commits/master>
|
|
358
|
+
A separate changelog is not maintained. Use `git log` or the [commit history](https://github.com/binarykitchen/videomail-client/commits/master).
|
|
324
359
|
|
|
325
360
|
### Noise
|
|
326
361
|
|
|
327
|
-
|
|
362
|
+
Videomail in the wild:
|
|
328
363
|
|
|
329
364
|
- [LimpingChicken](http://limpingchicken.com/2017/06/29/michael-heuberger-ive-created-a-web-form-to-send-emails-in-sign-language/)
|
|
330
365
|
|
|
@@ -336,7 +371,7 @@ Bear with me, there are lots of problems to crack, especially with the performan
|
|
|
336
371
|
|
|
337
372
|
### Credits
|
|
338
373
|
|
|
339
|
-
These
|
|
374
|
+
These people helped inspire the project:
|
|
340
375
|
|
|
341
376
|
- Heath Sadler (Designer)
|
|
342
377
|
- Stefan Weber (Designer)
|
|
@@ -352,8 +387,8 @@ They all deserve lots of love in return. Thank you so much.
|
|
|
352
387
|
|
|
353
388
|
### Code quality
|
|
354
389
|
|
|
355
|
-
|
|
390
|
+
The project prioritizes stability and bug fixes over large rewrites. Its implementation has evolved several times as browser media APIs and integration requirements have changed.
|
|
356
391
|
|
|
357
392
|
### Final philosophy
|
|
358
393
|
|
|
359
|
-
|
|
394
|
+
The primary goal is to make Sign Language easier to use in email and web forms.
|