videomail-client 15.8.1 → 15.8.2
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/dist/cjs/index.cjs +241 -231
- package/dist/esm/index.js +223 -214
- package/dist/esm/{util/html/media → media}/canPlayType.d.ts +1 -1
- package/dist/esm/util/error/createError.d.ts +1 -0
- package/dist/umd/index.js +238 -229
- package/package.json +8 -8
- /package/dist/esm/{util/html/media → media}/getFirstVideoTrack.d.ts +0 -0
- /package/dist/esm/{util/html/media → media}/mediaEvents.d.ts +0 -0
package/dist/cjs/index.cjs
CHANGED
|
@@ -423,7 +423,7 @@ var __webpack_modules__ = {
|
|
|
423
423
|
return parts.join('');
|
|
424
424
|
}
|
|
425
425
|
},
|
|
426
|
-
|
|
426
|
+
dY2 (__unused_rspack_module, exports1, __webpack_require__) {
|
|
427
427
|
"use strict";
|
|
428
428
|
/*!
|
|
429
429
|
* The buffer module from node.js, for the browser.
|
|
@@ -1706,7 +1706,7 @@ var __webpack_modules__ = {
|
|
|
1706
1706
|
return null === arg || 'boolean' == typeof arg || 'number' == typeof arg || 'string' == typeof arg || 'symbol' == typeof arg || void 0 === arg;
|
|
1707
1707
|
}
|
|
1708
1708
|
exports1.isPrimitive = isPrimitive;
|
|
1709
|
-
exports1.isBuffer = __webpack_require__("
|
|
1709
|
+
exports1.isBuffer = __webpack_require__("dY2").Buffer.isBuffer;
|
|
1710
1710
|
function objectToString(o) {
|
|
1711
1711
|
return Object.prototype.toString.call(o);
|
|
1712
1712
|
}
|
|
@@ -1902,7 +1902,7 @@ var __webpack_modules__ = {
|
|
|
1902
1902
|
} : false;
|
|
1903
1903
|
},
|
|
1904
1904
|
Y4 (module, __unused_rspack_exports, __webpack_require__) {
|
|
1905
|
-
var Buffer = __webpack_require__("
|
|
1905
|
+
var Buffer = __webpack_require__("dY2").Buffer;
|
|
1906
1906
|
var process = __webpack_require__("zT");
|
|
1907
1907
|
var stream = __webpack_require__("GB");
|
|
1908
1908
|
var eos = __webpack_require__("Qd");
|
|
@@ -3462,7 +3462,7 @@ var __webpack_modules__ = {
|
|
|
3462
3462
|
exports1.PassThrough = __webpack_require__("P");
|
|
3463
3463
|
},
|
|
3464
3464
|
Uf (module, exports1, __webpack_require__) {
|
|
3465
|
-
var buffer = __webpack_require__("
|
|
3465
|
+
var buffer = __webpack_require__("dY2");
|
|
3466
3466
|
var Buffer = buffer.Buffer;
|
|
3467
3467
|
function copyProps(src, dst) {
|
|
3468
3468
|
for(var key in src)dst[key] = src[key];
|
|
@@ -4760,7 +4760,7 @@ var __webpack_modules__ = {
|
|
|
4760
4760
|
]
|
|
4761
4761
|
};
|
|
4762
4762
|
var bind = __webpack_require__("zO");
|
|
4763
|
-
var hasOwn = __webpack_require__("
|
|
4763
|
+
var hasOwn = __webpack_require__("Z");
|
|
4764
4764
|
var $concat = bind.call($call, Array.prototype.concat);
|
|
4765
4765
|
var $spliceApply = bind.call($apply, Array.prototype.splice);
|
|
4766
4766
|
var $replace = bind.call($call, String.prototype.replace);
|
|
@@ -4985,7 +4985,7 @@ var __webpack_modules__ = {
|
|
|
4985
4985
|
return hasSymbols() && !!Symbol.toStringTag;
|
|
4986
4986
|
};
|
|
4987
4987
|
},
|
|
4988
|
-
|
|
4988
|
+
Z (module, __unused_rspack_exports, __webpack_require__) {
|
|
4989
4989
|
"use strict";
|
|
4990
4990
|
var call = Function.prototype.call;
|
|
4991
4991
|
var $hasOwn = Object.prototype.hasOwnProperty;
|
|
@@ -5220,7 +5220,7 @@ var __webpack_modules__ = {
|
|
|
5220
5220
|
"use strict";
|
|
5221
5221
|
var callBound = __webpack_require__("F");
|
|
5222
5222
|
var hasToStringTag = __webpack_require__("bT")();
|
|
5223
|
-
var hasOwn = __webpack_require__("
|
|
5223
|
+
var hasOwn = __webpack_require__("Z");
|
|
5224
5224
|
var gOPD = __webpack_require__("D");
|
|
5225
5225
|
var fn;
|
|
5226
5226
|
if (hasToStringTag) {
|
|
@@ -7044,7 +7044,7 @@ var __webpack_modules__ = {
|
|
|
7044
7044
|
const Emitter = __webpack_require__("r");
|
|
7045
7045
|
const safeStringify = __webpack_require__("X");
|
|
7046
7046
|
const qs = __webpack_require__("b");
|
|
7047
|
-
const RequestBase = __webpack_require__("
|
|
7047
|
+
const RequestBase = __webpack_require__("dY");
|
|
7048
7048
|
const { isObject, mixin, hasOwn, isSafeKey } = __webpack_require__("Dp");
|
|
7049
7049
|
const ResponseBase = __webpack_require__("e");
|
|
7050
7050
|
const Agent = __webpack_require__("pf");
|
|
@@ -7459,7 +7459,7 @@ var __webpack_modules__ = {
|
|
|
7459
7459
|
return request_;
|
|
7460
7460
|
};
|
|
7461
7461
|
},
|
|
7462
|
-
|
|
7462
|
+
dY (module, __unused_rspack_exports, __webpack_require__) {
|
|
7463
7463
|
"use strict";
|
|
7464
7464
|
const { isObject, hasOwn, isSafeKey } = __webpack_require__("Dp");
|
|
7465
7465
|
module.exports = RequestBase;
|
|
@@ -7862,7 +7862,7 @@ var __webpack_modules__ = {
|
|
|
7862
7862
|
exports1.isBrotliEncoding = (res)=>/^\s*br\s*$/i.test(res.headers['content-encoding']);
|
|
7863
7863
|
},
|
|
7864
7864
|
E (module, __unused_rspack_exports, __webpack_require__) {
|
|
7865
|
-
var Buffer = __webpack_require__("
|
|
7865
|
+
var Buffer = __webpack_require__("dY2").Buffer;
|
|
7866
7866
|
/*! typedarray-to-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */ module.exports = function(arr) {
|
|
7867
7867
|
return ArrayBuffer.isView(arr) ? Buffer.from(arr.buffer, arr.byteOffset, arr.byteLength) : Buffer.from(arr);
|
|
7868
7868
|
};
|
|
@@ -8728,7 +8728,7 @@ var __webpack_modules__ = {
|
|
|
8728
8728
|
this.decoder = null;
|
|
8729
8729
|
this.encoding = null;
|
|
8730
8730
|
if (options.encoding) {
|
|
8731
|
-
if (!StringDecoder) StringDecoder = __webpack_require__("
|
|
8731
|
+
if (!StringDecoder) StringDecoder = __webpack_require__("Zw").I;
|
|
8732
8732
|
this.decoder = new StringDecoder(options.encoding);
|
|
8733
8733
|
this.encoding = options.encoding;
|
|
8734
8734
|
}
|
|
@@ -8827,7 +8827,7 @@ var __webpack_modules__ = {
|
|
|
8827
8827
|
return false === this._readableState.flowing;
|
|
8828
8828
|
};
|
|
8829
8829
|
Readable.prototype.setEncoding = function(enc) {
|
|
8830
|
-
if (!StringDecoder) StringDecoder = __webpack_require__("
|
|
8830
|
+
if (!StringDecoder) StringDecoder = __webpack_require__("Zw").I;
|
|
8831
8831
|
this._readableState.decoder = new StringDecoder(enc);
|
|
8832
8832
|
this._readableState.encoding = enc;
|
|
8833
8833
|
return this;
|
|
@@ -9933,7 +9933,7 @@ var __webpack_modules__ = {
|
|
|
9933
9933
|
exports1.PassThrough = __webpack_require__("X2");
|
|
9934
9934
|
},
|
|
9935
9935
|
CX (module, exports1, __webpack_require__) {
|
|
9936
|
-
var buffer = __webpack_require__("
|
|
9936
|
+
var buffer = __webpack_require__("dY2");
|
|
9937
9937
|
var Buffer = buffer.Buffer;
|
|
9938
9938
|
function copyProps(src, dst) {
|
|
9939
9939
|
for(var key in src)dst[key] = src[key];
|
|
@@ -9968,7 +9968,7 @@ var __webpack_modules__ = {
|
|
|
9968
9968
|
return buffer.SlowBuffer(size);
|
|
9969
9969
|
};
|
|
9970
9970
|
},
|
|
9971
|
-
|
|
9971
|
+
Zw (__unused_rspack_module, exports1, __webpack_require__) {
|
|
9972
9972
|
"use strict";
|
|
9973
9973
|
var Buffer = __webpack_require__("CX").Buffer;
|
|
9974
9974
|
var isEncoding = Buffer.isEncoding || function(encoding) {
|
|
@@ -10972,7 +10972,7 @@ var __webpack_exports__ = {};
|
|
|
10972
10972
|
var client = __webpack_require__("Q");
|
|
10973
10973
|
var client_default = /*#__PURE__*/ __webpack_require__.n(client);
|
|
10974
10974
|
var package_namespaceObject = {
|
|
10975
|
-
rE: "15.8.
|
|
10975
|
+
rE: "15.8.2"
|
|
10976
10976
|
};
|
|
10977
10977
|
function isAudioEnabled(options) {
|
|
10978
10978
|
return Boolean(options.audio.enabled);
|
|
@@ -14608,6 +14608,7 @@ var __webpack_exports__ = {};
|
|
|
14608
14608
|
].filter(Boolean).join(", ");
|
|
14609
14609
|
options.logger.debug(`VideomailError: create(${args})`);
|
|
14610
14610
|
const errData = {
|
|
14611
|
+
cause: errorParams.cause,
|
|
14611
14612
|
explanation,
|
|
14612
14613
|
logLines,
|
|
14613
14614
|
err
|
|
@@ -14848,12 +14849,12 @@ var __webpack_exports__ = {};
|
|
|
14848
14849
|
element.style.removeProperty("display");
|
|
14849
14850
|
}
|
|
14850
14851
|
const html_showElement = showElement;
|
|
14851
|
-
const
|
|
14852
|
+
const EMAIL_SEPARATOR_REGEX = /[ ,]+/gu;
|
|
14852
14853
|
function trimEmail(email) {
|
|
14853
|
-
return email.replace(
|
|
14854
|
+
return email.replace(EMAIL_SEPARATOR_REGEX, "");
|
|
14854
14855
|
}
|
|
14855
14856
|
function trimEmails(emails) {
|
|
14856
|
-
const trimmedEmails = emails.split(
|
|
14857
|
+
const trimmedEmails = emails.split(EMAIL_SEPARATOR_REGEX).map((item)=>item.trim()).filter(Boolean);
|
|
14857
14858
|
return trimmedEmails;
|
|
14858
14859
|
}
|
|
14859
14860
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -15311,6 +15312,7 @@ var __webpack_exports__ = {};
|
|
|
15311
15312
|
browser: err.browser,
|
|
15312
15313
|
code: err.code,
|
|
15313
15314
|
cookie: err.cookie,
|
|
15315
|
+
cause: err.cause instanceof Error ? serializeError(err.cause) : err.cause,
|
|
15314
15316
|
cpu: err.cpu,
|
|
15315
15317
|
device: err.device,
|
|
15316
15318
|
engine: err.engine,
|
|
@@ -19086,6 +19088,34 @@ var __webpack_exports__ = {};
|
|
|
19086
19088
|
return line;
|
|
19087
19089
|
}
|
|
19088
19090
|
const util_summarize = summarize;
|
|
19091
|
+
function getFirstVideoTrack(localMediaStream) {
|
|
19092
|
+
const videoTracks = localMediaStream.getVideoTracks();
|
|
19093
|
+
let videoTrack;
|
|
19094
|
+
if (videoTracks[0]) videoTrack = videoTracks[0];
|
|
19095
|
+
return videoTrack;
|
|
19096
|
+
}
|
|
19097
|
+
const media_getFirstVideoTrack = getFirstVideoTrack;
|
|
19098
|
+
const MEDIA_EVENTS = [
|
|
19099
|
+
"loadstart",
|
|
19100
|
+
"suspend",
|
|
19101
|
+
"progress",
|
|
19102
|
+
"abort",
|
|
19103
|
+
"emptied",
|
|
19104
|
+
"stalled",
|
|
19105
|
+
"pause",
|
|
19106
|
+
"loadeddata",
|
|
19107
|
+
"waiting",
|
|
19108
|
+
"playing",
|
|
19109
|
+
"canplay",
|
|
19110
|
+
"canplaythrough",
|
|
19111
|
+
"seeking",
|
|
19112
|
+
"seeked",
|
|
19113
|
+
"ended",
|
|
19114
|
+
"ratechange",
|
|
19115
|
+
"durationchange",
|
|
19116
|
+
"volumechange"
|
|
19117
|
+
];
|
|
19118
|
+
const mediaEvents = MEDIA_EVENTS;
|
|
19089
19119
|
function esm_define_property(obj, key, value) {
|
|
19090
19120
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
19091
19121
|
value: value,
|
|
@@ -19159,11 +19189,11 @@ var __webpack_exports__ = {};
|
|
|
19159
19189
|
let { bufferSize } = this.options.audio;
|
|
19160
19190
|
if ("auto" === bufferSize) bufferSize = util_getBrowser(this.options).isFirefox() ? 512 : 2048;
|
|
19161
19191
|
if (!is_power_of_two_default()(bufferSize)) throw error_createError({
|
|
19162
|
-
message:
|
|
19192
|
+
message: `Audio buffer size must be a power of two. The current buffer size is ${bufferSize}.`,
|
|
19163
19193
|
options: this.options
|
|
19164
19194
|
});
|
|
19165
|
-
if (this.options.audio.volume < 0 || this.options.audio.volume > 1) throw error_createError({
|
|
19166
|
-
message:
|
|
19195
|
+
if (!Number.isFinite(this.options.audio.volume) || this.options.audio.volume < 0 || this.options.audio.volume > 1) throw error_createError({
|
|
19196
|
+
message: `Audio volume must be between zero and one. The current volume is ${this.options.audio.volume}.`,
|
|
19167
19197
|
options: this.options
|
|
19168
19198
|
});
|
|
19169
19199
|
volume.gain.value = this.options.audio.volume;
|
|
@@ -19209,34 +19239,6 @@ var __webpack_exports__ = {};
|
|
|
19209
19239
|
}
|
|
19210
19240
|
}
|
|
19211
19241
|
const media_AudioRecorder = AudioRecorder;
|
|
19212
|
-
function getFirstVideoTrack(localMediaStream) {
|
|
19213
|
-
const videoTracks = localMediaStream.getVideoTracks();
|
|
19214
|
-
let videoTrack;
|
|
19215
|
-
if (videoTracks[0]) videoTrack = videoTracks[0];
|
|
19216
|
-
return videoTrack;
|
|
19217
|
-
}
|
|
19218
|
-
const media_getFirstVideoTrack = getFirstVideoTrack;
|
|
19219
|
-
const MEDIA_EVENTS = [
|
|
19220
|
-
"loadstart",
|
|
19221
|
-
"suspend",
|
|
19222
|
-
"progress",
|
|
19223
|
-
"abort",
|
|
19224
|
-
"emptied",
|
|
19225
|
-
"stalled",
|
|
19226
|
-
"pause",
|
|
19227
|
-
"loadeddata",
|
|
19228
|
-
"waiting",
|
|
19229
|
-
"playing",
|
|
19230
|
-
"canplay",
|
|
19231
|
-
"canplaythrough",
|
|
19232
|
-
"seeking",
|
|
19233
|
-
"seeked",
|
|
19234
|
-
"ended",
|
|
19235
|
-
"ratechange",
|
|
19236
|
-
"durationchange",
|
|
19237
|
-
"volumechange"
|
|
19238
|
-
];
|
|
19239
|
-
const mediaEvents = MEDIA_EVENTS;
|
|
19240
19242
|
const VIRTUAL_KEYWORDS = [
|
|
19241
19243
|
"obs",
|
|
19242
19244
|
"virtual",
|
|
@@ -19573,7 +19575,7 @@ var __webpack_exports__ = {};
|
|
|
19573
19575
|
}
|
|
19574
19576
|
}
|
|
19575
19577
|
const visuals_userMedia = UserMedia;
|
|
19576
|
-
var Buffer = __webpack_require__("
|
|
19578
|
+
var Buffer = __webpack_require__("dY2").Buffer;
|
|
19577
19579
|
function recorder_define_property(obj, key, value) {
|
|
19578
19580
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
19579
19581
|
value: value,
|
|
@@ -19655,6 +19657,7 @@ var __webpack_exports__ = {};
|
|
|
19655
19657
|
const switchingFacingMode = null == params ? void 0 : params.switchingFacingMode;
|
|
19656
19658
|
this.userMediaLoading = this.blocking = this.unloaded = this.submitting = false;
|
|
19657
19659
|
this.userMediaLoaded = true;
|
|
19660
|
+
this.clearUserMediaTimeout();
|
|
19658
19661
|
if (!switchingFacingMode) this.loop = this.createLoop();
|
|
19659
19662
|
this.show();
|
|
19660
19663
|
if (null == params ? void 0 : params.recordWhenReady) this.record();
|
|
@@ -19685,6 +19688,7 @@ var __webpack_exports__ = {};
|
|
|
19685
19688
|
return navigator.onLine;
|
|
19686
19689
|
}
|
|
19687
19690
|
failConnection(params) {
|
|
19691
|
+
var _this_stream;
|
|
19688
19692
|
if (this.connectionFailed || this.connected || this.unloaded) return;
|
|
19689
19693
|
this.connectionFailed = true;
|
|
19690
19694
|
this.connecting = false;
|
|
@@ -19700,12 +19704,17 @@ var __webpack_exports__ = {};
|
|
|
19700
19704
|
closeReason: null == closeEvent ? void 0 : closeEvent.reason,
|
|
19701
19705
|
elapsedMs,
|
|
19702
19706
|
online,
|
|
19707
|
+
secureContext: globalThis.isSecureContext,
|
|
19708
|
+
socketReadyState: null == (_this_stream = this.stream) ? void 0 : _this_stream.socket.readyState,
|
|
19709
|
+
timeoutMs: this.options.timeouts.connection,
|
|
19710
|
+
url: url2Connect,
|
|
19703
19711
|
unloaded: this.unloaded,
|
|
19704
19712
|
userMediaLoaded: this.userMediaLoaded,
|
|
19705
19713
|
userMediaLoading: this.userMediaLoading,
|
|
19706
19714
|
wasClean: null == closeEvent ? void 0 : closeEvent.wasClean,
|
|
19707
19715
|
socketError,
|
|
19708
|
-
blocking: this.blocking
|
|
19716
|
+
blocking: this.blocking,
|
|
19717
|
+
visibilityState: document.visibilityState
|
|
19709
19718
|
};
|
|
19710
19719
|
const debugLine = util_summarize("Recorder: failConnection() diagnostic", contents);
|
|
19711
19720
|
this.options.logger.debug(debugLine);
|
|
@@ -19725,6 +19734,7 @@ var __webpack_exports__ = {};
|
|
|
19725
19734
|
message: "Unable to connect to the server",
|
|
19726
19735
|
explanation,
|
|
19727
19736
|
options: this.options,
|
|
19737
|
+
cause: contents,
|
|
19728
19738
|
exc: socketError ? new Error("WebSocket connection error", {
|
|
19729
19739
|
cause: socketError
|
|
19730
19740
|
}) : void 0
|
|
@@ -19803,197 +19813,197 @@ var __webpack_exports__ = {};
|
|
|
19803
19813
|
this.recordingStats.waitingTime = this.waitingTime;
|
|
19804
19814
|
}
|
|
19805
19815
|
initSocket(cb) {
|
|
19806
|
-
if (
|
|
19807
|
-
|
|
19808
|
-
|
|
19809
|
-
|
|
19810
|
-
|
|
19811
|
-
|
|
19812
|
-
|
|
19813
|
-
|
|
19814
|
-
|
|
19815
|
-
|
|
19816
|
-
|
|
19817
|
-
|
|
19818
|
-
|
|
19819
|
-
|
|
19820
|
-
|
|
19821
|
-
|
|
19822
|
-
|
|
19823
|
-
|
|
19824
|
-
|
|
19825
|
-
|
|
19826
|
-
|
|
19827
|
-
|
|
19828
|
-
|
|
19829
|
-
|
|
19830
|
-
|
|
19831
|
-
|
|
19832
|
-
|
|
19833
|
-
|
|
19834
|
-
|
|
19835
|
-
|
|
19836
|
-
|
|
19837
|
-
|
|
19838
|
-
|
|
19839
|
-
|
|
19840
|
-
|
|
19841
|
-
|
|
19842
|
-
|
|
19843
|
-
|
|
19844
|
-
|
|
19845
|
-
|
|
19846
|
-
}
|
|
19847
|
-
|
|
19848
|
-
|
|
19849
|
-
|
|
19850
|
-
}
|
|
19851
|
-
|
|
19852
|
-
|
|
19853
|
-
|
|
19854
|
-
|
|
19855
|
-
|
|
19856
|
-
|
|
19857
|
-
|
|
19858
|
-
|
|
19859
|
-
|
|
19860
|
-
|
|
19861
|
-
|
|
19862
|
-
|
|
19863
|
-
|
|
19864
|
-
|
|
19865
|
-
|
|
19866
|
-
|
|
19867
|
-
|
|
19868
|
-
|
|
19869
|
-
|
|
19870
|
-
|
|
19871
|
-
|
|
19872
|
-
|
|
19873
|
-
|
|
19874
|
-
|
|
19875
|
-
|
|
19876
|
-
|
|
19877
|
-
|
|
19878
|
-
|
|
19879
|
-
}
|
|
19880
|
-
|
|
19881
|
-
|
|
19882
|
-
|
|
19883
|
-
|
|
19884
|
-
|
|
19885
|
-
|
|
19886
|
-
|
|
19887
|
-
|
|
19888
|
-
|
|
19889
|
-
|
|
19890
|
-
}, connectionTimeoutMs);
|
|
19891
|
-
this.stream.on("close", ()=>{
|
|
19892
|
-
const debugLine = util_summarize(`${PIPE_SYMBOL}Stream has closed:`, {
|
|
19893
|
-
connecting: this.connecting,
|
|
19894
|
-
connected: this.connected,
|
|
19895
|
-
userMediaLoaded: this.userMediaLoaded,
|
|
19896
|
-
blocking: this.blocking
|
|
19897
|
-
});
|
|
19898
|
-
this.options.logger.debug(debugLine);
|
|
19899
|
-
const tryReconnect = this.connected && this.userMediaLoaded;
|
|
19900
|
-
this.connected = false;
|
|
19901
|
-
if (tryReconnect) this.initSocket();
|
|
19902
|
-
else if (!this.connecting && !this.blocking) window.setTimeout(()=>{
|
|
19903
|
-
this.failConnection({
|
|
19904
|
-
url2Connect,
|
|
19905
|
-
cause: "closed"
|
|
19906
|
-
});
|
|
19907
|
-
}, 0);
|
|
19816
|
+
if (this.connected) return void (null == cb || cb());
|
|
19817
|
+
if (this.connecting) return;
|
|
19818
|
+
if (util_isAutomatedUserAgent()) {
|
|
19819
|
+
this.connecting = false;
|
|
19820
|
+
this.options.logger.debug("Recorder: skipping web socket connection for an automated crawler");
|
|
19821
|
+
return;
|
|
19822
|
+
}
|
|
19823
|
+
this.connecting = true;
|
|
19824
|
+
this.connectionFailed = false;
|
|
19825
|
+
this.connectingStartedAt = Date.now();
|
|
19826
|
+
this.lastCloseEvent = void 0;
|
|
19827
|
+
this.lastSocketError = void 0;
|
|
19828
|
+
this.emit("CONNECTING");
|
|
19829
|
+
let url2Connect;
|
|
19830
|
+
try {
|
|
19831
|
+
const socketUrlObj = new URL(this.options.socketUrl);
|
|
19832
|
+
socketUrlObj.searchParams.set(constants.WHITELIST_KEY_LABEL, this.options.whitelistKey);
|
|
19833
|
+
url2Connect = socketUrlObj.toString();
|
|
19834
|
+
} catch (exc) {
|
|
19835
|
+
this.connecting = this.connected = false;
|
|
19836
|
+
const err = error_createError({
|
|
19837
|
+
message: "Invalid WebSocket URL",
|
|
19838
|
+
explanation: `The configured socketUrl "${this.options.socketUrl}" is not a valid URL. Please check your videomail-client configuration.`,
|
|
19839
|
+
options: this.options,
|
|
19840
|
+
exc
|
|
19841
|
+
});
|
|
19842
|
+
this.emit("ERROR", {
|
|
19843
|
+
err
|
|
19844
|
+
});
|
|
19845
|
+
return;
|
|
19846
|
+
}
|
|
19847
|
+
this.options.logger.debug(`Recorder: initializing web socket stream to ${url2Connect}`);
|
|
19848
|
+
let nativeSocket;
|
|
19849
|
+
try {
|
|
19850
|
+
nativeSocket = new WebSocket(url2Connect);
|
|
19851
|
+
nativeSocket.addEventListener("close", (event)=>{
|
|
19852
|
+
this.lastCloseEvent = {
|
|
19853
|
+
code: event.code,
|
|
19854
|
+
reason: event.reason,
|
|
19855
|
+
wasClean: event.wasClean
|
|
19856
|
+
};
|
|
19857
|
+
});
|
|
19858
|
+
nativeSocket.addEventListener("error", (event)=>{
|
|
19859
|
+
this.lastSocketError = error_getEventDetails(event);
|
|
19860
|
+
});
|
|
19861
|
+
} catch (exc) {
|
|
19862
|
+
this.connecting = this.connected = false;
|
|
19863
|
+
const diagnostic = error_getWebSocketDiagnostic(url2Connect);
|
|
19864
|
+
const message = diagnostic.looksAutomated ? "Automated crawler: WebSocket not supported in this environment" : `Failed to construct WebSocket to ${url2Connect}`;
|
|
19865
|
+
const explanation = diagnostic.looksAutomated ? "Headless crawlers cannot use Videomail's WebSocket. No action needed." : `Please check your connection and try again. If the problem persists, contact us. Diagnostic: ${diagnostic.text}`;
|
|
19866
|
+
const err = error_createError({
|
|
19867
|
+
message,
|
|
19868
|
+
explanation,
|
|
19869
|
+
options: this.options,
|
|
19870
|
+
exc
|
|
19871
|
+
});
|
|
19872
|
+
this.emit("ERROR", {
|
|
19873
|
+
err
|
|
19874
|
+
});
|
|
19875
|
+
return;
|
|
19876
|
+
}
|
|
19877
|
+
try {
|
|
19878
|
+
this.stream = stream_default()(nativeSocket);
|
|
19879
|
+
} catch (exc) {
|
|
19880
|
+
this.connecting = this.connected = false;
|
|
19881
|
+
const err = error_createError({
|
|
19882
|
+
message: `Failed to create a stream to ${url2Connect}`,
|
|
19883
|
+
explanation: "Please check your connection and try again. If the problem persists, contact us.",
|
|
19884
|
+
options: this.options,
|
|
19885
|
+
exc
|
|
19886
|
+
});
|
|
19887
|
+
this.emit("ERROR", {
|
|
19888
|
+
err
|
|
19889
|
+
});
|
|
19890
|
+
}
|
|
19891
|
+
if (this.stream) {
|
|
19892
|
+
const connectionTimeoutMs = this.options.timeouts.connection;
|
|
19893
|
+
this.connectionTimeout = window.setTimeout(()=>{
|
|
19894
|
+
if (this.isOnline() && this.isUserMediaLoaded()) {
|
|
19895
|
+
this.options.logger.debug(`${PIPE_SYMBOL}Reconnecting due to connection timeout.`);
|
|
19896
|
+
this.initSocket();
|
|
19897
|
+
} else this.failConnection({
|
|
19898
|
+
url2Connect,
|
|
19899
|
+
cause: "timeout"
|
|
19908
19900
|
});
|
|
19909
|
-
|
|
19910
|
-
|
|
19911
|
-
|
|
19912
|
-
this.
|
|
19913
|
-
|
|
19914
|
-
|
|
19915
|
-
|
|
19916
|
-
this.connecting = this.unloaded = false;
|
|
19917
|
-
this.emit("CONNECTED");
|
|
19918
|
-
null == cb || cb();
|
|
19919
|
-
}
|
|
19901
|
+
}, connectionTimeoutMs);
|
|
19902
|
+
this.stream.on("close", ()=>{
|
|
19903
|
+
const debugLine = util_summarize(`${PIPE_SYMBOL}Stream has closed:`, {
|
|
19904
|
+
connecting: this.connecting,
|
|
19905
|
+
connected: this.connected,
|
|
19906
|
+
userMediaLoaded: this.userMediaLoaded,
|
|
19907
|
+
blocking: this.blocking
|
|
19920
19908
|
});
|
|
19921
|
-
this.
|
|
19922
|
-
|
|
19923
|
-
|
|
19924
|
-
|
|
19925
|
-
|
|
19926
|
-
|
|
19927
|
-
this.options.logger.error(`Failed to parse command: ${exc}`);
|
|
19928
|
-
const err = error_createError({
|
|
19929
|
-
message: "Invalid server command",
|
|
19930
|
-
explanation: `Contact us. The invalid command was: ${data.toString()}.`,
|
|
19931
|
-
options: this.options,
|
|
19932
|
-
exc
|
|
19933
|
-
});
|
|
19934
|
-
this.emit("ERROR", {
|
|
19935
|
-
err
|
|
19936
|
-
});
|
|
19937
|
-
}
|
|
19938
|
-
});
|
|
19939
|
-
this.stream.on("error", (err)=>{
|
|
19940
|
-
var _this_lastSocketError;
|
|
19941
|
-
if ("u" > typeof Event && err instanceof Event) this.lastSocketError = error_getEventDetails(err);
|
|
19942
|
-
else this.lastSocketError = serializeError(err);
|
|
19943
|
-
const debugLine = util_summarize(`${PIPE_SYMBOL}Stream *error* event emitted:`, {
|
|
19944
|
-
error: serializeError(err)
|
|
19945
|
-
});
|
|
19946
|
-
this.options.logger.debug(debugLine);
|
|
19947
|
-
if (!this.connected) return void this.failConnection({
|
|
19909
|
+
this.options.logger.debug(debugLine);
|
|
19910
|
+
const tryReconnect = this.connected && this.userMediaLoaded;
|
|
19911
|
+
this.connected = false;
|
|
19912
|
+
if (tryReconnect) this.initSocket();
|
|
19913
|
+
else if (!this.connecting && !this.blocking) window.setTimeout(()=>{
|
|
19914
|
+
this.failConnection({
|
|
19948
19915
|
url2Connect,
|
|
19949
|
-
cause: "
|
|
19916
|
+
cause: "closed"
|
|
19950
19917
|
});
|
|
19951
|
-
|
|
19952
|
-
|
|
19918
|
+
}, 0);
|
|
19919
|
+
});
|
|
19920
|
+
this.stream.on("connect", (args)=>{
|
|
19921
|
+
var _this_stream;
|
|
19922
|
+
this.options.logger.debug(`${PIPE_SYMBOL}Stream *connect* event emitted with args: ${util_pretty(args)}`);
|
|
19923
|
+
this.clearConnectionTimeout();
|
|
19924
|
+
const isClosing = (null == (_this_stream = this.stream) ? void 0 : _this_stream.socket.readyState) === WebSocket.CLOSING;
|
|
19925
|
+
if (!this.connected && !isClosing && !this.unloaded) {
|
|
19926
|
+
this.connected = true;
|
|
19927
|
+
this.connecting = this.unloaded = false;
|
|
19928
|
+
this.emit("CONNECTED");
|
|
19929
|
+
null == cb || cb();
|
|
19930
|
+
}
|
|
19931
|
+
});
|
|
19932
|
+
this.stream.on("data", (data)=>{
|
|
19933
|
+
this.options.logger.debug(`${PIPE_SYMBOL}Stream *data* event emitted`);
|
|
19934
|
+
try {
|
|
19935
|
+
const command = JSON.parse(data.toString());
|
|
19936
|
+
this.executeCommand(command);
|
|
19937
|
+
} catch (exc) {
|
|
19938
|
+
this.options.logger.error(`Failed to parse command: ${exc}`);
|
|
19939
|
+
const err = error_createError({
|
|
19940
|
+
message: "Invalid server command",
|
|
19941
|
+
explanation: `Contact us. The invalid command was: ${data.toString()}.`,
|
|
19942
|
+
options: this.options,
|
|
19943
|
+
exc
|
|
19953
19944
|
});
|
|
19954
19945
|
this.emit("ERROR", {
|
|
19955
|
-
err
|
|
19956
|
-
message: "WebSocket stream error",
|
|
19957
|
-
explanation: `The WebSocket stream emitted an error event. Details: ${util_pretty(err)}`,
|
|
19958
|
-
options: this.options,
|
|
19959
|
-
exc: streamError
|
|
19960
|
-
})
|
|
19946
|
+
err
|
|
19961
19947
|
});
|
|
19948
|
+
}
|
|
19949
|
+
});
|
|
19950
|
+
this.stream.on("error", (err)=>{
|
|
19951
|
+
var _this_lastSocketError;
|
|
19952
|
+
if ("u" > typeof Event && err instanceof Event) this.lastSocketError = error_getEventDetails(err);
|
|
19953
|
+
else this.lastSocketError = serializeError(err);
|
|
19954
|
+
const debugLine = util_summarize(`${PIPE_SYMBOL}Stream *error* event emitted:`, {
|
|
19955
|
+
error: serializeError(err)
|
|
19962
19956
|
});
|
|
19963
|
-
this.
|
|
19964
|
-
|
|
19965
|
-
|
|
19966
|
-
|
|
19967
|
-
this.options.logger.debug(`${PIPE_SYMBOL}Stream *preend* event emitted with args: ${util_pretty(args)}`);
|
|
19968
|
-
});
|
|
19969
|
-
this.stream.on("end", ()=>{
|
|
19970
|
-
this.options.logger.debug(`${PIPE_SYMBOL}Stream *end* event emitted`);
|
|
19971
|
-
});
|
|
19972
|
-
this.stream.on("drain", (args)=>{
|
|
19973
|
-
this.options.logger.debug(`${PIPE_SYMBOL}Stream *drain* event emitted with args: ${util_pretty(args)}`);
|
|
19974
|
-
});
|
|
19975
|
-
this.stream.on("pipe", (src)=>{
|
|
19976
|
-
this.options.logger.debug(`${PIPE_SYMBOL}Stream *pipe* event emitted with src: ${util_pretty(src)}`);
|
|
19977
|
-
});
|
|
19978
|
-
this.stream.on("unpipe", (src)=>{
|
|
19979
|
-
this.options.logger.debug(`${PIPE_SYMBOL}Stream *unpipe* event emitted with src: ${util_pretty(src)}`);
|
|
19980
|
-
});
|
|
19981
|
-
this.stream.on("resume", (args)=>{
|
|
19982
|
-
this.options.logger.debug(`${PIPE_SYMBOL}Stream *resume* event emitted with args: ${util_pretty(args)}`);
|
|
19983
|
-
});
|
|
19984
|
-
this.stream.on("uncork", (args)=>{
|
|
19985
|
-
this.options.logger.debug(`${PIPE_SYMBOL}Stream *uncork* event emitted with args: ${util_pretty(args)}`);
|
|
19986
|
-
});
|
|
19987
|
-
this.stream.on("readable", (args)=>{
|
|
19988
|
-
this.options.logger.debug(`${PIPE_SYMBOL}Stream *readable* event emitted with args: ${util_pretty(args)}`);
|
|
19957
|
+
this.options.logger.debug(debugLine);
|
|
19958
|
+
if (!this.connected) return void this.failConnection({
|
|
19959
|
+
url2Connect,
|
|
19960
|
+
cause: "error"
|
|
19989
19961
|
});
|
|
19990
|
-
|
|
19991
|
-
|
|
19962
|
+
const streamError = err instanceof Error ? err : new Error("WebSocket stream emitted an error event", {
|
|
19963
|
+
cause: null != (_this_lastSocketError = this.lastSocketError) ? _this_lastSocketError : err
|
|
19992
19964
|
});
|
|
19993
|
-
this.
|
|
19994
|
-
|
|
19965
|
+
this.emit("ERROR", {
|
|
19966
|
+
err: error_createError({
|
|
19967
|
+
message: "WebSocket stream error",
|
|
19968
|
+
explanation: `The WebSocket stream emitted an error event. Details: ${util_pretty(err)}`,
|
|
19969
|
+
options: this.options,
|
|
19970
|
+
exc: streamError
|
|
19971
|
+
})
|
|
19995
19972
|
});
|
|
19996
|
-
}
|
|
19973
|
+
});
|
|
19974
|
+
this.stream.on("drain", ()=>{
|
|
19975
|
+
this.options.logger.debug(`${PIPE_SYMBOL}Stream *drain* event emitted (should not happen!)`);
|
|
19976
|
+
});
|
|
19977
|
+
this.stream.on("preend", (args)=>{
|
|
19978
|
+
this.options.logger.debug(`${PIPE_SYMBOL}Stream *preend* event emitted with args: ${util_pretty(args)}`);
|
|
19979
|
+
});
|
|
19980
|
+
this.stream.on("end", ()=>{
|
|
19981
|
+
this.options.logger.debug(`${PIPE_SYMBOL}Stream *end* event emitted`);
|
|
19982
|
+
});
|
|
19983
|
+
this.stream.on("drain", (args)=>{
|
|
19984
|
+
this.options.logger.debug(`${PIPE_SYMBOL}Stream *drain* event emitted with args: ${util_pretty(args)}`);
|
|
19985
|
+
});
|
|
19986
|
+
this.stream.on("pipe", (src)=>{
|
|
19987
|
+
this.options.logger.debug(`${PIPE_SYMBOL}Stream *pipe* event emitted with src: ${util_pretty(src)}`);
|
|
19988
|
+
});
|
|
19989
|
+
this.stream.on("unpipe", (src)=>{
|
|
19990
|
+
this.options.logger.debug(`${PIPE_SYMBOL}Stream *unpipe* event emitted with src: ${util_pretty(src)}`);
|
|
19991
|
+
});
|
|
19992
|
+
this.stream.on("resume", (args)=>{
|
|
19993
|
+
this.options.logger.debug(`${PIPE_SYMBOL}Stream *resume* event emitted with args: ${util_pretty(args)}`);
|
|
19994
|
+
});
|
|
19995
|
+
this.stream.on("uncork", (args)=>{
|
|
19996
|
+
this.options.logger.debug(`${PIPE_SYMBOL}Stream *uncork* event emitted with args: ${util_pretty(args)}`);
|
|
19997
|
+
});
|
|
19998
|
+
this.stream.on("readable", (args)=>{
|
|
19999
|
+
this.options.logger.debug(`${PIPE_SYMBOL}Stream *readable* event emitted with args: ${util_pretty(args)}`);
|
|
20000
|
+
});
|
|
20001
|
+
this.stream.on("prefinish", (args)=>{
|
|
20002
|
+
this.options.logger.debug(`${PIPE_SYMBOL}Stream *prefinish* event emitted with args: ${util_pretty(args)}`);
|
|
20003
|
+
});
|
|
20004
|
+
this.stream.on("finish", (args)=>{
|
|
20005
|
+
this.options.logger.debug(`${PIPE_SYMBOL}Stream *finish* event emitted with args: ${util_pretty(args)}`);
|
|
20006
|
+
});
|
|
19997
20007
|
}
|
|
19998
20008
|
}
|
|
19999
20009
|
showUserMedia() {
|