videomail-client 8.3.1 → 8.3.3
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/package.json +1 -1
- package/prototype/js/videomail-client.js +8 -9
- package/prototype/js/videomail-client.min.js +1 -1
- package/prototype/js/videomail-client.min.js.map +1 -1
- package/src/js/client.js +0 -210
- package/src/js/constants.js +0 -11
- package/src/js/events.js +0 -46
- package/src/js/index.js +0 -15
- package/src/js/options.js +0 -180
- package/src/js/resource.js +0 -206
- package/src/js/util/audioRecorder.js +0 -152
- package/src/js/util/browser.js +0 -319
- package/src/js/util/collectLogger.js +0 -72
- package/src/js/util/eventEmitter.js +0 -72
- package/src/js/util/humanize.js +0 -16
- package/src/js/util/mediaEvents.js +0 -148
- package/src/js/util/pretty.js +0 -70
- package/src/js/util/standardize.js +0 -71
- package/src/js/util/videomailError.js +0 -431
- package/src/js/wrappers/buttons.js +0 -670
- package/src/js/wrappers/container.js +0 -797
- package/src/js/wrappers/dimension.js +0 -149
- package/src/js/wrappers/form.js +0 -319
- package/src/js/wrappers/optionsWrapper.js +0 -81
- package/src/js/wrappers/visuals/inside/recorder/countdown.js +0 -83
- package/src/js/wrappers/visuals/inside/recorder/facingMode.js +0 -53
- package/src/js/wrappers/visuals/inside/recorder/pausedNote.js +0 -59
- package/src/js/wrappers/visuals/inside/recorder/recordNote.js +0 -42
- package/src/js/wrappers/visuals/inside/recorder/recordTimer.js +0 -149
- package/src/js/wrappers/visuals/inside/recorderInsides.js +0 -144
- package/src/js/wrappers/visuals/notifier.js +0 -341
- package/src/js/wrappers/visuals/recorder.js +0 -1492
- package/src/js/wrappers/visuals/replay.js +0 -355
- package/src/js/wrappers/visuals/userMedia.js +0 -541
- package/src/js/wrappers/visuals.js +0 -410
- package/src/styles/css/main.min.css.js +0 -1
- package/src/styles/styl/keyframes/blink.styl +0 -16
- package/src/styles/styl/main.styl +0 -126
|
@@ -1,431 +0,0 @@
|
|
|
1
|
-
import Resource from "./../resource";
|
|
2
|
-
// https://github.com/tgriesser/create-error
|
|
3
|
-
import createError from "create-error";
|
|
4
|
-
import originalPretty from "./pretty";
|
|
5
|
-
import stringify from "safe-json-stringify";
|
|
6
|
-
|
|
7
|
-
const VIDEOMAIL_ERR_NAME = "Videomail Error";
|
|
8
|
-
|
|
9
|
-
const VideomailError = createError(Error, VIDEOMAIL_ERR_NAME, {
|
|
10
|
-
explanation: undefined,
|
|
11
|
-
logLines: undefined,
|
|
12
|
-
useragent: undefined,
|
|
13
|
-
url: undefined,
|
|
14
|
-
stack: undefined,
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
// shim pretty to exclude stack always
|
|
18
|
-
const pretty = function (anything) {
|
|
19
|
-
return originalPretty(anything, { excludes: ["stack"] });
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
// static and public attribute of this class
|
|
23
|
-
VideomailError.PERMISSION_DENIED = "PERMISSION_DENIED";
|
|
24
|
-
VideomailError.NOT_ALLOWED_ERROR = "NotAllowedError";
|
|
25
|
-
VideomailError.NOT_CONNECTED = "Not connected";
|
|
26
|
-
VideomailError.DOM_EXCEPTION = "DOMException";
|
|
27
|
-
VideomailError.STARTING_FAILED = "Starting video failed";
|
|
28
|
-
VideomailError.MEDIA_DEVICE_NOT_SUPPORTED = "MediaDeviceNotSupported";
|
|
29
|
-
VideomailError.BROWSER_PROBLEM = "browser-problem";
|
|
30
|
-
VideomailError.WEBCAM_PROBLEM = "webcam-problem";
|
|
31
|
-
VideomailError.IOS_PROBLEM = "ios-problem";
|
|
32
|
-
VideomailError.OVERCONSTRAINED = "OverconstrainedError";
|
|
33
|
-
VideomailError.NOT_FOUND_ERROR = "NotFoundError";
|
|
34
|
-
VideomailError.NOT_READABLE_ERROR = "NotReadableError";
|
|
35
|
-
VideomailError.SECURITY_ERROR = "SecurityError";
|
|
36
|
-
VideomailError.TRACK_START_ERROR = "TrackStartError";
|
|
37
|
-
VideomailError.INVALID_STATE_ERROR = "InvalidStateError";
|
|
38
|
-
|
|
39
|
-
// static function to convert an error into a videomail error
|
|
40
|
-
VideomailError.create = function (err, explanation, options, parameters) {
|
|
41
|
-
if (err && err.name === VIDEOMAIL_ERR_NAME) {
|
|
42
|
-
return err;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (!options && explanation) {
|
|
46
|
-
options = explanation;
|
|
47
|
-
explanation = undefined;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
options ||= {};
|
|
51
|
-
parameters ||= {};
|
|
52
|
-
|
|
53
|
-
// be super robust
|
|
54
|
-
const debug = (options && options.debug) || console.log;
|
|
55
|
-
const audioEnabled = options && options.isAudioEnabled && options.isAudioEnabled();
|
|
56
|
-
|
|
57
|
-
debug("VideomailError: create()", err, explanation || "(no explanation set)");
|
|
58
|
-
|
|
59
|
-
const classList = parameters.classList || [];
|
|
60
|
-
|
|
61
|
-
/*
|
|
62
|
-
* Require Browser here, not at the top of the file to avoid
|
|
63
|
-
* recursion. Because the Browser class is requiring this file as well.
|
|
64
|
-
*/
|
|
65
|
-
const Browser = require("./browser").default;
|
|
66
|
-
const browser = new Browser(options);
|
|
67
|
-
|
|
68
|
-
let errType;
|
|
69
|
-
let message;
|
|
70
|
-
let stack;
|
|
71
|
-
|
|
72
|
-
// whole code is ugly because all browsers behave so differently :(
|
|
73
|
-
|
|
74
|
-
if (typeof err === "object") {
|
|
75
|
-
if (err.name === VideomailError.TRACK_START_ERROR) {
|
|
76
|
-
errType = VideomailError.TRACK_START_ERROR;
|
|
77
|
-
} else if (err.name === VideomailError.SECURITY_ERROR) {
|
|
78
|
-
errType = VideomailError.SECURITY_ERROR;
|
|
79
|
-
} else if (err.code === 8 && err.name === VideomailError.NotFoundError) {
|
|
80
|
-
errType = VideomailError.NotFoundError;
|
|
81
|
-
} else if (err.code === 35 || err.name === VideomailError.NOT_ALLOWED_ERROR) {
|
|
82
|
-
// https://github.com/binarykitchen/videomail.io/issues/411
|
|
83
|
-
errType = VideomailError.NOT_ALLOWED_ERROR;
|
|
84
|
-
} else if (err.code === 1 && err.PERMISSION_DENIED === 1) {
|
|
85
|
-
errType = VideomailError.PERMISSION_DENIED;
|
|
86
|
-
} else if (err.constructor && err.constructor.name === VideomailError.DOM_EXCEPTION) {
|
|
87
|
-
if (err.name === VideomailError.NOT_READABLE_ERROR) {
|
|
88
|
-
errType = VideomailError.NOT_READABLE_ERROR;
|
|
89
|
-
} else {
|
|
90
|
-
errType = VideomailError.DOM_EXCEPTION;
|
|
91
|
-
}
|
|
92
|
-
} else if (
|
|
93
|
-
err.constructor &&
|
|
94
|
-
err.constructor.name === VideomailError.OVERCONSTRAINED
|
|
95
|
-
) {
|
|
96
|
-
errType = VideomailError.OVERCONSTRAINED;
|
|
97
|
-
} else if (err.message === VideomailError.STARTING_FAILED) {
|
|
98
|
-
errType = err.message;
|
|
99
|
-
} else if (err.name) {
|
|
100
|
-
errType = err.name;
|
|
101
|
-
} else if (err.type === "error" && err.target.bufferedAmount === 0) {
|
|
102
|
-
errType = VideomailError.NOT_CONNECTED;
|
|
103
|
-
}
|
|
104
|
-
} else if (err === VideomailError.NOT_CONNECTED) {
|
|
105
|
-
errType = VideomailError.NOT_CONNECTED;
|
|
106
|
-
} else {
|
|
107
|
-
errType = err;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (err && err.stack) {
|
|
111
|
-
stack = err.stack;
|
|
112
|
-
} else {
|
|
113
|
-
stack = new Error().stack;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
switch (errType) {
|
|
117
|
-
case VideomailError.SECURITY_ERROR:
|
|
118
|
-
message = "The operation was insecure";
|
|
119
|
-
explanation = "Probably you have disallowed Cookies for this page?";
|
|
120
|
-
classList.push(VideomailError.BROWSER_PROBLEM);
|
|
121
|
-
break;
|
|
122
|
-
case VideomailError.OVERCONSTRAINED:
|
|
123
|
-
message = "Invalid webcam constraints";
|
|
124
|
-
|
|
125
|
-
if (err.constraint) {
|
|
126
|
-
if (err.constraint === "width") {
|
|
127
|
-
explanation = "Your webcam does not meet the width requirement.";
|
|
128
|
-
} else {
|
|
129
|
-
explanation = `Unmet constraint: ${err.constraint}`;
|
|
130
|
-
}
|
|
131
|
-
} else {
|
|
132
|
-
explanation = err.toString();
|
|
133
|
-
}
|
|
134
|
-
break;
|
|
135
|
-
case "MediaDeviceFailedDueToShutdown":
|
|
136
|
-
message = "Webcam is shutting down";
|
|
137
|
-
explanation =
|
|
138
|
-
"This happens your webcam is already switching off and not giving you permission to use it.";
|
|
139
|
-
break;
|
|
140
|
-
case "SourceUnavailableError":
|
|
141
|
-
message = "Source of your webcam cannot be accessed";
|
|
142
|
-
explanation = "Probably it is locked from another process or has a hardware error.";
|
|
143
|
-
|
|
144
|
-
if (err.message) {
|
|
145
|
-
err.message += ` Details: ${err.message}`;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
break;
|
|
149
|
-
case VideomailError.NOT_FOUND_ERROR:
|
|
150
|
-
case "NO_DEVICES_FOUND":
|
|
151
|
-
if (audioEnabled) {
|
|
152
|
-
message = "No webcam nor microphone found";
|
|
153
|
-
explanation =
|
|
154
|
-
"Your browser cannot find a webcam with microphone attached to your machine.";
|
|
155
|
-
} else {
|
|
156
|
-
message = "No webcam found";
|
|
157
|
-
explanation = "Your browser cannot find a webcam attached to your machine.";
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
classList.push(VideomailError.WEBCAM_PROBLEM);
|
|
161
|
-
break;
|
|
162
|
-
|
|
163
|
-
case "PermissionDismissedError":
|
|
164
|
-
message = "Ooops, you didn't give me any permissions?";
|
|
165
|
-
explanation =
|
|
166
|
-
"Looks like you skipped the webcam permission dialogue.<br/>" +
|
|
167
|
-
"Please grant access next time the dialogue appears.";
|
|
168
|
-
classList.push(VideomailError.WEBCAM_PROBLEM);
|
|
169
|
-
break;
|
|
170
|
-
|
|
171
|
-
case VideomailError.NOT_ALLOWED_ERROR:
|
|
172
|
-
case VideomailError.PERMISSION_DENIED:
|
|
173
|
-
case "PermissionDeniedError":
|
|
174
|
-
message = "Permission denied";
|
|
175
|
-
|
|
176
|
-
explanation =
|
|
177
|
-
"Cannot access your webcam. This can have two reasons:<br/>" +
|
|
178
|
-
"a) you blocked access to webcam; or<br/>" +
|
|
179
|
-
"b) your webcam is already in use.";
|
|
180
|
-
|
|
181
|
-
classList.push(VideomailError.WEBCAM_PROBLEM);
|
|
182
|
-
|
|
183
|
-
break;
|
|
184
|
-
|
|
185
|
-
case "HARDWARE_UNAVAILABLE":
|
|
186
|
-
message = "Webcam is unavailable";
|
|
187
|
-
explanation = "Maybe it is already busy in another window?";
|
|
188
|
-
|
|
189
|
-
if (browser.isChromeBased() || browser.isFirefox()) {
|
|
190
|
-
explanation += " Or you have to allow access above?";
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
classList.push(VideomailError.WEBCAM_PROBLEM);
|
|
194
|
-
|
|
195
|
-
break;
|
|
196
|
-
|
|
197
|
-
case VideomailError.NOT_CONNECTED:
|
|
198
|
-
message = "Unable to connect";
|
|
199
|
-
explanation =
|
|
200
|
-
"Either the videomail server or your connection is down. " +
|
|
201
|
-
"Trying to reconnect every few seconds …";
|
|
202
|
-
break;
|
|
203
|
-
|
|
204
|
-
case "NO_VIDEO_FEED":
|
|
205
|
-
message = "No video feed found!";
|
|
206
|
-
explanation = "Your webcam is already used in another browser.";
|
|
207
|
-
classList.push(VideomailError.WEBCAM_PROBLEM);
|
|
208
|
-
break;
|
|
209
|
-
|
|
210
|
-
case VideomailError.STARTING_FAILED:
|
|
211
|
-
message = "Starting video failed";
|
|
212
|
-
explanation =
|
|
213
|
-
"Most likely this happens when the webam is already active in another browser.";
|
|
214
|
-
classList.push(VideomailError.WEBCAM_PROBLEM);
|
|
215
|
-
break;
|
|
216
|
-
|
|
217
|
-
case "DevicesNotFoundError":
|
|
218
|
-
message = "No available webcam could be found";
|
|
219
|
-
explanation =
|
|
220
|
-
"Looks like you do not have any webcam attached to your machine; or " +
|
|
221
|
-
"the one you plugged in is already used.";
|
|
222
|
-
classList.push(VideomailError.WEBCAM_PROBLEM);
|
|
223
|
-
break;
|
|
224
|
-
|
|
225
|
-
case VideomailError.NOT_READABLE_ERROR:
|
|
226
|
-
case VideomailError.TRACK_START_ERROR:
|
|
227
|
-
message = "No access to webcam";
|
|
228
|
-
explanation = "A hardware error occurred which prevented access to your webcam.";
|
|
229
|
-
classList.push(VideomailError.WEBCAM_PROBLEM);
|
|
230
|
-
break;
|
|
231
|
-
|
|
232
|
-
case VideomailError.INVALID_STATE_ERROR:
|
|
233
|
-
message = "Invalid state";
|
|
234
|
-
explanation = "Video recording stream from your webcam already has finished.";
|
|
235
|
-
classList.push(VideomailError.WEBCAM_PROBLEM);
|
|
236
|
-
break;
|
|
237
|
-
|
|
238
|
-
case VideomailError.DOM_EXCEPTION:
|
|
239
|
-
switch (err.code) {
|
|
240
|
-
case 8:
|
|
241
|
-
message = "Requested webcam not found";
|
|
242
|
-
explanation = "A webcam is needed but could not be found.";
|
|
243
|
-
classList.push(VideomailError.WEBCAM_PROBLEM);
|
|
244
|
-
break;
|
|
245
|
-
case 9: {
|
|
246
|
-
const newUrl = `https:${window.location.href.substring(window.location.protocol.length)}`;
|
|
247
|
-
message = "Security upgrade needed";
|
|
248
|
-
explanation =
|
|
249
|
-
`Click <a href="${newUrl}">here</a> to switch to HTTPs which is more safe ` +
|
|
250
|
-
` and enables encrypted videomail transfers.`;
|
|
251
|
-
classList.push(VideomailError.BROWSER_PROBLEM);
|
|
252
|
-
break;
|
|
253
|
-
}
|
|
254
|
-
case 11:
|
|
255
|
-
message = "Invalid State";
|
|
256
|
-
explanation = "The object is in an invalid, unusable state.";
|
|
257
|
-
classList.push(VideomailError.BROWSER_PROBLEM);
|
|
258
|
-
break;
|
|
259
|
-
default:
|
|
260
|
-
message = "DOM Exception";
|
|
261
|
-
explanation = pretty(err);
|
|
262
|
-
classList.push(VideomailError.BROWSER_PROBLEM);
|
|
263
|
-
break;
|
|
264
|
-
}
|
|
265
|
-
break;
|
|
266
|
-
|
|
267
|
-
/*
|
|
268
|
-
* Chrome has a weird problem where if you try to do a getUserMedia request too early, it
|
|
269
|
-
* can return a MediaDeviceNotSupported error (even though nothing is wrong and permission
|
|
270
|
-
* has been granted). Look at userMediaErrorCallback() in recorder, there we do not
|
|
271
|
-
* emit those kind of errors further and just retry.
|
|
272
|
-
*
|
|
273
|
-
* but for whatever reasons, if it happens to reach this code, then investigate this further.
|
|
274
|
-
*/
|
|
275
|
-
case VideomailError.MEDIA_DEVICE_NOT_SUPPORTED:
|
|
276
|
-
message = "Media device not supported";
|
|
277
|
-
explanation = pretty(err);
|
|
278
|
-
break;
|
|
279
|
-
|
|
280
|
-
default: {
|
|
281
|
-
const originalExplanation = explanation;
|
|
282
|
-
|
|
283
|
-
if (explanation && typeof explanation === "object") {
|
|
284
|
-
explanation = pretty(explanation);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
/*
|
|
288
|
-
* it can be that explanation itself is an error object
|
|
289
|
-
* error objects can be prettified to undefined sometimes
|
|
290
|
-
*/
|
|
291
|
-
if (!explanation && originalExplanation) {
|
|
292
|
-
if (originalExplanation.message) {
|
|
293
|
-
explanation = originalExplanation.message;
|
|
294
|
-
} else {
|
|
295
|
-
// tried toString before but nah
|
|
296
|
-
explanation = `Inspected: ${stringify(originalExplanation)}`;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
if (err) {
|
|
301
|
-
if (typeof err === "string") {
|
|
302
|
-
message = err;
|
|
303
|
-
} else {
|
|
304
|
-
if (err.message) {
|
|
305
|
-
message = pretty(err.message);
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
if (err.explanation) {
|
|
309
|
-
if (!explanation) {
|
|
310
|
-
explanation = pretty(err.explanation);
|
|
311
|
-
} else {
|
|
312
|
-
explanation += `;<br/>${pretty(err.explanation)}`;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
if (err.details) {
|
|
317
|
-
const details = pretty(err.details);
|
|
318
|
-
|
|
319
|
-
if (!explanation) {
|
|
320
|
-
explanation = details;
|
|
321
|
-
} else {
|
|
322
|
-
explanation += `;<br/>${details}`;
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
// for weird, undefined cases
|
|
329
|
-
if (!message) {
|
|
330
|
-
if (errType) {
|
|
331
|
-
message = errType;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
if (!explanation && err) {
|
|
335
|
-
explanation = pretty(err, { excludes: ["stack"] });
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
// avoid dupes
|
|
339
|
-
if (pretty(message) === explanation) {
|
|
340
|
-
explanation = undefined;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
break;
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
let logLines = null;
|
|
349
|
-
|
|
350
|
-
if (options.logger && options.logger.getLines) {
|
|
351
|
-
logLines = options.logger.getLines();
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
if (stack) {
|
|
355
|
-
message = new Error(message);
|
|
356
|
-
message.stack = stack;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
let errCode = "none";
|
|
360
|
-
|
|
361
|
-
if (err) {
|
|
362
|
-
errCode = `code=${err.code ? err.code : "undefined"}`;
|
|
363
|
-
errCode += `, type=${err.type ? err.type : "undefined"}`;
|
|
364
|
-
errCode += `, name=${err.name ? err.name : "undefined"}`;
|
|
365
|
-
errCode += `, message=${err.message ? err.message : "undefined"}`;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
const videomailError = new VideomailError(message, {
|
|
369
|
-
explanation,
|
|
370
|
-
logLines,
|
|
371
|
-
client: browser.getUsefulData(),
|
|
372
|
-
url: window.location.href,
|
|
373
|
-
siteName: options.siteName,
|
|
374
|
-
code: errCode,
|
|
375
|
-
stack, // have to assign it manually again because it is kinda protected
|
|
376
|
-
});
|
|
377
|
-
|
|
378
|
-
let resource;
|
|
379
|
-
let reportErrors = false;
|
|
380
|
-
|
|
381
|
-
if (options.reportErrors) {
|
|
382
|
-
if (typeof options.reportErrors === "function") {
|
|
383
|
-
reportErrors = options.reportErrors(videomailError);
|
|
384
|
-
} else {
|
|
385
|
-
reportErrors = options.reportErrors;
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
if (reportErrors) {
|
|
390
|
-
resource = new Resource(options);
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
if (resource) {
|
|
394
|
-
resource.reportError(videomailError, function (err2) {
|
|
395
|
-
if (err2) {
|
|
396
|
-
console.error("Unable to report error", err2);
|
|
397
|
-
}
|
|
398
|
-
});
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
function hasClass(name) {
|
|
402
|
-
return classList.indexOf(name) >= 0;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
function isBrowserProblem() {
|
|
406
|
-
return hasClass(VideomailError.BROWSER_PROBLEM) || parameters.browserProblem;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
// add some public functions
|
|
410
|
-
|
|
411
|
-
// this one is useful so that the notifier can have different css classes
|
|
412
|
-
videomailError.getClassList = function () {
|
|
413
|
-
return classList;
|
|
414
|
-
};
|
|
415
|
-
|
|
416
|
-
videomailError.removeDimensions = function () {
|
|
417
|
-
return hasClass(VideomailError.IOS_PROBLEM) || browser.isMobile();
|
|
418
|
-
};
|
|
419
|
-
|
|
420
|
-
videomailError.hideButtons = function () {
|
|
421
|
-
return isBrowserProblem() || hasClass(VideomailError.IOS_PROBLEM);
|
|
422
|
-
};
|
|
423
|
-
|
|
424
|
-
videomailError.hideForm = function () {
|
|
425
|
-
return hasClass(VideomailError.IOS_PROBLEM);
|
|
426
|
-
};
|
|
427
|
-
|
|
428
|
-
return videomailError;
|
|
429
|
-
};
|
|
430
|
-
|
|
431
|
-
export default VideomailError;
|