videomail-client 15.8.0 → 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 +246 -230
- package/dist/esm/index.js +228 -213
- package/dist/esm/{util/html/media → media}/canPlayType.d.ts +1 -1
- package/dist/esm/util/error/createError.d.ts +1 -0
- package/dist/esm/wrappers/visuals/recorder.d.ts +1 -0
- package/dist/umd/index.js +243 -228
- package/package.json +14 -14
- /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/esm/index.js
CHANGED
|
@@ -3620,7 +3620,7 @@ const constants = {
|
|
|
3620
3620
|
}
|
|
3621
3621
|
};
|
|
3622
3622
|
var package_namespaceObject = {
|
|
3623
|
-
rE: "15.8.
|
|
3623
|
+
rE: "15.8.2"
|
|
3624
3624
|
};
|
|
3625
3625
|
function isAudioEnabled(options) {
|
|
3626
3626
|
return Boolean(options.audio.enabled);
|
|
@@ -3991,6 +3991,7 @@ function createError(errorParams) {
|
|
|
3991
3991
|
].filter(Boolean).join(", ");
|
|
3992
3992
|
options.logger.debug(`VideomailError: create(${args})`);
|
|
3993
3993
|
const errData = {
|
|
3994
|
+
cause: errorParams.cause,
|
|
3994
3995
|
explanation,
|
|
3995
3996
|
logLines,
|
|
3996
3997
|
err
|
|
@@ -4118,12 +4119,12 @@ function showElement(element) {
|
|
|
4118
4119
|
element.style.removeProperty("display");
|
|
4119
4120
|
}
|
|
4120
4121
|
const html_showElement = showElement;
|
|
4121
|
-
const
|
|
4122
|
+
const EMAIL_SEPARATOR_REGEX = /[ ,]+/gu;
|
|
4122
4123
|
function trimEmail(email) {
|
|
4123
|
-
return email.replace(
|
|
4124
|
+
return email.replace(EMAIL_SEPARATOR_REGEX, "");
|
|
4124
4125
|
}
|
|
4125
4126
|
function trimEmails(emails) {
|
|
4126
|
-
const trimmedEmails = emails.split(
|
|
4127
|
+
const trimmedEmails = emails.split(EMAIL_SEPARATOR_REGEX).map((item)=>item.trim()).filter(Boolean);
|
|
4127
4128
|
return trimmedEmails;
|
|
4128
4129
|
}
|
|
4129
4130
|
function form_define_property(obj, key, value) {
|
|
@@ -4499,6 +4500,7 @@ class Resource {
|
|
|
4499
4500
|
browser: err.browser,
|
|
4500
4501
|
code: err.code,
|
|
4501
4502
|
cookie: err.cookie,
|
|
4503
|
+
cause: err.cause instanceof Error ? serializeError(err.cause) : err.cause,
|
|
4502
4504
|
cpu: err.cpu,
|
|
4503
4505
|
device: err.device,
|
|
4504
4506
|
engine: err.engine,
|
|
@@ -6158,6 +6160,34 @@ function summarize(title, contents) {
|
|
|
6158
6160
|
return line;
|
|
6159
6161
|
}
|
|
6160
6162
|
const util_summarize = summarize;
|
|
6163
|
+
function getFirstVideoTrack(localMediaStream) {
|
|
6164
|
+
const videoTracks = localMediaStream.getVideoTracks();
|
|
6165
|
+
let videoTrack;
|
|
6166
|
+
if (videoTracks[0]) videoTrack = videoTracks[0];
|
|
6167
|
+
return videoTrack;
|
|
6168
|
+
}
|
|
6169
|
+
const media_getFirstVideoTrack = getFirstVideoTrack;
|
|
6170
|
+
const MEDIA_EVENTS = [
|
|
6171
|
+
"loadstart",
|
|
6172
|
+
"suspend",
|
|
6173
|
+
"progress",
|
|
6174
|
+
"abort",
|
|
6175
|
+
"emptied",
|
|
6176
|
+
"stalled",
|
|
6177
|
+
"pause",
|
|
6178
|
+
"loadeddata",
|
|
6179
|
+
"waiting",
|
|
6180
|
+
"playing",
|
|
6181
|
+
"canplay",
|
|
6182
|
+
"canplaythrough",
|
|
6183
|
+
"seeking",
|
|
6184
|
+
"seeked",
|
|
6185
|
+
"ended",
|
|
6186
|
+
"ratechange",
|
|
6187
|
+
"durationchange",
|
|
6188
|
+
"volumechange"
|
|
6189
|
+
];
|
|
6190
|
+
const mediaEvents = MEDIA_EVENTS;
|
|
6161
6191
|
function AudioRecorder_define_property(obj, key, value) {
|
|
6162
6192
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
6163
6193
|
value: value,
|
|
@@ -6203,11 +6233,11 @@ class AudioRecorder {
|
|
|
6203
6233
|
let { bufferSize } = this.options.audio;
|
|
6204
6234
|
if ("auto" === bufferSize) bufferSize = util_getBrowser(this.options).isFirefox() ? 512 : 2048;
|
|
6205
6235
|
if (!is_power_of_two(bufferSize)) throw error_createError({
|
|
6206
|
-
message:
|
|
6236
|
+
message: `Audio buffer size must be a power of two. The current buffer size is ${bufferSize}.`,
|
|
6207
6237
|
options: this.options
|
|
6208
6238
|
});
|
|
6209
|
-
if (this.options.audio.volume < 0 || this.options.audio.volume > 1) throw error_createError({
|
|
6210
|
-
message:
|
|
6239
|
+
if (!Number.isFinite(this.options.audio.volume) || this.options.audio.volume < 0 || this.options.audio.volume > 1) throw error_createError({
|
|
6240
|
+
message: `Audio volume must be between zero and one. The current volume is ${this.options.audio.volume}.`,
|
|
6211
6241
|
options: this.options
|
|
6212
6242
|
});
|
|
6213
6243
|
volume.gain.value = this.options.audio.volume;
|
|
@@ -6253,34 +6283,6 @@ class AudioRecorder {
|
|
|
6253
6283
|
}
|
|
6254
6284
|
}
|
|
6255
6285
|
const media_AudioRecorder = AudioRecorder;
|
|
6256
|
-
function getFirstVideoTrack(localMediaStream) {
|
|
6257
|
-
const videoTracks = localMediaStream.getVideoTracks();
|
|
6258
|
-
let videoTrack;
|
|
6259
|
-
if (videoTracks[0]) videoTrack = videoTracks[0];
|
|
6260
|
-
return videoTrack;
|
|
6261
|
-
}
|
|
6262
|
-
const media_getFirstVideoTrack = getFirstVideoTrack;
|
|
6263
|
-
const MEDIA_EVENTS = [
|
|
6264
|
-
"loadstart",
|
|
6265
|
-
"suspend",
|
|
6266
|
-
"progress",
|
|
6267
|
-
"abort",
|
|
6268
|
-
"emptied",
|
|
6269
|
-
"stalled",
|
|
6270
|
-
"pause",
|
|
6271
|
-
"loadeddata",
|
|
6272
|
-
"waiting",
|
|
6273
|
-
"playing",
|
|
6274
|
-
"canplay",
|
|
6275
|
-
"canplaythrough",
|
|
6276
|
-
"seeking",
|
|
6277
|
-
"seeked",
|
|
6278
|
-
"ended",
|
|
6279
|
-
"ratechange",
|
|
6280
|
-
"durationchange",
|
|
6281
|
-
"volumechange"
|
|
6282
|
-
];
|
|
6283
|
-
const mediaEvents = MEDIA_EVENTS;
|
|
6284
6286
|
const VIRTUAL_KEYWORDS = [
|
|
6285
6287
|
"obs",
|
|
6286
6288
|
"virtual",
|
|
@@ -6684,6 +6686,7 @@ class Recorder extends util_Despot {
|
|
|
6684
6686
|
const switchingFacingMode = params?.switchingFacingMode;
|
|
6685
6687
|
this.userMediaLoading = this.blocking = this.unloaded = this.submitting = false;
|
|
6686
6688
|
this.userMediaLoaded = true;
|
|
6689
|
+
this.clearUserMediaTimeout();
|
|
6687
6690
|
if (!switchingFacingMode) this.loop = this.createLoop();
|
|
6688
6691
|
this.show();
|
|
6689
6692
|
if (params?.recordWhenReady) this.record();
|
|
@@ -6710,13 +6713,16 @@ class Recorder extends util_Despot {
|
|
|
6710
6713
|
window.clearTimeout(this.connectionTimeout);
|
|
6711
6714
|
this.connectionTimeout = void 0;
|
|
6712
6715
|
}
|
|
6716
|
+
isOnline() {
|
|
6717
|
+
return navigator.onLine;
|
|
6718
|
+
}
|
|
6713
6719
|
failConnection(params) {
|
|
6714
6720
|
if (this.connectionFailed || this.connected || this.unloaded) return;
|
|
6715
6721
|
this.connectionFailed = true;
|
|
6716
6722
|
this.connecting = false;
|
|
6717
6723
|
this.clearConnectionTimeout();
|
|
6718
6724
|
const { url2Connect, cause } = params;
|
|
6719
|
-
const online =
|
|
6725
|
+
const online = this.isOnline();
|
|
6720
6726
|
const elapsedMs = this.connectingStartedAt ? Date.now() - this.connectingStartedAt : void 0;
|
|
6721
6727
|
const closeEvent = this.lastCloseEvent;
|
|
6722
6728
|
const socketError = this.lastSocketError;
|
|
@@ -6726,12 +6732,17 @@ class Recorder extends util_Despot {
|
|
|
6726
6732
|
closeReason: closeEvent?.reason,
|
|
6727
6733
|
elapsedMs,
|
|
6728
6734
|
online,
|
|
6735
|
+
secureContext: globalThis.isSecureContext,
|
|
6736
|
+
socketReadyState: this.stream?.socket.readyState,
|
|
6737
|
+
timeoutMs: this.options.timeouts.connection,
|
|
6738
|
+
url: url2Connect,
|
|
6729
6739
|
unloaded: this.unloaded,
|
|
6730
6740
|
userMediaLoaded: this.userMediaLoaded,
|
|
6731
6741
|
userMediaLoading: this.userMediaLoading,
|
|
6732
6742
|
wasClean: closeEvent?.wasClean,
|
|
6733
6743
|
socketError,
|
|
6734
|
-
blocking: this.blocking
|
|
6744
|
+
blocking: this.blocking,
|
|
6745
|
+
visibilityState: document.visibilityState
|
|
6735
6746
|
};
|
|
6736
6747
|
const debugLine = util_summarize("Recorder: failConnection() diagnostic", contents);
|
|
6737
6748
|
this.options.logger.debug(debugLine);
|
|
@@ -6751,6 +6762,7 @@ class Recorder extends util_Despot {
|
|
|
6751
6762
|
message: "Unable to connect to the server",
|
|
6752
6763
|
explanation,
|
|
6753
6764
|
options: this.options,
|
|
6765
|
+
cause: contents,
|
|
6754
6766
|
exc: socketError ? new Error("WebSocket connection error", {
|
|
6755
6767
|
cause: socketError
|
|
6756
6768
|
}) : void 0
|
|
@@ -6828,192 +6840,195 @@ class Recorder extends util_Despot {
|
|
|
6828
6840
|
this.recordingStats.waitingTime = this.waitingTime;
|
|
6829
6841
|
}
|
|
6830
6842
|
initSocket(cb) {
|
|
6831
|
-
if (
|
|
6832
|
-
|
|
6833
|
-
|
|
6834
|
-
|
|
6835
|
-
|
|
6836
|
-
|
|
6837
|
-
|
|
6838
|
-
|
|
6839
|
-
|
|
6840
|
-
|
|
6841
|
-
|
|
6842
|
-
|
|
6843
|
-
|
|
6844
|
-
|
|
6845
|
-
|
|
6846
|
-
|
|
6847
|
-
|
|
6848
|
-
|
|
6849
|
-
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
}
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
}
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
|
|
6884
|
-
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
|
|
6890
|
-
|
|
6891
|
-
|
|
6892
|
-
|
|
6893
|
-
|
|
6894
|
-
|
|
6895
|
-
|
|
6896
|
-
|
|
6897
|
-
|
|
6898
|
-
|
|
6899
|
-
|
|
6843
|
+
if (this.connected) return void cb?.();
|
|
6844
|
+
if (this.connecting) return;
|
|
6845
|
+
if (util_isAutomatedUserAgent()) {
|
|
6846
|
+
this.connecting = false;
|
|
6847
|
+
this.options.logger.debug("Recorder: skipping web socket connection for an automated crawler");
|
|
6848
|
+
return;
|
|
6849
|
+
}
|
|
6850
|
+
this.connecting = true;
|
|
6851
|
+
this.connectionFailed = false;
|
|
6852
|
+
this.connectingStartedAt = Date.now();
|
|
6853
|
+
this.lastCloseEvent = void 0;
|
|
6854
|
+
this.lastSocketError = void 0;
|
|
6855
|
+
this.emit("CONNECTING");
|
|
6856
|
+
let url2Connect;
|
|
6857
|
+
try {
|
|
6858
|
+
const socketUrlObj = new URL(this.options.socketUrl);
|
|
6859
|
+
socketUrlObj.searchParams.set(constants.WHITELIST_KEY_LABEL, this.options.whitelistKey);
|
|
6860
|
+
url2Connect = socketUrlObj.toString();
|
|
6861
|
+
} catch (exc) {
|
|
6862
|
+
this.connecting = this.connected = false;
|
|
6863
|
+
const err = error_createError({
|
|
6864
|
+
message: "Invalid WebSocket URL",
|
|
6865
|
+
explanation: `The configured socketUrl "${this.options.socketUrl}" is not a valid URL. Please check your videomail-client configuration.`,
|
|
6866
|
+
options: this.options,
|
|
6867
|
+
exc
|
|
6868
|
+
});
|
|
6869
|
+
this.emit("ERROR", {
|
|
6870
|
+
err
|
|
6871
|
+
});
|
|
6872
|
+
return;
|
|
6873
|
+
}
|
|
6874
|
+
this.options.logger.debug(`Recorder: initializing web socket stream to ${url2Connect}`);
|
|
6875
|
+
let nativeSocket;
|
|
6876
|
+
try {
|
|
6877
|
+
nativeSocket = new WebSocket(url2Connect);
|
|
6878
|
+
nativeSocket.addEventListener("close", (event)=>{
|
|
6879
|
+
this.lastCloseEvent = {
|
|
6880
|
+
code: event.code,
|
|
6881
|
+
reason: event.reason,
|
|
6882
|
+
wasClean: event.wasClean
|
|
6883
|
+
};
|
|
6884
|
+
});
|
|
6885
|
+
nativeSocket.addEventListener("error", (event)=>{
|
|
6886
|
+
this.lastSocketError = error_getEventDetails(event);
|
|
6887
|
+
});
|
|
6888
|
+
} catch (exc) {
|
|
6889
|
+
this.connecting = this.connected = false;
|
|
6890
|
+
const diagnostic = error_getWebSocketDiagnostic(url2Connect);
|
|
6891
|
+
const message = diagnostic.looksAutomated ? "Automated crawler: WebSocket not supported in this environment" : `Failed to construct WebSocket to ${url2Connect}`;
|
|
6892
|
+
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}`;
|
|
6893
|
+
const err = error_createError({
|
|
6894
|
+
message,
|
|
6895
|
+
explanation,
|
|
6896
|
+
options: this.options,
|
|
6897
|
+
exc
|
|
6898
|
+
});
|
|
6899
|
+
this.emit("ERROR", {
|
|
6900
|
+
err
|
|
6901
|
+
});
|
|
6902
|
+
return;
|
|
6903
|
+
}
|
|
6904
|
+
try {
|
|
6905
|
+
this.stream = websocket_stream(nativeSocket);
|
|
6906
|
+
} catch (exc) {
|
|
6907
|
+
this.connecting = this.connected = false;
|
|
6908
|
+
const err = error_createError({
|
|
6909
|
+
message: `Failed to create a stream to ${url2Connect}`,
|
|
6910
|
+
explanation: "Please check your connection and try again. If the problem persists, contact us.",
|
|
6911
|
+
options: this.options,
|
|
6912
|
+
exc
|
|
6913
|
+
});
|
|
6914
|
+
this.emit("ERROR", {
|
|
6915
|
+
err
|
|
6916
|
+
});
|
|
6917
|
+
}
|
|
6918
|
+
if (this.stream) {
|
|
6919
|
+
const connectionTimeoutMs = this.options.timeouts.connection;
|
|
6920
|
+
this.connectionTimeout = window.setTimeout(()=>{
|
|
6921
|
+
if (this.isOnline() && this.isUserMediaLoaded()) {
|
|
6922
|
+
this.options.logger.debug(`${PIPE_SYMBOL}Reconnecting due to connection timeout.`);
|
|
6923
|
+
this.initSocket();
|
|
6924
|
+
} else this.failConnection({
|
|
6925
|
+
url2Connect,
|
|
6926
|
+
cause: "timeout"
|
|
6900
6927
|
});
|
|
6901
|
-
|
|
6902
|
-
|
|
6928
|
+
}, connectionTimeoutMs);
|
|
6929
|
+
this.stream.on("close", ()=>{
|
|
6930
|
+
const debugLine = util_summarize(`${PIPE_SYMBOL}Stream has closed:`, {
|
|
6931
|
+
connecting: this.connecting,
|
|
6932
|
+
connected: this.connected,
|
|
6933
|
+
userMediaLoaded: this.userMediaLoaded,
|
|
6934
|
+
blocking: this.blocking
|
|
6903
6935
|
});
|
|
6904
|
-
|
|
6905
|
-
|
|
6906
|
-
|
|
6907
|
-
|
|
6936
|
+
this.options.logger.debug(debugLine);
|
|
6937
|
+
const tryReconnect = this.connected && this.userMediaLoaded;
|
|
6938
|
+
this.connected = false;
|
|
6939
|
+
if (tryReconnect) this.initSocket();
|
|
6940
|
+
else if (!this.connecting && !this.blocking) window.setTimeout(()=>{
|
|
6908
6941
|
this.failConnection({
|
|
6909
6942
|
url2Connect,
|
|
6910
|
-
cause: "
|
|
6943
|
+
cause: "closed"
|
|
6911
6944
|
});
|
|
6912
|
-
},
|
|
6913
|
-
|
|
6914
|
-
|
|
6915
|
-
|
|
6916
|
-
|
|
6917
|
-
|
|
6918
|
-
|
|
6919
|
-
|
|
6920
|
-
this.
|
|
6921
|
-
|
|
6922
|
-
|
|
6923
|
-
|
|
6924
|
-
|
|
6925
|
-
|
|
6926
|
-
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
6930
|
-
})
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
|
|
6934
|
-
|
|
6935
|
-
|
|
6936
|
-
|
|
6937
|
-
this.connecting = this.unloaded = false;
|
|
6938
|
-
this.emit("CONNECTED");
|
|
6939
|
-
cb?.();
|
|
6940
|
-
}
|
|
6941
|
-
});
|
|
6942
|
-
this.stream.on("data", (data)=>{
|
|
6943
|
-
this.options.logger.debug(`${PIPE_SYMBOL}Stream *data* event emitted`);
|
|
6944
|
-
try {
|
|
6945
|
-
const command = JSON.parse(data.toString());
|
|
6946
|
-
this.executeCommand(command);
|
|
6947
|
-
} catch (exc) {
|
|
6948
|
-
this.options.logger.error(`Failed to parse command: ${exc}`);
|
|
6949
|
-
const err = error_createError({
|
|
6950
|
-
message: "Invalid server command",
|
|
6951
|
-
explanation: `Contact us. The invalid command was: ${data.toString()}.`,
|
|
6952
|
-
options: this.options,
|
|
6953
|
-
exc
|
|
6954
|
-
});
|
|
6955
|
-
this.emit("ERROR", {
|
|
6956
|
-
err
|
|
6957
|
-
});
|
|
6958
|
-
}
|
|
6959
|
-
});
|
|
6960
|
-
this.stream.on("error", (err)=>{
|
|
6961
|
-
if ("u" > typeof Event && err instanceof Event) this.lastSocketError = error_getEventDetails(err);
|
|
6962
|
-
else this.lastSocketError = serializeError(err);
|
|
6963
|
-
const debugLine = util_summarize(`${PIPE_SYMBOL}Stream *error* event emitted:`, {
|
|
6964
|
-
error: serializeError(err)
|
|
6965
|
-
});
|
|
6966
|
-
this.options.logger.debug(debugLine);
|
|
6967
|
-
if (!this.connected) return void this.failConnection({
|
|
6968
|
-
url2Connect,
|
|
6969
|
-
cause: "error"
|
|
6970
|
-
});
|
|
6971
|
-
const streamError = err instanceof Error ? err : new Error("WebSocket stream emitted an error event", {
|
|
6972
|
-
cause: this.lastSocketError ?? err
|
|
6945
|
+
}, 0);
|
|
6946
|
+
});
|
|
6947
|
+
this.stream.on("connect", (args)=>{
|
|
6948
|
+
this.options.logger.debug(`${PIPE_SYMBOL}Stream *connect* event emitted with args: ${util_pretty(args)}`);
|
|
6949
|
+
this.clearConnectionTimeout();
|
|
6950
|
+
const isClosing = this.stream?.socket.readyState === WebSocket.CLOSING;
|
|
6951
|
+
if (!this.connected && !isClosing && !this.unloaded) {
|
|
6952
|
+
this.connected = true;
|
|
6953
|
+
this.connecting = this.unloaded = false;
|
|
6954
|
+
this.emit("CONNECTED");
|
|
6955
|
+
cb?.();
|
|
6956
|
+
}
|
|
6957
|
+
});
|
|
6958
|
+
this.stream.on("data", (data)=>{
|
|
6959
|
+
this.options.logger.debug(`${PIPE_SYMBOL}Stream *data* event emitted`);
|
|
6960
|
+
try {
|
|
6961
|
+
const command = JSON.parse(data.toString());
|
|
6962
|
+
this.executeCommand(command);
|
|
6963
|
+
} catch (exc) {
|
|
6964
|
+
this.options.logger.error(`Failed to parse command: ${exc}`);
|
|
6965
|
+
const err = error_createError({
|
|
6966
|
+
message: "Invalid server command",
|
|
6967
|
+
explanation: `Contact us. The invalid command was: ${data.toString()}.`,
|
|
6968
|
+
options: this.options,
|
|
6969
|
+
exc
|
|
6973
6970
|
});
|
|
6974
6971
|
this.emit("ERROR", {
|
|
6975
|
-
err
|
|
6976
|
-
message: "WebSocket stream error",
|
|
6977
|
-
explanation: `The WebSocket stream emitted an error event. Details: ${util_pretty(err)}`,
|
|
6978
|
-
options: this.options,
|
|
6979
|
-
exc: streamError
|
|
6980
|
-
})
|
|
6972
|
+
err
|
|
6981
6973
|
});
|
|
6974
|
+
}
|
|
6975
|
+
});
|
|
6976
|
+
this.stream.on("error", (err)=>{
|
|
6977
|
+
if ("u" > typeof Event && err instanceof Event) this.lastSocketError = error_getEventDetails(err);
|
|
6978
|
+
else this.lastSocketError = serializeError(err);
|
|
6979
|
+
const debugLine = util_summarize(`${PIPE_SYMBOL}Stream *error* event emitted:`, {
|
|
6980
|
+
error: serializeError(err)
|
|
6982
6981
|
});
|
|
6983
|
-
this.
|
|
6984
|
-
|
|
6985
|
-
|
|
6986
|
-
|
|
6987
|
-
this.options.logger.debug(`${PIPE_SYMBOL}Stream *preend* event emitted with args: ${util_pretty(args)}`);
|
|
6988
|
-
});
|
|
6989
|
-
this.stream.on("end", ()=>{
|
|
6990
|
-
this.options.logger.debug(`${PIPE_SYMBOL}Stream *end* event emitted`);
|
|
6991
|
-
});
|
|
6992
|
-
this.stream.on("drain", (args)=>{
|
|
6993
|
-
this.options.logger.debug(`${PIPE_SYMBOL}Stream *drain* event emitted with args: ${util_pretty(args)}`);
|
|
6994
|
-
});
|
|
6995
|
-
this.stream.on("pipe", (src)=>{
|
|
6996
|
-
this.options.logger.debug(`${PIPE_SYMBOL}Stream *pipe* event emitted with src: ${util_pretty(src)}`);
|
|
6997
|
-
});
|
|
6998
|
-
this.stream.on("unpipe", (src)=>{
|
|
6999
|
-
this.options.logger.debug(`${PIPE_SYMBOL}Stream *unpipe* event emitted with src: ${util_pretty(src)}`);
|
|
7000
|
-
});
|
|
7001
|
-
this.stream.on("resume", (args)=>{
|
|
7002
|
-
this.options.logger.debug(`${PIPE_SYMBOL}Stream *resume* event emitted with args: ${util_pretty(args)}`);
|
|
7003
|
-
});
|
|
7004
|
-
this.stream.on("uncork", (args)=>{
|
|
7005
|
-
this.options.logger.debug(`${PIPE_SYMBOL}Stream *uncork* event emitted with args: ${util_pretty(args)}`);
|
|
7006
|
-
});
|
|
7007
|
-
this.stream.on("readable", (args)=>{
|
|
7008
|
-
this.options.logger.debug(`${PIPE_SYMBOL}Stream *readable* event emitted with args: ${util_pretty(args)}`);
|
|
6982
|
+
this.options.logger.debug(debugLine);
|
|
6983
|
+
if (!this.connected) return void this.failConnection({
|
|
6984
|
+
url2Connect,
|
|
6985
|
+
cause: "error"
|
|
7009
6986
|
});
|
|
7010
|
-
|
|
7011
|
-
this.
|
|
6987
|
+
const streamError = err instanceof Error ? err : new Error("WebSocket stream emitted an error event", {
|
|
6988
|
+
cause: this.lastSocketError ?? err
|
|
7012
6989
|
});
|
|
7013
|
-
this.
|
|
7014
|
-
|
|
6990
|
+
this.emit("ERROR", {
|
|
6991
|
+
err: error_createError({
|
|
6992
|
+
message: "WebSocket stream error",
|
|
6993
|
+
explanation: `The WebSocket stream emitted an error event. Details: ${util_pretty(err)}`,
|
|
6994
|
+
options: this.options,
|
|
6995
|
+
exc: streamError
|
|
6996
|
+
})
|
|
7015
6997
|
});
|
|
7016
|
-
}
|
|
6998
|
+
});
|
|
6999
|
+
this.stream.on("drain", ()=>{
|
|
7000
|
+
this.options.logger.debug(`${PIPE_SYMBOL}Stream *drain* event emitted (should not happen!)`);
|
|
7001
|
+
});
|
|
7002
|
+
this.stream.on("preend", (args)=>{
|
|
7003
|
+
this.options.logger.debug(`${PIPE_SYMBOL}Stream *preend* event emitted with args: ${util_pretty(args)}`);
|
|
7004
|
+
});
|
|
7005
|
+
this.stream.on("end", ()=>{
|
|
7006
|
+
this.options.logger.debug(`${PIPE_SYMBOL}Stream *end* event emitted`);
|
|
7007
|
+
});
|
|
7008
|
+
this.stream.on("drain", (args)=>{
|
|
7009
|
+
this.options.logger.debug(`${PIPE_SYMBOL}Stream *drain* event emitted with args: ${util_pretty(args)}`);
|
|
7010
|
+
});
|
|
7011
|
+
this.stream.on("pipe", (src)=>{
|
|
7012
|
+
this.options.logger.debug(`${PIPE_SYMBOL}Stream *pipe* event emitted with src: ${util_pretty(src)}`);
|
|
7013
|
+
});
|
|
7014
|
+
this.stream.on("unpipe", (src)=>{
|
|
7015
|
+
this.options.logger.debug(`${PIPE_SYMBOL}Stream *unpipe* event emitted with src: ${util_pretty(src)}`);
|
|
7016
|
+
});
|
|
7017
|
+
this.stream.on("resume", (args)=>{
|
|
7018
|
+
this.options.logger.debug(`${PIPE_SYMBOL}Stream *resume* event emitted with args: ${util_pretty(args)}`);
|
|
7019
|
+
});
|
|
7020
|
+
this.stream.on("uncork", (args)=>{
|
|
7021
|
+
this.options.logger.debug(`${PIPE_SYMBOL}Stream *uncork* event emitted with args: ${util_pretty(args)}`);
|
|
7022
|
+
});
|
|
7023
|
+
this.stream.on("readable", (args)=>{
|
|
7024
|
+
this.options.logger.debug(`${PIPE_SYMBOL}Stream *readable* event emitted with args: ${util_pretty(args)}`);
|
|
7025
|
+
});
|
|
7026
|
+
this.stream.on("prefinish", (args)=>{
|
|
7027
|
+
this.options.logger.debug(`${PIPE_SYMBOL}Stream *prefinish* event emitted with args: ${util_pretty(args)}`);
|
|
7028
|
+
});
|
|
7029
|
+
this.stream.on("finish", (args)=>{
|
|
7030
|
+
this.options.logger.debug(`${PIPE_SYMBOL}Stream *finish* event emitted with args: ${util_pretty(args)}`);
|
|
7031
|
+
});
|
|
7017
7032
|
}
|
|
7018
7033
|
}
|
|
7019
7034
|
showUserMedia() {
|
|
@@ -7103,8 +7118,8 @@ class Recorder extends util_Despot {
|
|
|
7103
7118
|
ideal: idealHeight
|
|
7104
7119
|
};
|
|
7105
7120
|
}
|
|
7106
|
-
this.options.logger.debug(
|
|
7107
|
-
this.options.logger.debug(
|
|
7121
|
+
this.options.logger.debug(util_summarize("Recorder: our webcam constraints are:", constraints));
|
|
7122
|
+
this.options.logger.debug(util_summarize("Recorder: available webcam constraints are:", navigator.mediaDevices.getSupportedConstraints()));
|
|
7108
7123
|
const streamPromise = navigator.mediaDevices.getUserMedia(constraints);
|
|
7109
7124
|
streamPromise.then((localStream)=>{
|
|
7110
7125
|
this.getUserMediaCallback(localStream, params);
|
|
@@ -2,6 +2,7 @@ import { VideomailClientOptions } from "../../types/options.js";
|
|
|
2
2
|
import HTTPVideomailError from "./HTTPVideomailError.js";
|
|
3
3
|
import VideomailError from "./VideomailError.js";
|
|
4
4
|
interface ErrorParams {
|
|
5
|
+
cause?: unknown;
|
|
5
6
|
err?: HTTPVideomailError;
|
|
6
7
|
exc?: unknown;
|
|
7
8
|
message?: string;
|