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 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
- Finally you can encode any webcam recordings from modern browsers and mobiles into MP4 + WebM within seconds.
17
- This without the need for Flash, Java nor any other plugins / addons. Just TypeScript, compiled into ESM with their declarations.
18
-
19
- - <a href="#demo">Live Demo
20
- - <a href="#storybook">Storybook (examples)</a>
21
- - <a href="#options">Options</a>
22
- - <a href="#api">API</a>
23
- - <a href="#form">Form Submissions</a>
24
- - <a href="#whatisstored">What gets stored on the videomail server?</a>
25
- - <a href="#whitelist">Whitelist</a>
26
- - <a href="#compatibility">Backward compatibility</a>
27
- - <a href="#addons">Addons</a>
28
- - <a href="#notes">Notes</a>
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
- Have fun on [videomail-client.netlify.app](https://videomail-client.netlify.app)
35
+ Try it at [videomail-client.netlify.app](https://videomail-client.netlify.app).
35
36
 
36
- ### Real world usages
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 (examples)
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
- That's it. Easy as apple pie.
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
- There are many options you can pass onto the VideomailClient constructor. Check out the annotated source code at [src/options.ts](https://github.com/binarykitchen/videomail-client/blob/master/src/options.ts)
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
- In most cases, these defaults are good enough. Only one option, `whitelistKey` should be changed when you deploy your own site, see <a href="#whitelist">Whitelist</a>.
80
+ The defaults suit most integrations. Set `whitelistKey` when deploying on your own site; see [Whitelist](#whitelist).
66
81
 
67
- Looking at the examples in the `/src/stories` folder should give you some ideas how to use these options.
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 a JSON with optional <a href="#options">options</a>. Example:
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
- The VideomailClient class is inherited from EventEmitter and emits lots of useful events for your app. Here an example:
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
- // continue with your own app logic in your javascript code if you want to process
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
- They should be self-explanatory. If not, ask for better documentation. Then, some of these events may come with parameters.
137
+ Some events include typed parameters exported by the package.
123
138
 
124
- The videomail client already comes with internal error handling mechanism so there is no need to add code to display errors. But depending on your app logic you might want to process errors further with your own error listeners.
139
+ The client includes default visual error handling. Applications can also subscribe to the `ERROR` event for custom logging or recovery.
125
140
 
126
- By the way, all videomail errors are instances of `VideomailError`, inherited from the native Error class and come with additional attributes, useful for debugging weird errors.
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
- Forcefully starts recording without the need to press on a record button. Useful for special situations.
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
- Manually adds a video container for the given videomail inside the parent element. See stories for some inspiration.
159
+ Adds a video player for the supplied videomail.
145
160
 
146
- If the `parentElement` is an ID (string), then it will be resolved into a DOM element internally. If no parent element is given, then a replay container within the containerId is automatically generated.
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
- then this will be used instead of adding a new dom element.
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
- Start all over again, resets everything and go back to the ready state. Useful if you want to submit another videomail within the same instance.
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
- Queries a videomail (JSON) asynchronously by a given alias for further queries or processing. There are two ways to get the alias:
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. Get the alias from the `submitted` event and use it further within your code.
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 and a form exists. Useful when checking something before closing the window, i.E. this use case: show a window confirmation dialog to make sure the user didn't forget to submit the recorded video.
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 when a video is currently being recorded.
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
- For advanced use only: especially when the submit button is covered with other HTML layers and the videomail client fails to process the click event.
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
- For advanced use only: returns you a collection of log lines that show what code has been covered recently. Useful if you want to debug something tricky.
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
- For advanced use only: sets the recording time limit in seconds. Useful if you want to dynamically change the recording duration.
250
+ Updates the recording time limit for subsequent recording activity.
213
251
 
214
252
  <a name="whatisstored"></a>
215
253
 
216
- ## What gets stored on the videomail server?
254
+ ## Stored videomail data
217
255
 
218
- Here is an example JSON showing what videomail meta data exists, gets stored on the server and you can grab yourself for further use.
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
- "dateCreatedPretty": "Nov 2, 2018, 4:49 PM",
250
- "expiresAfterPretty": "Nov 2, 2018, 5:49 PM",
251
- "expiresAfterIso": "2018-11-02T04:49:49.811Z"
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 also can get all the above using the `videomailClient.getByKey()` API call.
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 videomail-client interrupts the form submission with `e.preventDefault()` and submits the videomail itself to the videomail server first. The videomail server replies with useful data, such as the videomail alias, other meta data and only then the real form submission is resumed.
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 doesn't seem to work on your side, then this is mostly because the form and the submit button couldn't be found and the submission event is fired too late. To fix this, you'll need to correct the selectors under options. Here are the important ones regarding forms:
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
- "formId": null,
268
- "submitButtonId": null,
269
- "submitButtonSelector": null
270
- },
307
+ formId: undefined,
308
+ submitButtonId: undefined,
309
+ submitButtonSelector: undefined,
310
+ }
271
311
  ```
272
312
 
273
- When these are null (defaults), the videomail-client tries to detect these automatically. But it can happen that detection fails because the form is somewhere else under the DOM or the submit button does not have the `type=submit` etc.
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
- If you want to include videomail meta data in the form submission to your own server, enable the `submitWithVideomail` option.
278
- Otherwise only the videomail alias is in the form body and will have to call `videomail.getByAlias(alias)` to retrieve these later on.
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 will work right away on [https://localhost:8443](https://localhost:8443). This is because localhost is whitelisted on the remote Videomail server. `https://localhost` and `https://localhost:443` are whitelisted too for local development. Other IP addresses won't work. If this is a problem, contact me and I can whitelist more.
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
- In other words, if your web server is connected through a domain besides localhost, the Videomail-Client is restricted from sending the media packets to the remote Videomail server which is responsible for storing and sending videomails. To fix that, just lodge a whitelist request at [https://videomail.io/whitelist](https://videomail.io/whitelist). Then you should get a new whitelist key and a list of whitelisted URLs for your own usage.
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
- ## Backward compatibility
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
- Source: [http://caniuse.com/#search=getUserMedia](http://caniuse.com/#search=getUserMedia)
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
- PS: On Safari and iPhones/iPads you can play the videomails fine without any issues. Repeating: there is just no recording functionality for them yet until Apple made a move.
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
- ## Addons
345
+ ## Add-ons
310
346
 
311
- There is a Videomail WordPress addon, wicked!
347
+ There is also a Videomail WordPress add-on:
312
348
  <https://wordpress.org/plugins/videomail-for-ninja-forms/>
313
349
 
314
- It's an extension of the popular form builder called Ninja Forms. When the videomail addon is installed, then you can just drag and drop a live webcam input into the form! And tell what should happen upon submission. So easy.
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
- Too hard to maintain. Just do `git log` or look here
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
- Here some noise about Videomail in the wild:
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 guys helped inspired me for this awesome project. Thank you so much:
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
- I admit, code isn't top notch and needs lots of rewrites. Believe me or not, I already rewrote about three times in the last four years. Good example that software hardly can be perfect. And since I am already honest here, I think stability and bug fixes come first before perfection otherwise you'll loose users. Reality you know.
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
- This planet is completely sold. And talk is overrated. That's why my primary goal is not to turn this into a commercial product, yet to promote a cool but underestimated language: Sign Language.
394
+ The primary goal is to make Sign Language easier to use in email and web forms.