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/umd/index.js CHANGED
@@ -429,7 +429,7 @@
429
429
  return parts.join('');
430
430
  }
431
431
  },
432
- dY (__unused_rspack_module, exports1, __webpack_require__) {
432
+ dY2 (__unused_rspack_module, exports1, __webpack_require__) {
433
433
  "use strict";
434
434
  /*!
435
435
  * The buffer module from node.js, for the browser.
@@ -1712,7 +1712,7 @@
1712
1712
  return null === arg || 'boolean' == typeof arg || 'number' == typeof arg || 'string' == typeof arg || 'symbol' == typeof arg || void 0 === arg;
1713
1713
  }
1714
1714
  exports1.isPrimitive = isPrimitive;
1715
- exports1.isBuffer = __webpack_require__("dY").Buffer.isBuffer;
1715
+ exports1.isBuffer = __webpack_require__("dY2").Buffer.isBuffer;
1716
1716
  function objectToString(o) {
1717
1717
  return Object.prototype.toString.call(o);
1718
1718
  }
@@ -1908,7 +1908,7 @@
1908
1908
  } : false;
1909
1909
  },
1910
1910
  Y4 (module1, __unused_rspack_exports, __webpack_require__) {
1911
- var Buffer = __webpack_require__("dY").Buffer;
1911
+ var Buffer = __webpack_require__("dY2").Buffer;
1912
1912
  var process = __webpack_require__("zT");
1913
1913
  var stream = __webpack_require__("GB");
1914
1914
  var eos = __webpack_require__("Qd");
@@ -3468,7 +3468,7 @@
3468
3468
  exports1.PassThrough = __webpack_require__("P");
3469
3469
  },
3470
3470
  Uf (module1, exports1, __webpack_require__) {
3471
- var buffer = __webpack_require__("dY");
3471
+ var buffer = __webpack_require__("dY2");
3472
3472
  var Buffer = buffer.Buffer;
3473
3473
  function copyProps(src, dst) {
3474
3474
  for(var key in src)dst[key] = src[key];
@@ -4766,7 +4766,7 @@
4766
4766
  ]
4767
4767
  };
4768
4768
  var bind = __webpack_require__("zO");
4769
- var hasOwn = __webpack_require__("Zw");
4769
+ var hasOwn = __webpack_require__("Z");
4770
4770
  var $concat = bind.call($call, Array.prototype.concat);
4771
4771
  var $spliceApply = bind.call($apply, Array.prototype.splice);
4772
4772
  var $replace = bind.call($call, String.prototype.replace);
@@ -4991,7 +4991,7 @@
4991
4991
  return hasSymbols() && !!Symbol.toStringTag;
4992
4992
  };
4993
4993
  },
4994
- Zw (module1, __unused_rspack_exports, __webpack_require__) {
4994
+ Z (module1, __unused_rspack_exports, __webpack_require__) {
4995
4995
  "use strict";
4996
4996
  var call = Function.prototype.call;
4997
4997
  var $hasOwn = Object.prototype.hasOwnProperty;
@@ -5226,7 +5226,7 @@
5226
5226
  "use strict";
5227
5227
  var callBound = __webpack_require__("F");
5228
5228
  var hasToStringTag = __webpack_require__("bT")();
5229
- var hasOwn = __webpack_require__("Zw");
5229
+ var hasOwn = __webpack_require__("Z");
5230
5230
  var gOPD = __webpack_require__("D");
5231
5231
  var fn;
5232
5232
  if (hasToStringTag) {
@@ -7050,7 +7050,7 @@
7050
7050
  const Emitter = __webpack_require__("r");
7051
7051
  const safeStringify = __webpack_require__("X");
7052
7052
  const qs = __webpack_require__("b");
7053
- const RequestBase = __webpack_require__("d");
7053
+ const RequestBase = __webpack_require__("dY");
7054
7054
  const { isObject, mixin, hasOwn, isSafeKey } = __webpack_require__("Dp");
7055
7055
  const ResponseBase = __webpack_require__("e");
7056
7056
  const Agent = __webpack_require__("pf");
@@ -7465,7 +7465,7 @@
7465
7465
  return request_;
7466
7466
  };
7467
7467
  },
7468
- d (module1, __unused_rspack_exports, __webpack_require__) {
7468
+ dY (module1, __unused_rspack_exports, __webpack_require__) {
7469
7469
  "use strict";
7470
7470
  const { isObject, hasOwn, isSafeKey } = __webpack_require__("Dp");
7471
7471
  module1.exports = RequestBase;
@@ -7868,7 +7868,7 @@
7868
7868
  exports1.isBrotliEncoding = (res)=>/^\s*br\s*$/i.test(res.headers['content-encoding']);
7869
7869
  },
7870
7870
  E (module1, __unused_rspack_exports, __webpack_require__) {
7871
- var Buffer = __webpack_require__("dY").Buffer;
7871
+ var Buffer = __webpack_require__("dY2").Buffer;
7872
7872
  /*! typedarray-to-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */ module1.exports = function(arr) {
7873
7873
  return ArrayBuffer.isView(arr) ? Buffer.from(arr.buffer, arr.byteOffset, arr.byteLength) : Buffer.from(arr);
7874
7874
  };
@@ -8734,7 +8734,7 @@
8734
8734
  this.decoder = null;
8735
8735
  this.encoding = null;
8736
8736
  if (options.encoding) {
8737
- if (!StringDecoder) StringDecoder = __webpack_require__("Zwc").I;
8737
+ if (!StringDecoder) StringDecoder = __webpack_require__("Zw").I;
8738
8738
  this.decoder = new StringDecoder(options.encoding);
8739
8739
  this.encoding = options.encoding;
8740
8740
  }
@@ -8833,7 +8833,7 @@
8833
8833
  return false === this._readableState.flowing;
8834
8834
  };
8835
8835
  Readable.prototype.setEncoding = function(enc) {
8836
- if (!StringDecoder) StringDecoder = __webpack_require__("Zwc").I;
8836
+ if (!StringDecoder) StringDecoder = __webpack_require__("Zw").I;
8837
8837
  this._readableState.decoder = new StringDecoder(enc);
8838
8838
  this._readableState.encoding = enc;
8839
8839
  return this;
@@ -9939,7 +9939,7 @@
9939
9939
  exports1.PassThrough = __webpack_require__("X2");
9940
9940
  },
9941
9941
  CX (module1, exports1, __webpack_require__) {
9942
- var buffer = __webpack_require__("dY");
9942
+ var buffer = __webpack_require__("dY2");
9943
9943
  var Buffer = buffer.Buffer;
9944
9944
  function copyProps(src, dst) {
9945
9945
  for(var key in src)dst[key] = src[key];
@@ -9974,7 +9974,7 @@
9974
9974
  return buffer.SlowBuffer(size);
9975
9975
  };
9976
9976
  },
9977
- Zwc (__unused_rspack_module, exports1, __webpack_require__) {
9977
+ Zw (__unused_rspack_module, exports1, __webpack_require__) {
9978
9978
  "use strict";
9979
9979
  var Buffer = __webpack_require__("CX").Buffer;
9980
9980
  var isEncoding = Buffer.isEncoding || function(encoding) {
@@ -10978,7 +10978,7 @@
10978
10978
  var client = __webpack_require__("Q");
10979
10979
  var client_default = /*#__PURE__*/ __webpack_require__.n(client);
10980
10980
  var package_namespaceObject = {
10981
- rE: "15.8.0"
10981
+ rE: "15.8.2"
10982
10982
  };
10983
10983
  function isAudioEnabled(options) {
10984
10984
  return Boolean(options.audio.enabled);
@@ -14600,6 +14600,7 @@
14600
14600
  ].filter(Boolean).join(", ");
14601
14601
  options.logger.debug(`VideomailError: create(${args})`);
14602
14602
  const errData = {
14603
+ cause: errorParams.cause,
14603
14604
  explanation,
14604
14605
  logLines,
14605
14606
  err
@@ -14830,12 +14831,12 @@
14830
14831
  element.style.removeProperty("display");
14831
14832
  }
14832
14833
  const html_showElement = showElement;
14833
- const REGEX = /[ ,]+/u;
14834
+ const EMAIL_SEPARATOR_REGEX = /[ ,]+/gu;
14834
14835
  function trimEmail(email) {
14835
- return email.replace(REGEX, "");
14836
+ return email.replace(EMAIL_SEPARATOR_REGEX, "");
14836
14837
  }
14837
14838
  function trimEmails(emails) {
14838
- const trimmedEmails = emails.split(REGEX).map((item)=>item.trim()).filter(Boolean);
14839
+ const trimmedEmails = emails.split(EMAIL_SEPARATOR_REGEX).map((item)=>item.trim()).filter(Boolean);
14839
14840
  return trimmedEmails;
14840
14841
  }
14841
14842
  const FormMethod = {
@@ -15202,6 +15203,7 @@
15202
15203
  browser: err.browser,
15203
15204
  code: err.code,
15204
15205
  cookie: err.cookie,
15206
+ cause: err.cause instanceof Error ? serializeError(err.cause) : err.cause,
15205
15207
  cpu: err.cpu,
15206
15208
  device: err.device,
15207
15209
  engine: err.engine,
@@ -18852,6 +18854,34 @@
18852
18854
  return line;
18853
18855
  }
18854
18856
  const util_summarize = summarize;
18857
+ function getFirstVideoTrack(localMediaStream) {
18858
+ const videoTracks = localMediaStream.getVideoTracks();
18859
+ let videoTrack;
18860
+ if (videoTracks[0]) videoTrack = videoTracks[0];
18861
+ return videoTrack;
18862
+ }
18863
+ const media_getFirstVideoTrack = getFirstVideoTrack;
18864
+ const MEDIA_EVENTS = [
18865
+ "loadstart",
18866
+ "suspend",
18867
+ "progress",
18868
+ "abort",
18869
+ "emptied",
18870
+ "stalled",
18871
+ "pause",
18872
+ "loadeddata",
18873
+ "waiting",
18874
+ "playing",
18875
+ "canplay",
18876
+ "canplaythrough",
18877
+ "seeking",
18878
+ "seeked",
18879
+ "ended",
18880
+ "ratechange",
18881
+ "durationchange",
18882
+ "volumechange"
18883
+ ];
18884
+ const mediaEvents = MEDIA_EVENTS;
18855
18885
  function _define_property(obj, key, value) {
18856
18886
  if (key in obj) Object.defineProperty(obj, key, {
18857
18887
  value: value,
@@ -18924,11 +18954,11 @@
18924
18954
  let { bufferSize } = this.options.audio;
18925
18955
  if ("auto" === bufferSize) bufferSize = util_getBrowser(this.options).isFirefox() ? 512 : 2048;
18926
18956
  if (!is_power_of_two_default()(bufferSize)) throw error_createError({
18927
- message: "Audio buffer size must be a power of two.",
18957
+ message: `Audio buffer size must be a power of two. The current buffer size is ${bufferSize}.`,
18928
18958
  options: this.options
18929
18959
  });
18930
- if (this.options.audio.volume < 0 || this.options.audio.volume > 1) throw error_createError({
18931
- message: "Audio volume must be between zero and one.",
18960
+ if (!Number.isFinite(this.options.audio.volume) || this.options.audio.volume < 0 || this.options.audio.volume > 1) throw error_createError({
18961
+ message: `Audio volume must be between zero and one. The current volume is ${this.options.audio.volume}.`,
18932
18962
  options: this.options
18933
18963
  });
18934
18964
  volume.gain.value = this.options.audio.volume;
@@ -18965,34 +18995,6 @@
18965
18995
  }
18966
18996
  }
18967
18997
  const media_AudioRecorder = AudioRecorder;
18968
- function getFirstVideoTrack(localMediaStream) {
18969
- const videoTracks = localMediaStream.getVideoTracks();
18970
- let videoTrack;
18971
- if (videoTracks[0]) videoTrack = videoTracks[0];
18972
- return videoTrack;
18973
- }
18974
- const media_getFirstVideoTrack = getFirstVideoTrack;
18975
- const MEDIA_EVENTS = [
18976
- "loadstart",
18977
- "suspend",
18978
- "progress",
18979
- "abort",
18980
- "emptied",
18981
- "stalled",
18982
- "pause",
18983
- "loadeddata",
18984
- "waiting",
18985
- "playing",
18986
- "canplay",
18987
- "canplaythrough",
18988
- "seeking",
18989
- "seeked",
18990
- "ended",
18991
- "ratechange",
18992
- "durationchange",
18993
- "volumechange"
18994
- ];
18995
- const mediaEvents = MEDIA_EVENTS;
18996
18998
  const VIRTUAL_KEYWORDS = [
18997
18999
  "obs",
18998
19000
  "virtual",
@@ -19316,7 +19318,7 @@
19316
19318
  }
19317
19319
  }
19318
19320
  const visuals_userMedia = UserMedia;
19319
- var Buffer = __webpack_require__("dY").Buffer;
19321
+ var Buffer = __webpack_require__("dY2").Buffer;
19320
19322
  const PIPE_SYMBOL = "°º¤ø,¸¸,ø¤º°`°º¤ø,¸,ø¤°º¤ø,¸¸,ø¤º°`°º¤ø,¸ ";
19321
19323
  class Recorder extends util_Despot {
19322
19324
  visuals;
@@ -19433,6 +19435,7 @@
19433
19435
  const switchingFacingMode = params?.switchingFacingMode;
19434
19436
  this.userMediaLoading = this.blocking = this.unloaded = this.submitting = false;
19435
19437
  this.userMediaLoaded = true;
19438
+ this.clearUserMediaTimeout();
19436
19439
  if (!switchingFacingMode) this.loop = this.createLoop();
19437
19440
  this.show();
19438
19441
  if (params?.recordWhenReady) this.record();
@@ -19459,13 +19462,16 @@
19459
19462
  window.clearTimeout(this.connectionTimeout);
19460
19463
  this.connectionTimeout = void 0;
19461
19464
  }
19465
+ isOnline() {
19466
+ return navigator.onLine;
19467
+ }
19462
19468
  failConnection(params) {
19463
19469
  if (this.connectionFailed || this.connected || this.unloaded) return;
19464
19470
  this.connectionFailed = true;
19465
19471
  this.connecting = false;
19466
19472
  this.clearConnectionTimeout();
19467
19473
  const { url2Connect, cause } = params;
19468
- const online = navigator.onLine;
19474
+ const online = this.isOnline();
19469
19475
  const elapsedMs = this.connectingStartedAt ? Date.now() - this.connectingStartedAt : void 0;
19470
19476
  const closeEvent = this.lastCloseEvent;
19471
19477
  const socketError = this.lastSocketError;
@@ -19475,12 +19481,17 @@
19475
19481
  closeReason: closeEvent?.reason,
19476
19482
  elapsedMs,
19477
19483
  online,
19484
+ secureContext: globalThis.isSecureContext,
19485
+ socketReadyState: this.stream?.socket.readyState,
19486
+ timeoutMs: this.options.timeouts.connection,
19487
+ url: url2Connect,
19478
19488
  unloaded: this.unloaded,
19479
19489
  userMediaLoaded: this.userMediaLoaded,
19480
19490
  userMediaLoading: this.userMediaLoading,
19481
19491
  wasClean: closeEvent?.wasClean,
19482
19492
  socketError,
19483
- blocking: this.blocking
19493
+ blocking: this.blocking,
19494
+ visibilityState: document.visibilityState
19484
19495
  };
19485
19496
  const debugLine = util_summarize("Recorder: failConnection() diagnostic", contents);
19486
19497
  this.options.logger.debug(debugLine);
@@ -19500,6 +19511,7 @@
19500
19511
  message: "Unable to connect to the server",
19501
19512
  explanation,
19502
19513
  options: this.options,
19514
+ cause: contents,
19503
19515
  exc: socketError ? new Error("WebSocket connection error", {
19504
19516
  cause: socketError
19505
19517
  }) : void 0
@@ -19577,192 +19589,195 @@
19577
19589
  this.recordingStats.waitingTime = this.waitingTime;
19578
19590
  }
19579
19591
  initSocket(cb) {
19580
- if (!this.connected) {
19581
- if (util_isAutomatedUserAgent()) {
19582
- this.connecting = false;
19583
- this.options.logger.debug("Recorder: skipping web socket connection for an automated crawler");
19584
- return;
19585
- }
19586
- this.connecting = true;
19587
- this.connectionFailed = false;
19588
- this.connectingStartedAt = Date.now();
19589
- this.lastCloseEvent = void 0;
19590
- this.lastSocketError = void 0;
19591
- this.emit("CONNECTING");
19592
- let url2Connect;
19593
- try {
19594
- const socketUrlObj = new URL(this.options.socketUrl);
19595
- socketUrlObj.searchParams.set(constants.WHITELIST_KEY_LABEL, this.options.whitelistKey);
19596
- url2Connect = socketUrlObj.toString();
19597
- } catch (exc) {
19598
- this.connecting = this.connected = false;
19599
- const err = error_createError({
19600
- message: "Invalid WebSocket URL",
19601
- explanation: `The configured socketUrl "${this.options.socketUrl}" is not a valid URL. Please check your videomail-client configuration.`,
19602
- options: this.options,
19603
- exc
19604
- });
19605
- this.emit("ERROR", {
19606
- err
19607
- });
19608
- return;
19609
- }
19610
- this.options.logger.debug(`Recorder: initializing web socket stream to ${url2Connect}`);
19611
- let nativeSocket;
19612
- try {
19613
- nativeSocket = new WebSocket(url2Connect);
19614
- nativeSocket.addEventListener("close", (event)=>{
19615
- this.lastCloseEvent = {
19616
- code: event.code,
19617
- reason: event.reason,
19618
- wasClean: event.wasClean
19619
- };
19620
- });
19621
- nativeSocket.addEventListener("error", (event)=>{
19622
- this.lastSocketError = error_getEventDetails(event);
19623
- });
19624
- } catch (exc) {
19625
- this.connecting = this.connected = false;
19626
- const diagnostic = error_getWebSocketDiagnostic(url2Connect);
19627
- const message = diagnostic.looksAutomated ? "Automated crawler: WebSocket not supported in this environment" : `Failed to construct WebSocket to ${url2Connect}`;
19628
- 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}`;
19629
- const err = error_createError({
19630
- message,
19631
- explanation,
19632
- options: this.options,
19633
- exc
19634
- });
19635
- this.emit("ERROR", {
19636
- err
19637
- });
19638
- return;
19639
- }
19640
- try {
19641
- this.stream = stream_default()(nativeSocket);
19642
- } catch (exc) {
19643
- this.connecting = this.connected = false;
19644
- const err = error_createError({
19645
- message: `Failed to create a stream to ${url2Connect}`,
19646
- explanation: "Please check your connection and try again. If the problem persists, contact us.",
19647
- options: this.options,
19648
- exc
19592
+ if (this.connected) return void cb?.();
19593
+ if (this.connecting) return;
19594
+ if (util_isAutomatedUserAgent()) {
19595
+ this.connecting = false;
19596
+ this.options.logger.debug("Recorder: skipping web socket connection for an automated crawler");
19597
+ return;
19598
+ }
19599
+ this.connecting = true;
19600
+ this.connectionFailed = false;
19601
+ this.connectingStartedAt = Date.now();
19602
+ this.lastCloseEvent = void 0;
19603
+ this.lastSocketError = void 0;
19604
+ this.emit("CONNECTING");
19605
+ let url2Connect;
19606
+ try {
19607
+ const socketUrlObj = new URL(this.options.socketUrl);
19608
+ socketUrlObj.searchParams.set(constants.WHITELIST_KEY_LABEL, this.options.whitelistKey);
19609
+ url2Connect = socketUrlObj.toString();
19610
+ } catch (exc) {
19611
+ this.connecting = this.connected = false;
19612
+ const err = error_createError({
19613
+ message: "Invalid WebSocket URL",
19614
+ explanation: `The configured socketUrl "${this.options.socketUrl}" is not a valid URL. Please check your videomail-client configuration.`,
19615
+ options: this.options,
19616
+ exc
19617
+ });
19618
+ this.emit("ERROR", {
19619
+ err
19620
+ });
19621
+ return;
19622
+ }
19623
+ this.options.logger.debug(`Recorder: initializing web socket stream to ${url2Connect}`);
19624
+ let nativeSocket;
19625
+ try {
19626
+ nativeSocket = new WebSocket(url2Connect);
19627
+ nativeSocket.addEventListener("close", (event)=>{
19628
+ this.lastCloseEvent = {
19629
+ code: event.code,
19630
+ reason: event.reason,
19631
+ wasClean: event.wasClean
19632
+ };
19633
+ });
19634
+ nativeSocket.addEventListener("error", (event)=>{
19635
+ this.lastSocketError = error_getEventDetails(event);
19636
+ });
19637
+ } catch (exc) {
19638
+ this.connecting = this.connected = false;
19639
+ const diagnostic = error_getWebSocketDiagnostic(url2Connect);
19640
+ const message = diagnostic.looksAutomated ? "Automated crawler: WebSocket not supported in this environment" : `Failed to construct WebSocket to ${url2Connect}`;
19641
+ 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}`;
19642
+ const err = error_createError({
19643
+ message,
19644
+ explanation,
19645
+ options: this.options,
19646
+ exc
19647
+ });
19648
+ this.emit("ERROR", {
19649
+ err
19650
+ });
19651
+ return;
19652
+ }
19653
+ try {
19654
+ this.stream = stream_default()(nativeSocket);
19655
+ } catch (exc) {
19656
+ this.connecting = this.connected = false;
19657
+ const err = error_createError({
19658
+ message: `Failed to create a stream to ${url2Connect}`,
19659
+ explanation: "Please check your connection and try again. If the problem persists, contact us.",
19660
+ options: this.options,
19661
+ exc
19662
+ });
19663
+ this.emit("ERROR", {
19664
+ err
19665
+ });
19666
+ }
19667
+ if (this.stream) {
19668
+ const connectionTimeoutMs = this.options.timeouts.connection;
19669
+ this.connectionTimeout = window.setTimeout(()=>{
19670
+ if (this.isOnline() && this.isUserMediaLoaded()) {
19671
+ this.options.logger.debug(`${PIPE_SYMBOL}Reconnecting due to connection timeout.`);
19672
+ this.initSocket();
19673
+ } else this.failConnection({
19674
+ url2Connect,
19675
+ cause: "timeout"
19649
19676
  });
19650
- this.emit("ERROR", {
19651
- err
19677
+ }, connectionTimeoutMs);
19678
+ this.stream.on("close", ()=>{
19679
+ const debugLine = util_summarize(`${PIPE_SYMBOL}Stream has closed:`, {
19680
+ connecting: this.connecting,
19681
+ connected: this.connected,
19682
+ userMediaLoaded: this.userMediaLoaded,
19683
+ blocking: this.blocking
19652
19684
  });
19653
- }
19654
- if (this.stream) {
19655
- const connectionTimeoutMs = this.options.timeouts.connection;
19656
- this.connectionTimeout = window.setTimeout(()=>{
19685
+ this.options.logger.debug(debugLine);
19686
+ const tryReconnect = this.connected && this.userMediaLoaded;
19687
+ this.connected = false;
19688
+ if (tryReconnect) this.initSocket();
19689
+ else if (!this.connecting && !this.blocking) window.setTimeout(()=>{
19657
19690
  this.failConnection({
19658
19691
  url2Connect,
19659
- cause: "timeout"
19660
- });
19661
- }, connectionTimeoutMs);
19662
- this.stream.on("close", ()=>{
19663
- const debugLine = util_summarize(`${PIPE_SYMBOL}Stream has closed:`, {
19664
- connecting: this.connecting,
19665
- connected: this.connected,
19666
- userMediaLoaded: this.userMediaLoaded,
19667
- blocking: this.blocking
19692
+ cause: "closed"
19668
19693
  });
19669
- this.options.logger.debug(debugLine);
19670
- const tryReconnect = this.connected && this.userMediaLoaded;
19671
- this.connected = false;
19672
- if (tryReconnect) this.initSocket();
19673
- else if (!this.connecting && !this.blocking) window.setTimeout(()=>{
19674
- this.failConnection({
19675
- url2Connect,
19676
- cause: "closed"
19677
- });
19678
- }, 0);
19679
- });
19680
- this.stream.on("connect", (args)=>{
19681
- this.options.logger.debug(`${PIPE_SYMBOL}Stream *connect* event emitted with args: ${util_pretty(args)}`);
19682
- this.clearConnectionTimeout();
19683
- const isClosing = this.stream?.socket.readyState === WebSocket.CLOSING;
19684
- if (!this.connected && !isClosing && !this.unloaded) {
19685
- this.connected = true;
19686
- this.connecting = this.unloaded = false;
19687
- this.emit("CONNECTED");
19688
- cb?.();
19689
- }
19690
- });
19691
- this.stream.on("data", (data)=>{
19692
- this.options.logger.debug(`${PIPE_SYMBOL}Stream *data* event emitted`);
19693
- try {
19694
- const command = JSON.parse(data.toString());
19695
- this.executeCommand(command);
19696
- } catch (exc) {
19697
- this.options.logger.error(`Failed to parse command: ${exc}`);
19698
- const err = error_createError({
19699
- message: "Invalid server command",
19700
- explanation: `Contact us. The invalid command was: ${data.toString()}.`,
19701
- options: this.options,
19702
- exc
19703
- });
19704
- this.emit("ERROR", {
19705
- err
19706
- });
19707
- }
19708
- });
19709
- this.stream.on("error", (err)=>{
19710
- if ("u" > typeof Event && err instanceof Event) this.lastSocketError = error_getEventDetails(err);
19711
- else this.lastSocketError = serializeError(err);
19712
- const debugLine = util_summarize(`${PIPE_SYMBOL}Stream *error* event emitted:`, {
19713
- error: serializeError(err)
19714
- });
19715
- this.options.logger.debug(debugLine);
19716
- if (!this.connected) return void this.failConnection({
19717
- url2Connect,
19718
- cause: "error"
19719
- });
19720
- const streamError = err instanceof Error ? err : new Error("WebSocket stream emitted an error event", {
19721
- cause: this.lastSocketError ?? err
19694
+ }, 0);
19695
+ });
19696
+ this.stream.on("connect", (args)=>{
19697
+ this.options.logger.debug(`${PIPE_SYMBOL}Stream *connect* event emitted with args: ${util_pretty(args)}`);
19698
+ this.clearConnectionTimeout();
19699
+ const isClosing = this.stream?.socket.readyState === WebSocket.CLOSING;
19700
+ if (!this.connected && !isClosing && !this.unloaded) {
19701
+ this.connected = true;
19702
+ this.connecting = this.unloaded = false;
19703
+ this.emit("CONNECTED");
19704
+ cb?.();
19705
+ }
19706
+ });
19707
+ this.stream.on("data", (data)=>{
19708
+ this.options.logger.debug(`${PIPE_SYMBOL}Stream *data* event emitted`);
19709
+ try {
19710
+ const command = JSON.parse(data.toString());
19711
+ this.executeCommand(command);
19712
+ } catch (exc) {
19713
+ this.options.logger.error(`Failed to parse command: ${exc}`);
19714
+ const err = error_createError({
19715
+ message: "Invalid server command",
19716
+ explanation: `Contact us. The invalid command was: ${data.toString()}.`,
19717
+ options: this.options,
19718
+ exc
19722
19719
  });
19723
19720
  this.emit("ERROR", {
19724
- err: error_createError({
19725
- message: "WebSocket stream error",
19726
- explanation: `The WebSocket stream emitted an error event. Details: ${util_pretty(err)}`,
19727
- options: this.options,
19728
- exc: streamError
19729
- })
19721
+ err
19730
19722
  });
19723
+ }
19724
+ });
19725
+ this.stream.on("error", (err)=>{
19726
+ if ("u" > typeof Event && err instanceof Event) this.lastSocketError = error_getEventDetails(err);
19727
+ else this.lastSocketError = serializeError(err);
19728
+ const debugLine = util_summarize(`${PIPE_SYMBOL}Stream *error* event emitted:`, {
19729
+ error: serializeError(err)
19731
19730
  });
19732
- this.stream.on("drain", ()=>{
19733
- this.options.logger.debug(`${PIPE_SYMBOL}Stream *drain* event emitted (should not happen!)`);
19734
- });
19735
- this.stream.on("preend", (args)=>{
19736
- this.options.logger.debug(`${PIPE_SYMBOL}Stream *preend* event emitted with args: ${util_pretty(args)}`);
19737
- });
19738
- this.stream.on("end", ()=>{
19739
- this.options.logger.debug(`${PIPE_SYMBOL}Stream *end* event emitted`);
19740
- });
19741
- this.stream.on("drain", (args)=>{
19742
- this.options.logger.debug(`${PIPE_SYMBOL}Stream *drain* event emitted with args: ${util_pretty(args)}`);
19743
- });
19744
- this.stream.on("pipe", (src)=>{
19745
- this.options.logger.debug(`${PIPE_SYMBOL}Stream *pipe* event emitted with src: ${util_pretty(src)}`);
19746
- });
19747
- this.stream.on("unpipe", (src)=>{
19748
- this.options.logger.debug(`${PIPE_SYMBOL}Stream *unpipe* event emitted with src: ${util_pretty(src)}`);
19749
- });
19750
- this.stream.on("resume", (args)=>{
19751
- this.options.logger.debug(`${PIPE_SYMBOL}Stream *resume* event emitted with args: ${util_pretty(args)}`);
19752
- });
19753
- this.stream.on("uncork", (args)=>{
19754
- this.options.logger.debug(`${PIPE_SYMBOL}Stream *uncork* event emitted with args: ${util_pretty(args)}`);
19755
- });
19756
- this.stream.on("readable", (args)=>{
19757
- this.options.logger.debug(`${PIPE_SYMBOL}Stream *readable* event emitted with args: ${util_pretty(args)}`);
19731
+ this.options.logger.debug(debugLine);
19732
+ if (!this.connected) return void this.failConnection({
19733
+ url2Connect,
19734
+ cause: "error"
19758
19735
  });
19759
- this.stream.on("prefinish", (args)=>{
19760
- this.options.logger.debug(`${PIPE_SYMBOL}Stream *prefinish* event emitted with args: ${util_pretty(args)}`);
19736
+ const streamError = err instanceof Error ? err : new Error("WebSocket stream emitted an error event", {
19737
+ cause: this.lastSocketError ?? err
19761
19738
  });
19762
- this.stream.on("finish", (args)=>{
19763
- this.options.logger.debug(`${PIPE_SYMBOL}Stream *finish* event emitted with args: ${util_pretty(args)}`);
19739
+ this.emit("ERROR", {
19740
+ err: error_createError({
19741
+ message: "WebSocket stream error",
19742
+ explanation: `The WebSocket stream emitted an error event. Details: ${util_pretty(err)}`,
19743
+ options: this.options,
19744
+ exc: streamError
19745
+ })
19764
19746
  });
19765
- }
19747
+ });
19748
+ this.stream.on("drain", ()=>{
19749
+ this.options.logger.debug(`${PIPE_SYMBOL}Stream *drain* event emitted (should not happen!)`);
19750
+ });
19751
+ this.stream.on("preend", (args)=>{
19752
+ this.options.logger.debug(`${PIPE_SYMBOL}Stream *preend* event emitted with args: ${util_pretty(args)}`);
19753
+ });
19754
+ this.stream.on("end", ()=>{
19755
+ this.options.logger.debug(`${PIPE_SYMBOL}Stream *end* event emitted`);
19756
+ });
19757
+ this.stream.on("drain", (args)=>{
19758
+ this.options.logger.debug(`${PIPE_SYMBOL}Stream *drain* event emitted with args: ${util_pretty(args)}`);
19759
+ });
19760
+ this.stream.on("pipe", (src)=>{
19761
+ this.options.logger.debug(`${PIPE_SYMBOL}Stream *pipe* event emitted with src: ${util_pretty(src)}`);
19762
+ });
19763
+ this.stream.on("unpipe", (src)=>{
19764
+ this.options.logger.debug(`${PIPE_SYMBOL}Stream *unpipe* event emitted with src: ${util_pretty(src)}`);
19765
+ });
19766
+ this.stream.on("resume", (args)=>{
19767
+ this.options.logger.debug(`${PIPE_SYMBOL}Stream *resume* event emitted with args: ${util_pretty(args)}`);
19768
+ });
19769
+ this.stream.on("uncork", (args)=>{
19770
+ this.options.logger.debug(`${PIPE_SYMBOL}Stream *uncork* event emitted with args: ${util_pretty(args)}`);
19771
+ });
19772
+ this.stream.on("readable", (args)=>{
19773
+ this.options.logger.debug(`${PIPE_SYMBOL}Stream *readable* event emitted with args: ${util_pretty(args)}`);
19774
+ });
19775
+ this.stream.on("prefinish", (args)=>{
19776
+ this.options.logger.debug(`${PIPE_SYMBOL}Stream *prefinish* event emitted with args: ${util_pretty(args)}`);
19777
+ });
19778
+ this.stream.on("finish", (args)=>{
19779
+ this.options.logger.debug(`${PIPE_SYMBOL}Stream *finish* event emitted with args: ${util_pretty(args)}`);
19780
+ });
19766
19781
  }
19767
19782
  }
19768
19783
  showUserMedia() {
@@ -19852,8 +19867,8 @@
19852
19867
  ideal: idealHeight
19853
19868
  };
19854
19869
  }
19855
- this.options.logger.debug(`Recorder: our webcam constraints are: ${util_pretty(constraints)}`);
19856
- this.options.logger.debug(`Recorder: available webcam constraints are: ${util_pretty(navigator.mediaDevices.getSupportedConstraints())}`);
19870
+ this.options.logger.debug(util_summarize("Recorder: our webcam constraints are:", constraints));
19871
+ this.options.logger.debug(util_summarize("Recorder: available webcam constraints are:", navigator.mediaDevices.getSupportedConstraints()));
19857
19872
  const streamPromise = navigator.mediaDevices.getUserMedia(constraints);
19858
19873
  streamPromise.then((localStream)=>{
19859
19874
  this.getUserMediaCallback(localStream, params);