videomail-client 16.5.0 → 16.7.0

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.
@@ -5987,6 +5987,7 @@ var __webpack_modules__ = {
5987
5987
  var has = Object.prototype.hasOwnProperty;
5988
5988
  var isArray = Array.isArray;
5989
5989
  var getPrototypeOf = Object.getPrototypeOf;
5990
+ var fromCharCode = String.fromCharCode;
5990
5991
  var isPlainContainer = function(value) {
5991
5992
  if (!value || 'object' != typeof value) return false;
5992
5993
  if (isArray(value)) return true;
@@ -6059,7 +6060,12 @@ var __webpack_modules__ = {
6059
6060
  };
6060
6061
  var interpretNumericEntities = function(str) {
6061
6062
  return str.replace(/&#(\d+);/g, function($0, numberStr) {
6062
- return String.fromCharCode(parseInt(numberStr, 10));
6063
+ var c = parseInt(numberStr, 10);
6064
+ if (c > 0xFFFF && c <= 0x10FFFF) {
6065
+ c -= 0x10000;
6066
+ return fromCharCode(0xD800 | c >> 10, 0xDC00 | 0x3FF & c);
6067
+ }
6068
+ return fromCharCode(c);
6063
6069
  });
6064
6070
  };
6065
6071
  var parseArrayValue = function(val, options, currentArrayLength) {
@@ -6131,6 +6137,9 @@ var __webpack_modules__ = {
6131
6137
  }
6132
6138
  return obj;
6133
6139
  };
6140
+ var stripWrappingBrackets = function(key) {
6141
+ return '[' === key.charAt(0) && ']' === key.charAt(key.length - 1) ? key.slice(1, -1) : key;
6142
+ };
6134
6143
  var parseObject = function(chain, val, options, valuesParsed) {
6135
6144
  var currentArrayLength = 0;
6136
6145
  if (chain.length > 0 && '[]' === chain[chain.length - 1]) {
@@ -6146,7 +6155,7 @@ var __webpack_modules__ = {
6146
6155
  obj = options.plainObjects ? {
6147
6156
  __proto__: null
6148
6157
  } : {};
6149
- var cleanRoot = '[' === root.charAt(0) && ']' === root.charAt(root.length - 1) ? root.slice(1, -1) : root;
6158
+ var cleanRoot = stripWrappingBrackets(root);
6150
6159
  var decodedRoot = options.decodeDotInKeys ? cleanRoot.replace(/%2E/gi, '.') : cleanRoot;
6151
6160
  var index = parseInt(decodedRoot, 10);
6152
6161
  var isValidArrayIndex = !isNaN(index) && root !== decodedRoot && String(index) === decodedRoot && index >= 0 && options.parseArrays;
@@ -6159,9 +6168,7 @@ var __webpack_modules__ = {
6159
6168
  obj[index] = leaf;
6160
6169
  utils.markOverflow(obj, index);
6161
6170
  } else if ('__proto__' !== decodedRoot) obj[decodedRoot] = leaf;
6162
- } else obj = {
6163
- 0: leaf
6164
- };
6171
+ } else obj[0] = leaf;
6165
6172
  }
6166
6173
  leaf = obj;
6167
6174
  }
@@ -6191,7 +6198,7 @@ var __webpack_modules__ = {
6191
6198
  var splitKeyIntoSegments = function(originalKey, options) {
6192
6199
  var key = options.allowDots ? topLevelDotsToBrackets(originalKey) : originalKey;
6193
6200
  if (options.depth <= 0) {
6194
- if (!options.plainObjects && has.call(Object.prototype, key)) {
6201
+ if (!options.plainObjects && has.call(Object.prototype, stripWrappingBrackets(key))) {
6195
6202
  if (!options.allowPrototypes) return;
6196
6203
  }
6197
6204
  return [
@@ -6575,6 +6582,11 @@ var __webpack_modules__ = {
6575
6582
  }
6576
6583
  return max;
6577
6584
  };
6585
+ var countElements = function(arr) {
6586
+ var count = 0;
6587
+ for(var i = 0; i < arr.length; ++i)if (has.call(arr, i)) count += 1;
6588
+ return count;
6589
+ };
6578
6590
  var limitedPair = function(first, second, options) {
6579
6591
  var pair = [
6580
6592
  first,
@@ -6591,7 +6603,7 @@ var __webpack_modules__ = {
6591
6603
  if ('object' != typeof source && 'function' != typeof source) {
6592
6604
  if (isArray(target)) {
6593
6605
  var nextIndex = target.length;
6594
- if (options && 'number' == typeof options.arrayLimit && nextIndex >= options.arrayLimit) {
6606
+ if (options && 'number' == typeof options.arrayLimit && countElements(target) >= options.arrayLimit) {
6595
6607
  if (options.throwOnLimitExceeded) throw new RangeError('Array limit exceeded. Only ' + options.arrayLimit + ' element' + (1 === options.arrayLimit ? '' : 's') + ' allowed in an array.');
6596
6608
  return markOverflow(arrayToObject(target.concat(source), options), nextIndex);
6597
6609
  }
@@ -6649,7 +6661,7 @@ var __webpack_modules__ = {
6649
6661
  else target[target.length] = item;
6650
6662
  } else target[i] = item;
6651
6663
  });
6652
- if (options && 'number' == typeof options.arrayLimit && target.length > options.arrayLimit) {
6664
+ if (options && 'number' == typeof options.arrayLimit && countElements(target) > options.arrayLimit) {
6653
6665
  if (options.throwOnLimitExceeded) throw new RangeError('Array limit exceeded. Only ' + options.arrayLimit + ' element' + (1 === options.arrayLimit ? '' : 's') + ' allowed in an array.');
6654
6666
  return markOverflow(arrayToObject(target, options), target.length - 1);
6655
6667
  }
@@ -7200,7 +7212,7 @@ var __webpack_modules__ = {
7200
7212
  const qs = __webpack_require__("b");
7201
7213
  const RequestBase = __webpack_require__("d");
7202
7214
  const { isObject, mixin, hasOwn, isSafeKey } = __webpack_require__("Dp");
7203
- const ResponseBase = __webpack_require__("es");
7215
+ const ResponseBase = __webpack_require__("e");
7204
7216
  const Agent = __webpack_require__("pf");
7205
7217
  function noop() {}
7206
7218
  module.exports = function(method, url) {
@@ -7914,7 +7926,7 @@ var __webpack_modules__ = {
7914
7926
  }, this._responseTimeout);
7915
7927
  };
7916
7928
  },
7917
- es (module, __unused_rspack_exports, __webpack_require__) {
7929
+ e (module, __unused_rspack_exports, __webpack_require__) {
7918
7930
  "use strict";
7919
7931
  const utils = __webpack_require__("Dp");
7920
7932
  module.exports = ResponseBase;
@@ -10625,7 +10637,7 @@ var __webpack_modules__ = {
10625
10637
  return i[1];
10626
10638
  };
10627
10639
  },
10628
- R (module) {
10640
+ RR (module) {
10629
10641
  "use strict";
10630
10642
  var stylesInDOM = [];
10631
10643
  function getIndexByIdentifier(identifier) {
@@ -11126,7 +11138,7 @@ var __webpack_exports__ = {};
11126
11138
  var client = __webpack_require__("Q");
11127
11139
  var client_default = /*#__PURE__*/ __webpack_require__.n(client);
11128
11140
  var package_namespaceObject = {
11129
- rE: "16.5.0"
11141
+ rE: "16.7.0"
11130
11142
  };
11131
11143
  function isAudioEnabled(options) {
11132
11144
  return Boolean(options.audio.enabled);
@@ -15198,6 +15210,17 @@ var __webpack_exports__ = {};
15198
15210
  enable(buttonsToo) {
15199
15211
  this.setDisabled(false, buttonsToo);
15200
15212
  }
15213
+ disableForSubmission() {
15214
+ for (const formControl of this.formElement.elements){
15215
+ this.submissionDisabledStates.set(formControl, formControl.hasAttribute("disabled"));
15216
+ formControl.setAttribute("disabled", "disabled");
15217
+ }
15218
+ }
15219
+ restoreAfterFailedSubmission() {
15220
+ for (const [formControl, wasDisabled] of this.submissionDisabledStates)if (wasDisabled) formControl.setAttribute("disabled", "disabled");
15221
+ else formControl.removeAttribute("disabled");
15222
+ this.submissionDisabledStates.clear();
15223
+ }
15201
15224
  build() {
15202
15225
  this.options.logger.debug("Form: build()");
15203
15226
  this.keyInput = this.formElement.querySelector(`input[name="${this.options.selectors.keyInputName}"]`);
@@ -15363,7 +15386,7 @@ var __webpack_exports__ = {};
15363
15386
  html_showElement(this.formElement);
15364
15387
  }
15365
15388
  constructor(container, formElement, options){
15366
- super("Form", options), form_define_property(this, "container", void 0), form_define_property(this, "formElement", void 0), form_define_property(this, "keyInput", void 0), form_define_property(this, "submitButton", void 0), form_define_property(this, "submitButtonFormAttribute", null), form_define_property(this, "generatedFormId", void 0), form_define_property(this, "isSubmitting", false), form_define_property(this, "FORM_FIELDS", {}), form_define_property(this, "validate", (event)=>{
15389
+ super("Form", options), form_define_property(this, "container", void 0), form_define_property(this, "formElement", void 0), form_define_property(this, "keyInput", void 0), form_define_property(this, "submitButton", void 0), form_define_property(this, "submitButtonFormAttribute", null), form_define_property(this, "generatedFormId", void 0), form_define_property(this, "isSubmitting", false), form_define_property(this, "submissionDisabledStates", new Map()), form_define_property(this, "FORM_FIELDS", {}), form_define_property(this, "validate", (event)=>{
15367
15390
  this.container.validate(event);
15368
15391
  }), form_define_property(this, "handleSubmit", (event)=>{
15369
15392
  if (!event.defaultPrevented) this.doTheSubmit(event);
@@ -15832,7 +15855,7 @@ var __webpack_exports__ = {};
15832
15855
  return newOptions;
15833
15856
  }
15834
15857
  const options_mergeWithDefaultOptions = mergeWithDefaultOptions;
15835
- var injectStylesIntoStyleTag = __webpack_require__("R");
15858
+ var injectStylesIntoStyleTag = __webpack_require__("RR");
15836
15859
  var injectStylesIntoStyleTag_default = /*#__PURE__*/ __webpack_require__.n(injectStylesIntoStyleTag);
15837
15860
  var styleDomAPI = __webpack_require__("Bd");
15838
15861
  var styleDomAPI_default = /*#__PURE__*/ __webpack_require__.n(styleDomAPI);
@@ -18162,8 +18185,13 @@ var __webpack_exports__ = {};
18162
18185
  this.hide();
18163
18186
  }
18164
18187
  onUserMediaReady(params) {
18165
- this.onFormReady();
18188
+ this.onFormReady(params);
18166
18189
  html_showElement(this.buttonsElement);
18190
+ if (params.recovering && params.paused) {
18191
+ html_hideElement(this.recordButton);
18192
+ html_disableElement(this.recordButton);
18193
+ return;
18194
+ }
18167
18195
  html_showElement(this.audioOnRadioPair);
18168
18196
  html_showElement(this.audioOffRadioPair);
18169
18197
  if (html_isShown(this.recordButton) && !params.recordWhenReady) html_enableElement(this.recordButton);
@@ -18886,8 +18914,8 @@ var __webpack_exports__ = {};
18886
18914
  this.on("PAUSED", ()=>{
18887
18915
  this.pauseRecording();
18888
18916
  });
18889
- this.on("ERROR", ()=>{
18890
- this.onResetting();
18917
+ this.on("ERROR", ({ recoverable })=>{
18918
+ if (!recoverable) this.onResetting();
18891
18919
  });
18892
18920
  this.on("RESETTING", ()=>{
18893
18921
  this.onResetting();
@@ -19078,12 +19106,12 @@ var __webpack_exports__ = {};
19078
19106
  this.entertainTimeoutId = void 0;
19079
19107
  this.entertaining = false;
19080
19108
  }
19081
- error(err) {
19109
+ error(err, blocking = true) {
19082
19110
  const message = err.message;
19083
19111
  const explanation = err.explanation;
19084
19112
  if (!message) this.options.logger.debug(`Weird empty error message generated for error ${string_pretty(err)}`);
19085
19113
  this.notify(message, explanation, {
19086
- blocking: true,
19114
+ blocking,
19087
19115
  problem: true,
19088
19116
  classList: err.getClassList(),
19089
19117
  removeDimensions: util_getBrowser(this.options).isMobile()
@@ -19275,6 +19303,18 @@ var __webpack_exports__ = {};
19275
19303
  canvas_to_buffer_modern_r.atob = void 0;
19276
19304
  var websocket_stream_stream = __webpack_require__("U");
19277
19305
  var stream_default = /*#__PURE__*/ __webpack_require__.n(websocket_stream_stream);
19306
+ function isAutomatedUserAgent(userAgent = navigator.userAgent) {
19307
+ return /bot|crawler|spider|headlesschrome|phantomjs|puppeteer|playwright/iu.test(userAgent);
19308
+ }
19309
+ const util_isAutomatedUserAgent = isAutomatedUserAgent;
19310
+ function getAutomationSignals() {
19311
+ const webdriver = navigator.webdriver;
19312
+ return {
19313
+ webdriver: true === webdriver,
19314
+ userAgentMatched: util_isAutomatedUserAgent()
19315
+ };
19316
+ }
19317
+ const util_getAutomationSignals = getAutomationSignals;
19278
19318
  function getEdgeCodes(value, amount, fromEnd) {
19279
19319
  const chars = fromEnd ? value.slice(-amount) : value.slice(0, amount);
19280
19320
  const codes = Array.from(chars, (char)=>String(char.codePointAt(0))).join(".");
@@ -19302,15 +19342,16 @@ var __webpack_exports__ = {};
19302
19342
  if (languageList.length > 0) return languageList.join(",");
19303
19343
  return navigator.language || "none";
19304
19344
  }
19305
- function getAutomationSignals(probeBase, probeSimpleQuery) {
19345
+ function getDiagnosticSignals(probeBase, probeSimpleQuery) {
19306
19346
  const reasons = [];
19307
- if (navigator.webdriver) reasons.push("webdriver=true");
19308
- if (/HeadlessChrome|PhantomJS|puppeteer|playwright/iu.test(navigator.userAgent)) reasons.push("headless_ua_marker");
19347
+ const automation = util_getAutomationSignals();
19348
+ if (automation.webdriver) reasons.push("webdriver=true");
19349
+ if (automation.userAgentMatched) reasons.push("headless_ua_marker");
19309
19350
  if (0 === navigator.languages.length) reasons.push("no_languages");
19310
19351
  if ("ok" !== probeBase) reasons.push("probe_base_failed");
19311
19352
  if ("ok" !== probeSimpleQuery) reasons.push("probe_simple_query_failed");
19312
19353
  return {
19313
- looksAutomated: reasons.length > 0,
19354
+ looksAutomated: automation.webdriver || automation.userAgentMatched,
19314
19355
  reasons: reasons.length > 0 ? reasons.join(",") : "none"
19315
19356
  };
19316
19357
  }
@@ -19327,7 +19368,7 @@ var __webpack_exports__ = {};
19327
19368
  const probeBase = probeWebSocketConstructor("wss://videomail.io");
19328
19369
  const probeWithSimpleQuery = probeWebSocketConstructor("wss://videomail.io/?a=b");
19329
19370
  const languages = getLanguagesValue();
19330
- const automationSignals = getAutomationSignals(probeBase, probeWithSimpleQuery);
19371
+ const automationSignals = getDiagnosticSignals(probeBase, probeWithSimpleQuery);
19331
19372
  const diagnosticPairs = [
19332
19373
  `webdriver=${String(navigator.webdriver)}`,
19333
19374
  `wsCtorNative=${String(wsCtorNative)}`,
@@ -19354,10 +19395,6 @@ var __webpack_exports__ = {};
19354
19395
  };
19355
19396
  }
19356
19397
  const error_getWebSocketDiagnostic = getWebSocketDiagnostic;
19357
- function isAutomatedUserAgent(userAgent = navigator.userAgent) {
19358
- return /bot|crawler|spider|headlesschrome|phantomjs|puppeteer|playwright/iu.test(userAgent);
19359
- }
19360
- const util_isAutomatedUserAgent = isAutomatedUserAgent;
19361
19398
  function boundedWriteQueue_define_property(obj, key, value) {
19362
19399
  if (key in obj) Object.defineProperty(obj, key, {
19363
19400
  value: value,
@@ -19553,6 +19590,9 @@ var __webpack_exports__ = {};
19553
19590
  explanation: "The server connection closed before this recording completed. It cannot be safely resumed, so it has been stopped. Please start a new recording.",
19554
19591
  options: this.options,
19555
19592
  cause: {
19593
+ transportPhase: "recording",
19594
+ mediaTransmissionStarted: true,
19595
+ automation: util_getAutomationSignals(),
19556
19596
  unconfirmedFrames,
19557
19597
  unconfirmedSamples
19558
19598
  }
@@ -19620,46 +19660,54 @@ var __webpack_exports__ = {};
19620
19660
  this.resumeAfterDrain = false;
19621
19661
  this.reconnecting = true;
19622
19662
  this.initSocket();
19623
- } else if (this.shouldReportStreamClose()) window.setTimeout(()=>{
19624
- this.handleConnectionFailure({
19625
- url2Connect,
19626
- cause: "closed"
19627
- });
19628
- }, 0);
19663
+ } else if (this.shouldReportStreamClose()) {
19664
+ const stream = this.stream;
19665
+ window.setTimeout(()=>{
19666
+ if (this.stream === stream) this.handleConnectionFailure({
19667
+ url2Connect,
19668
+ cause: "closed"
19669
+ });
19670
+ }, 0);
19671
+ }
19629
19672
  }
19630
19673
  shouldIgnoreStreamClose() {
19631
- return this.recordingTransportFailed || Boolean(this.unloaded) || this.validate();
19674
+ return this.recordingTransportFailed || Boolean(this.unloaded) || this.validate() || this.blocking && !this.mediaTransmissionStarted;
19675
+ }
19676
+ closeIdleConnection(reason) {
19677
+ if (this.mediaTransmissionStarted) return;
19678
+ this.options.logger.debug(string_summarize("Recorder: closing idle connection", {
19679
+ reason,
19680
+ connected: this.connected,
19681
+ connecting: this.connecting,
19682
+ visibilityState: document.visibilityState
19683
+ }));
19684
+ this.connected = this.connecting = this.reconnecting = false;
19685
+ this.clearConnectionTimeout();
19686
+ this.clearReconnectTimeout();
19687
+ this.stopPings();
19688
+ this.discardSocket();
19632
19689
  }
19633
19690
  handleStreamError(url2Connect, err) {
19634
- var _this_lastSocketError;
19635
19691
  if ("u" > typeof Event && err instanceof Event) this.lastSocketError = error_getEventDetails(err);
19636
19692
  else this.lastSocketError = serializeError(err);
19637
19693
  const debugLine = string_summarize(`${PIPE_SYMBOL}Stream *error* event emitted:`, {
19638
19694
  error: serializeError(err)
19639
19695
  });
19640
19696
  this.options.logger.debug(debugLine);
19641
- if (this.validate()) {
19697
+ if (this.shouldIgnoreStreamClose()) {
19642
19698
  this.connected = false;
19643
19699
  this.stopPings();
19644
19700
  this.discardSocket();
19645
19701
  return;
19646
19702
  }
19647
- if (!this.connected) return void this.handleConnectionFailure({
19703
+ if (this.mediaTransmissionStarted) return void this.failInterruptedRecording();
19704
+ this.reconnecting || (this.reconnecting = this.canReconnectAfterStreamClose());
19705
+ this.connected = false;
19706
+ this.stopPings();
19707
+ this.handleConnectionFailure({
19648
19708
  url2Connect,
19649
19709
  cause: "error"
19650
19710
  });
19651
- const streamError = err instanceof Error ? err : new Error("WebSocket stream emitted an error event", {
19652
- cause: null != (_this_lastSocketError = this.lastSocketError) ? _this_lastSocketError : err
19653
- });
19654
- if (this.mediaTransmissionStarted) return void this.failInterruptedRecording();
19655
- this.emit("ERROR", {
19656
- err: error_createError({
19657
- message: "WebSocket stream error",
19658
- explanation: `The WebSocket stream emitted an error event. Details: ${string_pretty(err)}`,
19659
- options: this.options,
19660
- exc: streamError
19661
- })
19662
- });
19663
19711
  }
19664
19712
  sendPings() {
19665
19713
  this.stopPings();
@@ -19720,6 +19768,7 @@ var __webpack_exports__ = {};
19720
19768
  this.connectionFailed = true;
19721
19769
  this.connecting = false;
19722
19770
  this.reconnecting = false;
19771
+ const reconnectAttempts = this.reconnectAttempts;
19723
19772
  this.reconnectAttempts = 0;
19724
19773
  this.clearReconnectTimeout();
19725
19774
  this.clearConnectionTimeout();
@@ -19730,6 +19779,14 @@ var __webpack_exports__ = {};
19730
19779
  const socketError = this.lastSocketError;
19731
19780
  const contents = {
19732
19781
  cause,
19782
+ transportPhase: void 0 === this.connectionOpenedAt ? "initial" : "idle",
19783
+ mediaTransmissionStarted: this.mediaTransmissionStarted,
19784
+ recordingActive: this.recordingActive,
19785
+ framesCount: this.framesCount,
19786
+ samplesCount: this.samplesCount,
19787
+ reconnectAttempts,
19788
+ connectionOpenedAt: this.connectionOpenedAt,
19789
+ automation: util_getAutomationSignals(),
19733
19790
  closeCode: null == closeEvent ? void 0 : closeEvent.code,
19734
19791
  closeReason: null == closeEvent ? void 0 : closeEvent.reason,
19735
19792
  elapsedMs,
@@ -19771,7 +19828,7 @@ var __webpack_exports__ = {};
19771
19828
  });
19772
19829
  }
19773
19830
  shouldIgnoreConnectionFailure() {
19774
- return this.connectionFailed || this.connected || Boolean(this.unloaded) || this.validate();
19831
+ return this.connectionFailed || this.connected || Boolean(this.unloaded) || this.validate() || this.blocking && !this.mediaTransmissionStarted;
19775
19832
  }
19776
19833
  initSocket(cb) {
19777
19834
  if (this.connected) {
@@ -19781,7 +19838,8 @@ var __webpack_exports__ = {};
19781
19838
  }
19782
19839
  if (this.connecting) return void this.options.logger.debug("Recorder: already **connecting**. Not going to initialize a new WebSocket connection.");
19783
19840
  this.clearReconnectTimeout();
19784
- if (util_isAutomatedUserAgent()) {
19841
+ const automation = util_getAutomationSignals();
19842
+ if (automation.userAgentMatched) {
19785
19843
  this.connecting = false;
19786
19844
  this.options.logger.debug("Recorder: skipping web socket connection for an automated crawler");
19787
19845
  return;
@@ -19815,6 +19873,8 @@ var __webpack_exports__ = {};
19815
19873
  try {
19816
19874
  nativeSocket = new WebSocket(url2Connect);
19817
19875
  nativeSocket.addEventListener("close", (event)=>{
19876
+ var _this_stream;
19877
+ if ((null == (_this_stream = this.stream) ? void 0 : _this_stream.socket) !== nativeSocket) return;
19818
19878
  this.lastCloseEvent = {
19819
19879
  code: event.code,
19820
19880
  reason: event.reason,
@@ -19822,6 +19882,8 @@ var __webpack_exports__ = {};
19822
19882
  };
19823
19883
  });
19824
19884
  nativeSocket.addEventListener("error", (event)=>{
19885
+ var _this_stream;
19886
+ if ((null == (_this_stream = this.stream) ? void 0 : _this_stream.socket) !== nativeSocket) return;
19825
19887
  this.lastSocketError = error_getEventDetails(event);
19826
19888
  });
19827
19889
  } catch (exc) {
@@ -19833,7 +19895,10 @@ var __webpack_exports__ = {};
19833
19895
  message,
19834
19896
  explanation,
19835
19897
  options: this.options,
19836
- exc
19898
+ exc,
19899
+ cause: {
19900
+ automation
19901
+ }
19837
19902
  });
19838
19903
  this.emit("ERROR", {
19839
19904
  err
@@ -19871,15 +19936,16 @@ var __webpack_exports__ = {};
19871
19936
  });
19872
19937
  }, connectionTimeoutMs);
19873
19938
  stream.on("close", ()=>{
19874
- this.handleStreamClose(url2Connect);
19939
+ if (this.stream === stream) this.handleStreamClose(url2Connect);
19875
19940
  });
19876
19941
  stream.on("connect", (args)=>{
19877
- var _this_stream;
19942
+ if (this.stream !== stream) return;
19878
19943
  this.options.logger.debug(`${PIPE_SYMBOL}Stream *connect* event emitted with args: ${string_pretty(args)}`);
19879
19944
  this.clearConnectionTimeout();
19880
- const isClosing = (null == (_this_stream = this.stream) ? void 0 : _this_stream.socket.readyState) === WebSocket.CLOSING;
19945
+ const isClosing = stream.socket.readyState === WebSocket.CLOSING;
19881
19946
  if (!this.connected && !isClosing && !this.unloaded) {
19882
19947
  this.connected = true;
19948
+ this.connectionOpenedAt = Date.now();
19883
19949
  this.connecting = this.unloaded = false;
19884
19950
  this.reconnecting = false;
19885
19951
  this.reconnectAttempts = 0;
@@ -19889,6 +19955,7 @@ var __webpack_exports__ = {};
19889
19955
  }
19890
19956
  });
19891
19957
  stream.on("data", (data)=>{
19958
+ if (this.stream !== stream) return;
19892
19959
  this.options.logger.debug(`${PIPE_SYMBOL}Stream *data* event emitted`);
19893
19960
  try {
19894
19961
  const command = JSON.parse(data.toString());
@@ -19907,10 +19974,10 @@ var __webpack_exports__ = {};
19907
19974
  }
19908
19975
  });
19909
19976
  stream.on("error", (err)=>{
19910
- this.handleStreamError(url2Connect, err);
19977
+ if (this.stream === stream) this.handleStreamError(url2Connect, err);
19911
19978
  });
19912
19979
  stream.on("drain", ()=>{
19913
- this.handleStreamDrain(stream);
19980
+ if (this.stream === stream) this.handleStreamDrain(stream);
19914
19981
  });
19915
19982
  stream.on("preend", (args)=>{
19916
19983
  this.options.logger.debug(`${PIPE_SYMBOL}Stream *preend* event emitted with args: ${string_pretty(args)}`);
@@ -19964,7 +20031,7 @@ var __webpack_exports__ = {};
19964
20031
  }
19965
20032
  }
19966
20033
  constructor(options){
19967
- super(options), connection_define_property(this, "reconnectTimeout", void 0), connection_define_property(this, "connectionTimeout", void 0), connection_define_property(this, "userMediaLoaded", void 0), connection_define_property(this, "userMediaLoading", false), connection_define_property(this, "unloaded", void 0), connection_define_property(this, "connectionFailed", false), connection_define_property(this, "reconnectAttempts", 0), connection_define_property(this, "blocking", false), connection_define_property(this, "connectingStartedAt", void 0), connection_define_property(this, "lastCloseEvent", void 0), connection_define_property(this, "lastSocketError", void 0), connection_define_property(this, "pingInterval", void 0);
20034
+ super(options), connection_define_property(this, "reconnectTimeout", void 0), connection_define_property(this, "connectionTimeout", void 0), connection_define_property(this, "userMediaLoaded", void 0), connection_define_property(this, "userMediaLoading", false), connection_define_property(this, "unloaded", void 0), connection_define_property(this, "connectionFailed", false), connection_define_property(this, "reconnectAttempts", 0), connection_define_property(this, "blocking", false), connection_define_property(this, "connectingStartedAt", void 0), connection_define_property(this, "lastCloseEvent", void 0), connection_define_property(this, "lastSocketError", void 0), connection_define_property(this, "pingInterval", void 0), connection_define_property(this, "connectionOpenedAt", void 0);
19968
20035
  }
19969
20036
  }
19970
20037
  const connection = RecorderConnection;
@@ -20027,6 +20094,7 @@ var __webpack_exports__ = {};
20027
20094
  const characteristics = null == (_this_userMedia = this.userMedia) ? void 0 : _this_userMedia.getCharacteristics();
20028
20095
  this.options.logger.debug(`Recorder: userMediaErrorCallback(), name: ${err.name}, message: ${err.message} and Webcam characteristics: ${characteristics ? string_pretty(characteristics) : "none"}`);
20029
20096
  const errorListeners = this.getListeners("ERROR");
20097
+ if (err.name !== error_VideomailError.MEDIA_DEVICE_NOT_SUPPORTED) this.closeIdleConnection("camera-access-failed");
20030
20098
  if (null == errorListeners ? void 0 : errorListeners.length) if (err.name !== error_VideomailError.MEDIA_DEVICE_NOT_SUPPORTED) {
20031
20099
  const videomailError = error_createError({
20032
20100
  err,
@@ -20537,6 +20605,10 @@ var __webpack_exports__ = {};
20537
20605
  if (this.streamBackpressured) this.resumeAfterDrain = true;
20538
20606
  else loop.start();
20539
20607
  }
20608
+ resumeMediaForCountdown() {
20609
+ var _this_userMedia;
20610
+ null == (_this_userMedia = this.userMedia) || _this_userMedia.resume();
20611
+ }
20540
20612
  onFlushed(opts) {
20541
20613
  const frameNumber = opts.frameNumber;
20542
20614
  if (1 === frameNumber) this.emit("FIRST_FRAME_SENT");
@@ -21800,6 +21872,7 @@ var __webpack_exports__ = {};
21800
21872
  this.cancelCameraRecovery();
21801
21873
  this.blocking = true;
21802
21874
  this.clearUserMediaTimeout();
21875
+ this.closeIdleConnection("blocking-error");
21803
21876
  });
21804
21877
  this.on("PREVIEW", ()=>{
21805
21878
  this.hide();
@@ -22166,6 +22239,32 @@ var __webpack_exports__ = {};
22166
22239
  }
22167
22240
  }
22168
22241
  const visuals_replay = Replay;
22242
+ function visuals_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
22243
+ try {
22244
+ var info = gen[key](arg);
22245
+ var value = info.value;
22246
+ } catch (error) {
22247
+ reject(error);
22248
+ return;
22249
+ }
22250
+ if (info.done) resolve(value);
22251
+ else Promise.resolve(value).then(_next, _throw);
22252
+ }
22253
+ function visuals_async_to_generator(fn) {
22254
+ return function() {
22255
+ var self1 = this, args = arguments;
22256
+ return new Promise(function(resolve, reject) {
22257
+ var gen = fn.apply(self1, args);
22258
+ function _next(value) {
22259
+ visuals_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22260
+ }
22261
+ function _throw(err) {
22262
+ visuals_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
22263
+ }
22264
+ _next(void 0);
22265
+ });
22266
+ };
22267
+ }
22169
22268
  function visuals_define_property(obj, key, value) {
22170
22269
  if (key in obj) Object.defineProperty(obj, key, {
22171
22270
  value: value,
@@ -22360,21 +22459,40 @@ var __webpack_exports__ = {};
22360
22459
  this.clearCameraRecoveryNotice();
22361
22460
  return this.recorder.recoverCamera();
22362
22461
  }
22363
- resume() {
22364
- this.clearCameraRecoveryNotice();
22365
- if (this.recorderInsides.isCountingDown()) {
22462
+ canResumeCountdown(restored) {
22463
+ return restored && Boolean(this.recorderInsides.isCountingDown());
22464
+ }
22465
+ resumeCountdown() {
22466
+ return visuals_async_to_generator(function*() {
22467
+ const restored = yield this.recoverCamera();
22468
+ if (!this.canResumeCountdown(restored)) return;
22469
+ this.recorder.resumeMediaForCountdown();
22366
22470
  this.recorderInsides.resumeCountdown();
22367
22471
  this.recorderInsides.hidePause();
22368
- } else {
22369
- this.recorder.resume();
22370
- if (!this.recorder.isPaused()) this.recorderInsides.hidePause();
22371
- }
22472
+ }).call(this);
22473
+ }
22474
+ resume() {
22475
+ return visuals_async_to_generator(function*() {
22476
+ this.clearCameraRecoveryNotice();
22477
+ if (this.recorderInsides.isCountingDown()) yield this.resumeCountdown();
22478
+ else {
22479
+ this.recorder.resume();
22480
+ if (!this.recorder.isPaused()) this.recorderInsides.hidePause();
22481
+ }
22482
+ }).call(this);
22483
+ }
22484
+ resumeFromControl() {
22485
+ this.resume().catch((exc)=>{
22486
+ this.emit("ERROR", {
22487
+ exc
22488
+ });
22489
+ });
22372
22490
  }
22373
22491
  pauseOrResume() {
22374
- if (this.cameraRecoveryFailed && this.recorder.isPaused()) this.resume();
22492
+ if (this.cameraRecoveryFailed && this.recorder.isPaused()) this.resumeFromControl();
22375
22493
  else if (this.isRecordable()) {
22376
22494
  if (this.isRecording()) this.pause();
22377
- else if (this.recorder.isPaused()) this.resume();
22495
+ else if (this.recorder.isPaused()) this.resumeFromControl();
22378
22496
  else if (this.recorder.isReady()) this.recorder.record();
22379
22497
  }
22380
22498
  }
@@ -22403,8 +22521,8 @@ var __webpack_exports__ = {};
22403
22521
  isPaused() {
22404
22522
  return this.recorder.isPaused();
22405
22523
  }
22406
- error(err) {
22407
- this.notifier.error(err);
22524
+ error(err, blocking = true) {
22525
+ this.notifier.error(err, blocking);
22408
22526
  }
22409
22527
  hide() {
22410
22528
  if (this.visualsElement) {
@@ -22553,6 +22671,7 @@ var __webpack_exports__ = {};
22553
22671
  }
22554
22672
  return target;
22555
22673
  }
22674
+ const INTERACTIVE_SPACE_TARGETS = "button, input, select, textarea, a[href], summary, label, audio[controls], video[controls], [contenteditable]:not([contenteditable='false']), [role='button'], [role='link'], [role='checkbox'], [role='radio'], [role='switch'], [role='menuitem'], [role='tab'], [tabindex]:not([tabindex='-1'])";
22556
22675
  class Container extends util_Despot {
22557
22676
  buildChildren(playerOnly = false, parentElement) {
22558
22677
  const parentElementInfo = parentElement ? `, parentElement="${string_pretty(parentElement)}"` : "";
@@ -22627,9 +22746,9 @@ var __webpack_exports__ = {};
22627
22746
  if (params.exc.stack) this.options.logger.error(params.exc.stack);
22628
22747
  else if (params.exc.message) this.options.logger.error(params.exc.message);
22629
22748
  } else this.options.logger.error(params.exc);
22630
- if (this.options.displayErrors && params.err) this.visuals.error(params.err);
22631
- else if (this.options.displayErrors && params.exc && params.exc instanceof error_VideomailError) this.visuals.error(params.exc);
22632
- else this.visuals.reset();
22749
+ if (this.options.displayErrors && params.err) this.visuals.error(params.err, !params.recoverable);
22750
+ else if (this.options.displayErrors && params.exc && params.exc instanceof error_VideomailError) this.visuals.error(params.exc, !params.recoverable);
22751
+ else if (!params.recoverable) this.visuals.reset();
22633
22752
  }
22634
22753
  initEvents(playerOnly = false) {
22635
22754
  this.options.logger.debug(`Container: initEvents (playerOnly = ${playerOnly})`);
@@ -22647,7 +22766,10 @@ var __webpack_exports__ = {};
22647
22766
  }
22648
22767
  });
22649
22768
  if (this.options.enableSpace) {
22650
- if (!playerOnly) window.addEventListener("keydown", this.handleKeyDown);
22769
+ if (!playerOnly) {
22770
+ var _this_containerElement;
22771
+ null == (_this_containerElement = this.containerElement) || _this_containerElement.addEventListener("keydown", this.handleKeyDown);
22772
+ }
22651
22773
  }
22652
22774
  this.on("ERROR", (params)=>{
22653
22775
  this.processError(params);
@@ -22685,10 +22807,10 @@ var __webpack_exports__ = {};
22685
22807
  this.endWaiting();
22686
22808
  }
22687
22809
  removeBrowserEventListeners() {
22688
- var _this_stopListeningToVisibility, _this;
22810
+ var _this_containerElement, _this_stopListeningToVisibility, _this;
22689
22811
  window.removeEventListener("resize", this.handleWindowResize);
22690
22812
  window.removeEventListener("beforeunload", this.handleBeforeUnload);
22691
- window.removeEventListener("keydown", this.handleKeyDown);
22813
+ null == (_this_containerElement = this.containerElement) || _this_containerElement.removeEventListener("keydown", this.handleKeyDown);
22692
22814
  null == (_this_stopListeningToVisibility = (_this = this).stopListeningToVisibility) || _this_stopListeningToVisibility.call(_this);
22693
22815
  this.stopListeningToVisibility = void 0;
22694
22816
  }
@@ -22938,6 +23060,7 @@ var __webpack_exports__ = {};
22938
23060
  return container_async_to_generator(function*() {
22939
23061
  let response;
22940
23062
  let hostResponse;
23063
+ let submissionFailed = false;
22941
23064
  const videomailKey = formData[this.options.selectors.keyInputName];
22942
23065
  try {
22943
23066
  const hasVideomailKey = Boolean(videomailKey);
@@ -22948,7 +23071,10 @@ var __webpack_exports__ = {};
22948
23071
  ].filter(Boolean).join(": ");
22949
23072
  this.options.logger.debug(`Container: submitAll(${output})`);
22950
23073
  this.beginWaiting();
22951
- if (this.options.disableFormWhenSubmitting) this.disableForm(true);
23074
+ if (this.options.disableFormWhenSubmitting) {
23075
+ var _this_form;
23076
+ null == (_this_form = this.form) || _this_form.disableForSubmission();
23077
+ }
22952
23078
  this.emit("SUBMITTING");
22953
23079
  if (hasVideomailKey) {
22954
23080
  var _this_getPendingHostSubmissionResponse;
@@ -22977,15 +23103,21 @@ var __webpack_exports__ = {};
22977
23103
  });
22978
23104
  }
22979
23105
  } catch (exc) {
23106
+ submissionFailed = true;
22980
23107
  const err = error_createError({
22981
23108
  exc,
22982
23109
  options: this.options
22983
23110
  });
22984
23111
  this.emit("ERROR", {
22985
- err
23112
+ err,
23113
+ recoverable: true
22986
23114
  });
22987
23115
  } finally{
22988
23116
  const finalResponse = null != hostResponse ? hostResponse : response;
23117
+ if (submissionFailed && this.options.disableFormWhenSubmitting) {
23118
+ var _this_form1;
23119
+ null == (_this_form1 = this.form) || _this_form1.restoreAfterFailedSubmission();
23120
+ }
22989
23121
  if ((null == finalResponse ? void 0 : finalResponse.text) && "text/html" === finalResponse.type) document.body.innerHTML = purify_default.sanitize(finalResponse.text);
22990
23122
  this.endWaiting();
22991
23123
  }
@@ -23045,7 +23177,11 @@ var __webpack_exports__ = {};
23045
23177
  this.visuals.record();
23046
23178
  }
23047
23179
  resume() {
23048
- this.visuals.resume();
23180
+ this.visuals.resume().catch((exc)=>{
23181
+ this.emit("ERROR", {
23182
+ exc
23183
+ });
23184
+ });
23049
23185
  }
23050
23186
  stop() {
23051
23187
  this.visuals.stop();
@@ -23065,14 +23201,16 @@ var __webpack_exports__ = {};
23065
23201
  e
23066
23202
  });
23067
23203
  }), container_define_property(this, "handleKeyDown", (e)=>{
23068
- const element = e.target;
23069
- const tagName = element.tagName;
23070
- const isEditable = element.isContentEditable || "true" === element.contentEditable;
23071
- if (!isEditable && tagName && "INPUT" !== tagName.toUpperCase() && "TEXTAREA" !== tagName.toUpperCase() && "Space" === e.code) {
23072
- e.preventDefault();
23073
- if (this.options.enablePause) this.visuals.pauseOrResume();
23074
- else this.visuals.recordOrStop();
23075
- }
23204
+ const containerElement = this.containerElement;
23205
+ if (!containerElement) return;
23206
+ const eventPath = e.composedPath();
23207
+ const targetContainerIndex = eventPath.findIndex((eventTarget)=>eventTarget instanceof Element && eventTarget.classList.contains(this.options.selectors.containerClass));
23208
+ const targetContainer = eventPath[targetContainerIndex];
23209
+ const isInteractiveTarget = eventPath.slice(0, targetContainerIndex + 1).some((eventTarget)=>eventTarget instanceof Element && eventTarget.matches(INTERACTIVE_SPACE_TARGETS));
23210
+ if (!eventPath.includes(containerElement) || targetContainer !== containerElement || isInteractiveTarget || e.defaultPrevented || e.repeat || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || "Space" !== e.code) return;
23211
+ e.preventDefault();
23212
+ if (this.options.enablePause) this.visuals.pauseOrResume();
23213
+ else this.visuals.recordOrStop();
23076
23214
  });
23077
23215
  this.visuals = new wrappers_visuals(this, options);
23078
23216
  this.buttons = new buttons(this, options);