videomail-client 15.7.19 → 15.8.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.
- package/dist/cjs/index.cjs +67 -45
- package/dist/esm/index.js +66 -45
- package/dist/esm/wrappers/container.d.ts +5 -0
- package/dist/esm/wrappers/visuals/recorder.d.ts +2 -0
- package/dist/umd/index.js +69 -43
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -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.
|
|
10975
|
+
rE: "15.8.0"
|
|
10976
10976
|
};
|
|
10977
10977
|
function isAudioEnabled(options) {
|
|
10978
10978
|
return Boolean(options.audio.enabled);
|
|
@@ -19290,7 +19290,8 @@ var __webpack_exports__ = {};
|
|
|
19290
19290
|
}
|
|
19291
19291
|
hasInvalidDimensions() {
|
|
19292
19292
|
if (!this.rawVisualUserMedia) return false;
|
|
19293
|
-
|
|
19293
|
+
const { videoWidth, videoHeight } = this.rawVisualUserMedia;
|
|
19294
|
+
return videoWidth > 0 && videoWidth < 3 || videoHeight > 0 && videoHeight < 3;
|
|
19294
19295
|
}
|
|
19295
19296
|
logEvent(eventType, params) {
|
|
19296
19297
|
this.options.logger.debug(`UserMedia: ... ${EVENT_ASCII} event ${eventType}: ${util_pretty(params)}`);
|
|
@@ -19629,13 +19630,16 @@ var __webpack_exports__ = {};
|
|
|
19629
19630
|
}
|
|
19630
19631
|
}
|
|
19631
19632
|
sendPings() {
|
|
19633
|
+
this.stopPings();
|
|
19632
19634
|
this.pingInterval = window.setInterval(()=>{
|
|
19633
19635
|
this.options.logger.debug("Recorder: pinging...");
|
|
19634
19636
|
this.writeStream(Buffer.from(""));
|
|
19635
19637
|
}, this.options.timeouts.pingInterval);
|
|
19636
19638
|
}
|
|
19637
19639
|
stopPings() {
|
|
19638
|
-
|
|
19640
|
+
if (void 0 === this.pingInterval) return;
|
|
19641
|
+
window.clearInterval(this.pingInterval);
|
|
19642
|
+
this.pingInterval = void 0;
|
|
19639
19643
|
}
|
|
19640
19644
|
onAudioSample(audioSample) {
|
|
19641
19645
|
this.samplesCount++;
|
|
@@ -19666,13 +19670,13 @@ var __webpack_exports__ = {};
|
|
|
19666
19670
|
}
|
|
19667
19671
|
}
|
|
19668
19672
|
clearRetryTimeout() {
|
|
19669
|
-
if (
|
|
19673
|
+
if (void 0 === this.retryTimeout) return;
|
|
19670
19674
|
this.options.logger.debug("Recorder: clearRetryTimeout()");
|
|
19671
19675
|
window.clearTimeout(this.retryTimeout);
|
|
19672
19676
|
this.retryTimeout = void 0;
|
|
19673
19677
|
}
|
|
19674
19678
|
clearConnectionTimeout() {
|
|
19675
|
-
if (
|
|
19679
|
+
if (void 0 === this.connectionTimeout) return;
|
|
19676
19680
|
this.options.logger.debug("Recorder: clearConnectionTimeout()");
|
|
19677
19681
|
window.clearTimeout(this.connectionTimeout);
|
|
19678
19682
|
this.connectionTimeout = void 0;
|
|
@@ -20001,19 +20005,23 @@ var __webpack_exports__ = {};
|
|
|
20001
20005
|
const characteristics = null == (_this_userMedia = this.userMedia) ? void 0 : _this_userMedia.getCharacteristics();
|
|
20002
20006
|
this.options.logger.debug(`Recorder: userMediaErrorCallback(), name: ${err.name}, message: ${err.message} and Webcam characteristics: ${characteristics ? util_pretty(characteristics) : "none"}`);
|
|
20003
20007
|
const errorListeners = this.getListeners("ERROR");
|
|
20004
|
-
if (null == errorListeners ? void 0 : errorListeners.length) {
|
|
20005
|
-
|
|
20006
|
-
|
|
20007
|
-
|
|
20008
|
-
|
|
20009
|
-
|
|
20010
|
-
|
|
20011
|
-
|
|
20012
|
-
|
|
20013
|
-
|
|
20014
|
-
|
|
20015
|
-
this.retryTimeout = window.setTimeout(
|
|
20016
|
-
|
|
20008
|
+
if (null == errorListeners ? void 0 : errorListeners.length) if (err.name !== error_VideomailError.MEDIA_DEVICE_NOT_SUPPORTED) {
|
|
20009
|
+
const videomailError = error_createError({
|
|
20010
|
+
err,
|
|
20011
|
+
options: this.options,
|
|
20012
|
+
usedConstraints
|
|
20013
|
+
});
|
|
20014
|
+
this.emit("ERROR", {
|
|
20015
|
+
err: videomailError
|
|
20016
|
+
});
|
|
20017
|
+
} else {
|
|
20018
|
+
this.options.logger.debug(`Recorder: ignore user media error ${util_pretty(err)}`);
|
|
20019
|
+
this.retryTimeout = window.setTimeout(()=>{
|
|
20020
|
+
this.retryTimeout = void 0;
|
|
20021
|
+
this.loadUserMedia();
|
|
20022
|
+
}, this.options.timeouts.userMedia);
|
|
20023
|
+
}
|
|
20024
|
+
else if (this.unloaded) this.options.logger.debug(`Recorder: already unloaded. Not going to throw error ${util_pretty(err)}`);
|
|
20017
20025
|
else {
|
|
20018
20026
|
this.options.logger.debug(`Recorder: no error listeners attached but throwing error ${util_pretty(err)}`);
|
|
20019
20027
|
throw error_createError({
|
|
@@ -20237,7 +20245,8 @@ var __webpack_exports__ = {};
|
|
|
20237
20245
|
limitReached
|
|
20238
20246
|
});
|
|
20239
20247
|
null == (_this_loop = this.loop) || _this_loop.complete();
|
|
20240
|
-
setTimeout(()=>{
|
|
20248
|
+
this.stopTimeout = window.setTimeout(()=>{
|
|
20249
|
+
this.stopTimeout = void 0;
|
|
20241
20250
|
this.stopTime = Date.now();
|
|
20242
20251
|
const videoType = this.replay.getVideoType();
|
|
20243
20252
|
if (!videoType) throw new Error("Unable to video record when no video type is defined.");
|
|
@@ -20287,6 +20296,9 @@ var __webpack_exports__ = {};
|
|
|
20287
20296
|
this.reset();
|
|
20288
20297
|
this.clearUserMediaTimeout();
|
|
20289
20298
|
this.clearConnectionTimeout();
|
|
20299
|
+
this.clearRetryTimeout();
|
|
20300
|
+
this.clearStopTimeout();
|
|
20301
|
+
this.stopPings();
|
|
20290
20302
|
this.connecting = false;
|
|
20291
20303
|
if (this.userMedia) this.userMedia.unloadRemainingEventListeners();
|
|
20292
20304
|
if (this.submitting) ;
|
|
@@ -20310,12 +20322,17 @@ var __webpack_exports__ = {};
|
|
|
20310
20322
|
}
|
|
20311
20323
|
}
|
|
20312
20324
|
clearUserMediaTimeout() {
|
|
20313
|
-
if (this.userMediaTimeout) {
|
|
20325
|
+
if (void 0 !== this.userMediaTimeout) {
|
|
20314
20326
|
this.options.logger.debug("Recorder: clearUserMediaTimeout()");
|
|
20315
20327
|
window.clearTimeout(this.userMediaTimeout);
|
|
20316
20328
|
this.userMediaTimeout = void 0;
|
|
20317
20329
|
}
|
|
20318
20330
|
}
|
|
20331
|
+
clearStopTimeout() {
|
|
20332
|
+
if (void 0 === this.stopTimeout) return;
|
|
20333
|
+
window.clearTimeout(this.stopTimeout);
|
|
20334
|
+
this.stopTimeout = void 0;
|
|
20335
|
+
}
|
|
20319
20336
|
validate() {
|
|
20320
20337
|
return this.connected && void 0 === this.canvas;
|
|
20321
20338
|
}
|
|
@@ -20699,7 +20716,7 @@ var __webpack_exports__ = {};
|
|
|
20699
20716
|
return this.userMediaLoaded;
|
|
20700
20717
|
}
|
|
20701
20718
|
constructor(visuals, replay, options){
|
|
20702
|
-
super("Recorder", options), recorder_define_property(this, "visuals", void 0), recorder_define_property(this, "replay", void 0), recorder_define_property(this, "loop", void 0), recorder_define_property(this, "originalAnimationFrameObject", void 0), recorder_define_property(this, "samplesCount", 0), recorder_define_property(this, "framesCount", 0), recorder_define_property(this, "recordingStats", void 0), recorder_define_property(this, "confirmedFrameNumber", 0), recorder_define_property(this, "confirmedSampleNumber", 0), recorder_define_property(this, "recorderElement", void 0), recorder_define_property(this, "userMedia", void 0), recorder_define_property(this, "userMediaTimeout", void 0), recorder_define_property(this, "retryTimeout", void 0), recorder_define_property(this, "connectionTimeout", void 0), recorder_define_property(this, "frameProgress", void 0), recorder_define_property(this, "sampleProgress", void 0), recorder_define_property(this, "canvas", void 0), recorder_define_property(this, "ctx", void 0), recorder_define_property(this, "userMediaLoaded", void 0), recorder_define_property(this, "userMediaLoading", false), recorder_define_property(this, "submitting", false), recorder_define_property(this, "unloaded", void 0), recorder_define_property(this, "stopTime", void 0), recorder_define_property(this, "stream", void 0), recorder_define_property(this, "connecting", false), recorder_define_property(this, "connected", false), recorder_define_property(this, "connectionFailed", false), recorder_define_property(this, "blocking", false), recorder_define_property(this, "built", false), recorder_define_property(this, "key", void 0), recorder_define_property(this, "waitingTime", void 0), recorder_define_property(this, "connectingStartedAt", void 0), recorder_define_property(this, "lastCloseEvent", void 0), recorder_define_property(this, "lastSocketError", void 0), recorder_define_property(this, "pingInterval", void 0), recorder_define_property(this, "frame", void 0), recorder_define_property(this, "recordingBuffer", void 0), recorder_define_property(this, "facingMode", void 0);
|
|
20719
|
+
super("Recorder", options), recorder_define_property(this, "visuals", void 0), recorder_define_property(this, "replay", void 0), recorder_define_property(this, "loop", void 0), recorder_define_property(this, "originalAnimationFrameObject", void 0), recorder_define_property(this, "samplesCount", 0), recorder_define_property(this, "framesCount", 0), recorder_define_property(this, "recordingStats", void 0), recorder_define_property(this, "confirmedFrameNumber", 0), recorder_define_property(this, "confirmedSampleNumber", 0), recorder_define_property(this, "recorderElement", void 0), recorder_define_property(this, "userMedia", void 0), recorder_define_property(this, "userMediaTimeout", void 0), recorder_define_property(this, "retryTimeout", void 0), recorder_define_property(this, "connectionTimeout", void 0), recorder_define_property(this, "stopTimeout", void 0), recorder_define_property(this, "frameProgress", void 0), recorder_define_property(this, "sampleProgress", void 0), recorder_define_property(this, "canvas", void 0), recorder_define_property(this, "ctx", void 0), recorder_define_property(this, "userMediaLoaded", void 0), recorder_define_property(this, "userMediaLoading", false), recorder_define_property(this, "submitting", false), recorder_define_property(this, "unloaded", void 0), recorder_define_property(this, "stopTime", void 0), recorder_define_property(this, "stream", void 0), recorder_define_property(this, "connecting", false), recorder_define_property(this, "connected", false), recorder_define_property(this, "connectionFailed", false), recorder_define_property(this, "blocking", false), recorder_define_property(this, "built", false), recorder_define_property(this, "key", void 0), recorder_define_property(this, "waitingTime", void 0), recorder_define_property(this, "connectingStartedAt", void 0), recorder_define_property(this, "lastCloseEvent", void 0), recorder_define_property(this, "lastSocketError", void 0), recorder_define_property(this, "pingInterval", void 0), recorder_define_property(this, "frame", void 0), recorder_define_property(this, "recordingBuffer", void 0), recorder_define_property(this, "facingMode", void 0);
|
|
20703
20720
|
this.visuals = visuals;
|
|
20704
20721
|
this.replay = replay;
|
|
20705
20722
|
this.facingMode = options.video.facingMode;
|
|
@@ -21391,18 +21408,11 @@ var __webpack_exports__ = {};
|
|
|
21391
21408
|
}
|
|
21392
21409
|
initEvents(playerOnly = false) {
|
|
21393
21410
|
this.options.logger.debug(`Container: initEvents (playerOnly = ${playerOnly})`);
|
|
21394
|
-
if (this.options.recalculateDimensionsOnWindowResize) window.addEventListener("resize",
|
|
21395
|
-
|
|
21396
|
-
this.emit("WINDOW_RESIZE", "container");
|
|
21397
|
-
});
|
|
21398
|
-
if (this.options.enableAutoUnload) window.addEventListener("beforeunload", (e)=>{
|
|
21399
|
-
this.unload({
|
|
21400
|
-
e
|
|
21401
|
-
});
|
|
21402
|
-
}, {
|
|
21411
|
+
if (this.options.recalculateDimensionsOnWindowResize) window.addEventListener("resize", this.handleWindowResize);
|
|
21412
|
+
if (this.options.enableAutoUnload) window.addEventListener("beforeunload", this.handleBeforeUnload, {
|
|
21403
21413
|
once: true
|
|
21404
21414
|
});
|
|
21405
|
-
if (!playerOnly) this.visibility.onChange((visible)=>{
|
|
21415
|
+
if (!playerOnly) this.stopListeningToVisibility = this.visibility.onChange((visible)=>{
|
|
21406
21416
|
if (this.built) if (visible) {
|
|
21407
21417
|
if (isAutoPauseEnabled(this.options) && this.isCountingDown()) this.resume();
|
|
21408
21418
|
this.emit("VISIBLE");
|
|
@@ -21412,19 +21422,7 @@ var __webpack_exports__ = {};
|
|
|
21412
21422
|
}
|
|
21413
21423
|
});
|
|
21414
21424
|
if (this.options.enableSpace) {
|
|
21415
|
-
if (!playerOnly) window.addEventListener("keydown",
|
|
21416
|
-
const element = e.target;
|
|
21417
|
-
const tagName = element.tagName;
|
|
21418
|
-
const isEditable = element.isContentEditable || "true" === element.contentEditable;
|
|
21419
|
-
if (!isEditable && tagName && "INPUT" !== tagName.toUpperCase() && "TEXTAREA" !== tagName.toUpperCase()) {
|
|
21420
|
-
const code = e.code;
|
|
21421
|
-
if ("Space" === code) {
|
|
21422
|
-
e.preventDefault();
|
|
21423
|
-
if (this.options.enablePause) this.visuals.pauseOrResume();
|
|
21424
|
-
else this.visuals.recordOrStop();
|
|
21425
|
-
}
|
|
21426
|
-
}
|
|
21427
|
-
});
|
|
21425
|
+
if (!playerOnly) window.addEventListener("keydown", this.handleKeyDown);
|
|
21428
21426
|
}
|
|
21429
21427
|
this.on("ERROR", (params)=>{
|
|
21430
21428
|
this.processError(params);
|
|
@@ -21461,6 +21459,14 @@ var __webpack_exports__ = {};
|
|
|
21461
21459
|
}
|
|
21462
21460
|
this.endWaiting();
|
|
21463
21461
|
}
|
|
21462
|
+
removeBrowserEventListeners() {
|
|
21463
|
+
var _this_stopListeningToVisibility, _this;
|
|
21464
|
+
window.removeEventListener("resize", this.handleWindowResize);
|
|
21465
|
+
window.removeEventListener("beforeunload", this.handleBeforeUnload);
|
|
21466
|
+
window.removeEventListener("keydown", this.handleKeyDown);
|
|
21467
|
+
null == (_this_stopListeningToVisibility = (_this = this).stopListeningToVisibility) || _this_stopListeningToVisibility.call(_this);
|
|
21468
|
+
this.stopListeningToVisibility = void 0;
|
|
21469
|
+
}
|
|
21464
21470
|
hideMySelf() {
|
|
21465
21471
|
html_hideElement(this.containerElement);
|
|
21466
21472
|
}
|
|
@@ -21532,6 +21538,7 @@ var __webpack_exports__ = {};
|
|
|
21532
21538
|
exc
|
|
21533
21539
|
});
|
|
21534
21540
|
} finally{
|
|
21541
|
+
this.removeBrowserEventListeners();
|
|
21535
21542
|
this.removeAllListeners();
|
|
21536
21543
|
this.built = this.submitted = false;
|
|
21537
21544
|
}
|
|
@@ -21813,7 +21820,22 @@ var __webpack_exports__ = {};
|
|
|
21813
21820
|
this.visuals.setLimitSeconds(limitSeconds);
|
|
21814
21821
|
}
|
|
21815
21822
|
constructor(options){
|
|
21816
|
-
super("Container", options), container_define_property(this, "visibility", document_visibility_default()()), container_define_property(this, "htmlElement", document.querySelector("html")), container_define_property(this, "visuals", void 0), container_define_property(this, "buttons", void 0), container_define_property(this, "resource", void 0), container_define_property(this, "form", void 0), container_define_property(this, "hasError", false), container_define_property(this, "submitted", false), container_define_property(this, "lastValidation", false), container_define_property(this, "containerElement", void 0), container_define_property(this, "built", false)
|
|
21823
|
+
super("Container", options), container_define_property(this, "visibility", document_visibility_default()()), container_define_property(this, "htmlElement", document.querySelector("html")), container_define_property(this, "visuals", void 0), container_define_property(this, "buttons", void 0), container_define_property(this, "resource", void 0), container_define_property(this, "form", void 0), container_define_property(this, "hasError", false), container_define_property(this, "submitted", false), container_define_property(this, "lastValidation", false), container_define_property(this, "containerElement", void 0), container_define_property(this, "built", false), container_define_property(this, "stopListeningToVisibility", void 0), container_define_property(this, "handleWindowResize", ()=>{
|
|
21824
|
+
if (this.built) this.emit("WINDOW_RESIZE", "container");
|
|
21825
|
+
}), container_define_property(this, "handleBeforeUnload", (e)=>{
|
|
21826
|
+
this.unload({
|
|
21827
|
+
e
|
|
21828
|
+
});
|
|
21829
|
+
}), container_define_property(this, "handleKeyDown", (e)=>{
|
|
21830
|
+
const element = e.target;
|
|
21831
|
+
const tagName = element.tagName;
|
|
21832
|
+
const isEditable = element.isContentEditable || "true" === element.contentEditable;
|
|
21833
|
+
if (!isEditable && tagName && "INPUT" !== tagName.toUpperCase() && "TEXTAREA" !== tagName.toUpperCase() && "Space" === e.code) {
|
|
21834
|
+
e.preventDefault();
|
|
21835
|
+
if (this.options.enablePause) this.visuals.pauseOrResume();
|
|
21836
|
+
else this.visuals.recordOrStop();
|
|
21837
|
+
}
|
|
21838
|
+
});
|
|
21817
21839
|
this.visuals = new wrappers_visuals(this, options);
|
|
21818
21840
|
this.buttons = new buttons(this, options);
|
|
21819
21841
|
this.resource = new src_resource(options);
|
package/dist/esm/index.js
CHANGED
|
@@ -3620,7 +3620,7 @@ const constants = {
|
|
|
3620
3620
|
}
|
|
3621
3621
|
};
|
|
3622
3622
|
var package_namespaceObject = {
|
|
3623
|
-
rE: "15.
|
|
3623
|
+
rE: "15.8.0"
|
|
3624
3624
|
};
|
|
3625
3625
|
function isAudioEnabled(options) {
|
|
3626
3626
|
return Boolean(options.audio.enabled);
|
|
@@ -6333,7 +6333,8 @@ class UserMedia extends util_Despot {
|
|
|
6333
6333
|
}
|
|
6334
6334
|
hasInvalidDimensions() {
|
|
6335
6335
|
if (!this.rawVisualUserMedia) return false;
|
|
6336
|
-
|
|
6336
|
+
const { videoWidth, videoHeight } = this.rawVisualUserMedia;
|
|
6337
|
+
return videoWidth > 0 && videoWidth < 3 || videoHeight > 0 && videoHeight < 3;
|
|
6337
6338
|
}
|
|
6338
6339
|
logEvent(eventType, params) {
|
|
6339
6340
|
this.options.logger.debug(`UserMedia: ... ${EVENT_ASCII} event ${eventType}: ${util_pretty(params)}`);
|
|
@@ -6658,13 +6659,16 @@ class Recorder extends util_Despot {
|
|
|
6658
6659
|
}
|
|
6659
6660
|
}
|
|
6660
6661
|
sendPings() {
|
|
6662
|
+
this.stopPings();
|
|
6661
6663
|
this.pingInterval = window.setInterval(()=>{
|
|
6662
6664
|
this.options.logger.debug("Recorder: pinging...");
|
|
6663
6665
|
this.writeStream(Buffer.from(""));
|
|
6664
6666
|
}, this.options.timeouts.pingInterval);
|
|
6665
6667
|
}
|
|
6666
6668
|
stopPings() {
|
|
6667
|
-
|
|
6669
|
+
if (void 0 === this.pingInterval) return;
|
|
6670
|
+
window.clearInterval(this.pingInterval);
|
|
6671
|
+
this.pingInterval = void 0;
|
|
6668
6672
|
}
|
|
6669
6673
|
onAudioSample(audioSample) {
|
|
6670
6674
|
this.samplesCount++;
|
|
@@ -6695,13 +6699,13 @@ class Recorder extends util_Despot {
|
|
|
6695
6699
|
}
|
|
6696
6700
|
}
|
|
6697
6701
|
clearRetryTimeout() {
|
|
6698
|
-
if (
|
|
6702
|
+
if (void 0 === this.retryTimeout) return;
|
|
6699
6703
|
this.options.logger.debug("Recorder: clearRetryTimeout()");
|
|
6700
6704
|
window.clearTimeout(this.retryTimeout);
|
|
6701
6705
|
this.retryTimeout = void 0;
|
|
6702
6706
|
}
|
|
6703
6707
|
clearConnectionTimeout() {
|
|
6704
|
-
if (
|
|
6708
|
+
if (void 0 === this.connectionTimeout) return;
|
|
6705
6709
|
this.options.logger.debug("Recorder: clearConnectionTimeout()");
|
|
6706
6710
|
window.clearTimeout(this.connectionTimeout);
|
|
6707
6711
|
this.connectionTimeout = void 0;
|
|
@@ -7026,19 +7030,23 @@ class Recorder extends util_Despot {
|
|
|
7026
7030
|
const characteristics = this.userMedia?.getCharacteristics();
|
|
7027
7031
|
this.options.logger.debug(`Recorder: userMediaErrorCallback(), name: ${err.name}, message: ${err.message} and Webcam characteristics: ${characteristics ? util_pretty(characteristics) : "none"}`);
|
|
7028
7032
|
const errorListeners = this.getListeners("ERROR");
|
|
7029
|
-
if (errorListeners?.length) {
|
|
7030
|
-
|
|
7031
|
-
|
|
7032
|
-
|
|
7033
|
-
|
|
7034
|
-
|
|
7035
|
-
|
|
7036
|
-
|
|
7037
|
-
|
|
7038
|
-
|
|
7039
|
-
|
|
7040
|
-
this.retryTimeout = window.setTimeout(
|
|
7041
|
-
|
|
7033
|
+
if (errorListeners?.length) if (err.name !== error_VideomailError.MEDIA_DEVICE_NOT_SUPPORTED) {
|
|
7034
|
+
const videomailError = error_createError({
|
|
7035
|
+
err,
|
|
7036
|
+
options: this.options,
|
|
7037
|
+
usedConstraints
|
|
7038
|
+
});
|
|
7039
|
+
this.emit("ERROR", {
|
|
7040
|
+
err: videomailError
|
|
7041
|
+
});
|
|
7042
|
+
} else {
|
|
7043
|
+
this.options.logger.debug(`Recorder: ignore user media error ${util_pretty(err)}`);
|
|
7044
|
+
this.retryTimeout = window.setTimeout(()=>{
|
|
7045
|
+
this.retryTimeout = void 0;
|
|
7046
|
+
this.loadUserMedia();
|
|
7047
|
+
}, this.options.timeouts.userMedia);
|
|
7048
|
+
}
|
|
7049
|
+
else if (this.unloaded) this.options.logger.debug(`Recorder: already unloaded. Not going to throw error ${util_pretty(err)}`);
|
|
7042
7050
|
else {
|
|
7043
7051
|
this.options.logger.debug(`Recorder: no error listeners attached but throwing error ${util_pretty(err)}`);
|
|
7044
7052
|
throw error_createError({
|
|
@@ -7258,7 +7266,8 @@ class Recorder extends util_Despot {
|
|
|
7258
7266
|
limitReached
|
|
7259
7267
|
});
|
|
7260
7268
|
this.loop?.complete();
|
|
7261
|
-
setTimeout(()=>{
|
|
7269
|
+
this.stopTimeout = window.setTimeout(()=>{
|
|
7270
|
+
this.stopTimeout = void 0;
|
|
7262
7271
|
this.stopTime = Date.now();
|
|
7263
7272
|
const videoType = this.replay.getVideoType();
|
|
7264
7273
|
if (!videoType) throw new Error("Unable to video record when no video type is defined.");
|
|
@@ -7307,6 +7316,9 @@ class Recorder extends util_Despot {
|
|
|
7307
7316
|
this.reset();
|
|
7308
7317
|
this.clearUserMediaTimeout();
|
|
7309
7318
|
this.clearConnectionTimeout();
|
|
7319
|
+
this.clearRetryTimeout();
|
|
7320
|
+
this.clearStopTimeout();
|
|
7321
|
+
this.stopPings();
|
|
7310
7322
|
this.connecting = false;
|
|
7311
7323
|
if (this.userMedia) this.userMedia.unloadRemainingEventListeners();
|
|
7312
7324
|
if (this.submitting) ;
|
|
@@ -7329,12 +7341,17 @@ class Recorder extends util_Despot {
|
|
|
7329
7341
|
}
|
|
7330
7342
|
}
|
|
7331
7343
|
clearUserMediaTimeout() {
|
|
7332
|
-
if (this.userMediaTimeout) {
|
|
7344
|
+
if (void 0 !== this.userMediaTimeout) {
|
|
7333
7345
|
this.options.logger.debug("Recorder: clearUserMediaTimeout()");
|
|
7334
7346
|
window.clearTimeout(this.userMediaTimeout);
|
|
7335
7347
|
this.userMediaTimeout = void 0;
|
|
7336
7348
|
}
|
|
7337
7349
|
}
|
|
7350
|
+
clearStopTimeout() {
|
|
7351
|
+
if (void 0 === this.stopTimeout) return;
|
|
7352
|
+
window.clearTimeout(this.stopTimeout);
|
|
7353
|
+
this.stopTimeout = void 0;
|
|
7354
|
+
}
|
|
7338
7355
|
validate() {
|
|
7339
7356
|
return this.connected && void 0 === this.canvas;
|
|
7340
7357
|
}
|
|
@@ -7710,7 +7727,7 @@ class Recorder extends util_Despot {
|
|
|
7710
7727
|
return this.userMediaLoaded;
|
|
7711
7728
|
}
|
|
7712
7729
|
constructor(visuals, replay, options){
|
|
7713
|
-
super("Recorder", options), recorder_define_property(this, "visuals", void 0), recorder_define_property(this, "replay", void 0), recorder_define_property(this, "loop", void 0), recorder_define_property(this, "originalAnimationFrameObject", void 0), recorder_define_property(this, "samplesCount", 0), recorder_define_property(this, "framesCount", 0), recorder_define_property(this, "recordingStats", void 0), recorder_define_property(this, "confirmedFrameNumber", 0), recorder_define_property(this, "confirmedSampleNumber", 0), recorder_define_property(this, "recorderElement", void 0), recorder_define_property(this, "userMedia", void 0), recorder_define_property(this, "userMediaTimeout", void 0), recorder_define_property(this, "retryTimeout", void 0), recorder_define_property(this, "connectionTimeout", void 0), recorder_define_property(this, "frameProgress", void 0), recorder_define_property(this, "sampleProgress", void 0), recorder_define_property(this, "canvas", void 0), recorder_define_property(this, "ctx", void 0), recorder_define_property(this, "userMediaLoaded", void 0), recorder_define_property(this, "userMediaLoading", false), recorder_define_property(this, "submitting", false), recorder_define_property(this, "unloaded", void 0), recorder_define_property(this, "stopTime", void 0), recorder_define_property(this, "stream", void 0), recorder_define_property(this, "connecting", false), recorder_define_property(this, "connected", false), recorder_define_property(this, "connectionFailed", false), recorder_define_property(this, "blocking", false), recorder_define_property(this, "built", false), recorder_define_property(this, "key", void 0), recorder_define_property(this, "waitingTime", void 0), recorder_define_property(this, "connectingStartedAt", void 0), recorder_define_property(this, "lastCloseEvent", void 0), recorder_define_property(this, "lastSocketError", void 0), recorder_define_property(this, "pingInterval", void 0), recorder_define_property(this, "frame", void 0), recorder_define_property(this, "recordingBuffer", void 0), recorder_define_property(this, "facingMode", void 0);
|
|
7730
|
+
super("Recorder", options), recorder_define_property(this, "visuals", void 0), recorder_define_property(this, "replay", void 0), recorder_define_property(this, "loop", void 0), recorder_define_property(this, "originalAnimationFrameObject", void 0), recorder_define_property(this, "samplesCount", 0), recorder_define_property(this, "framesCount", 0), recorder_define_property(this, "recordingStats", void 0), recorder_define_property(this, "confirmedFrameNumber", 0), recorder_define_property(this, "confirmedSampleNumber", 0), recorder_define_property(this, "recorderElement", void 0), recorder_define_property(this, "userMedia", void 0), recorder_define_property(this, "userMediaTimeout", void 0), recorder_define_property(this, "retryTimeout", void 0), recorder_define_property(this, "connectionTimeout", void 0), recorder_define_property(this, "stopTimeout", void 0), recorder_define_property(this, "frameProgress", void 0), recorder_define_property(this, "sampleProgress", void 0), recorder_define_property(this, "canvas", void 0), recorder_define_property(this, "ctx", void 0), recorder_define_property(this, "userMediaLoaded", void 0), recorder_define_property(this, "userMediaLoading", false), recorder_define_property(this, "submitting", false), recorder_define_property(this, "unloaded", void 0), recorder_define_property(this, "stopTime", void 0), recorder_define_property(this, "stream", void 0), recorder_define_property(this, "connecting", false), recorder_define_property(this, "connected", false), recorder_define_property(this, "connectionFailed", false), recorder_define_property(this, "blocking", false), recorder_define_property(this, "built", false), recorder_define_property(this, "key", void 0), recorder_define_property(this, "waitingTime", void 0), recorder_define_property(this, "connectingStartedAt", void 0), recorder_define_property(this, "lastCloseEvent", void 0), recorder_define_property(this, "lastSocketError", void 0), recorder_define_property(this, "pingInterval", void 0), recorder_define_property(this, "frame", void 0), recorder_define_property(this, "recordingBuffer", void 0), recorder_define_property(this, "facingMode", void 0);
|
|
7714
7731
|
this.visuals = visuals;
|
|
7715
7732
|
this.replay = replay;
|
|
7716
7733
|
this.facingMode = options.video.facingMode;
|
|
@@ -8351,18 +8368,11 @@ class Container extends util_Despot {
|
|
|
8351
8368
|
}
|
|
8352
8369
|
initEvents(playerOnly = false) {
|
|
8353
8370
|
this.options.logger.debug(`Container: initEvents (playerOnly = ${playerOnly})`);
|
|
8354
|
-
if (this.options.recalculateDimensionsOnWindowResize) window.addEventListener("resize",
|
|
8355
|
-
|
|
8356
|
-
this.emit("WINDOW_RESIZE", "container");
|
|
8357
|
-
});
|
|
8358
|
-
if (this.options.enableAutoUnload) window.addEventListener("beforeunload", (e)=>{
|
|
8359
|
-
this.unload({
|
|
8360
|
-
e
|
|
8361
|
-
});
|
|
8362
|
-
}, {
|
|
8371
|
+
if (this.options.recalculateDimensionsOnWindowResize) window.addEventListener("resize", this.handleWindowResize);
|
|
8372
|
+
if (this.options.enableAutoUnload) window.addEventListener("beforeunload", this.handleBeforeUnload, {
|
|
8363
8373
|
once: true
|
|
8364
8374
|
});
|
|
8365
|
-
if (!playerOnly) this.visibility.onChange((visible)=>{
|
|
8375
|
+
if (!playerOnly) this.stopListeningToVisibility = this.visibility.onChange((visible)=>{
|
|
8366
8376
|
if (this.built) if (visible) {
|
|
8367
8377
|
if (isAutoPauseEnabled(this.options) && this.isCountingDown()) this.resume();
|
|
8368
8378
|
this.emit("VISIBLE");
|
|
@@ -8372,19 +8382,7 @@ class Container extends util_Despot {
|
|
|
8372
8382
|
}
|
|
8373
8383
|
});
|
|
8374
8384
|
if (this.options.enableSpace) {
|
|
8375
|
-
if (!playerOnly) window.addEventListener("keydown",
|
|
8376
|
-
const element = e.target;
|
|
8377
|
-
const tagName = element.tagName;
|
|
8378
|
-
const isEditable = element.isContentEditable || "true" === element.contentEditable;
|
|
8379
|
-
if (!isEditable && tagName && "INPUT" !== tagName.toUpperCase() && "TEXTAREA" !== tagName.toUpperCase()) {
|
|
8380
|
-
const code = e.code;
|
|
8381
|
-
if ("Space" === code) {
|
|
8382
|
-
e.preventDefault();
|
|
8383
|
-
if (this.options.enablePause) this.visuals.pauseOrResume();
|
|
8384
|
-
else this.visuals.recordOrStop();
|
|
8385
|
-
}
|
|
8386
|
-
}
|
|
8387
|
-
});
|
|
8385
|
+
if (!playerOnly) window.addEventListener("keydown", this.handleKeyDown);
|
|
8388
8386
|
}
|
|
8389
8387
|
this.on("ERROR", (params)=>{
|
|
8390
8388
|
this.processError(params);
|
|
@@ -8421,6 +8419,13 @@ class Container extends util_Despot {
|
|
|
8421
8419
|
}
|
|
8422
8420
|
this.endWaiting();
|
|
8423
8421
|
}
|
|
8422
|
+
removeBrowserEventListeners() {
|
|
8423
|
+
window.removeEventListener("resize", this.handleWindowResize);
|
|
8424
|
+
window.removeEventListener("beforeunload", this.handleBeforeUnload);
|
|
8425
|
+
window.removeEventListener("keydown", this.handleKeyDown);
|
|
8426
|
+
this.stopListeningToVisibility?.();
|
|
8427
|
+
this.stopListeningToVisibility = void 0;
|
|
8428
|
+
}
|
|
8424
8429
|
hideMySelf() {
|
|
8425
8430
|
html_hideElement(this.containerElement);
|
|
8426
8431
|
}
|
|
@@ -8487,6 +8492,7 @@ class Container extends util_Despot {
|
|
|
8487
8492
|
exc
|
|
8488
8493
|
});
|
|
8489
8494
|
} finally{
|
|
8495
|
+
this.removeBrowserEventListeners();
|
|
8490
8496
|
this.removeAllListeners();
|
|
8491
8497
|
this.built = this.submitted = false;
|
|
8492
8498
|
}
|
|
@@ -8756,7 +8762,22 @@ class Container extends util_Despot {
|
|
|
8756
8762
|
this.visuals.setLimitSeconds(limitSeconds);
|
|
8757
8763
|
}
|
|
8758
8764
|
constructor(options){
|
|
8759
|
-
super("Container", options), container_define_property(this, "visibility", document_visibility()), container_define_property(this, "htmlElement", document.querySelector("html")), container_define_property(this, "visuals", void 0), container_define_property(this, "buttons", void 0), container_define_property(this, "resource", void 0), container_define_property(this, "form", void 0), container_define_property(this, "hasError", false), container_define_property(this, "submitted", false), container_define_property(this, "lastValidation", false), container_define_property(this, "containerElement", void 0), container_define_property(this, "built", false)
|
|
8765
|
+
super("Container", options), container_define_property(this, "visibility", document_visibility()), container_define_property(this, "htmlElement", document.querySelector("html")), container_define_property(this, "visuals", void 0), container_define_property(this, "buttons", void 0), container_define_property(this, "resource", void 0), container_define_property(this, "form", void 0), container_define_property(this, "hasError", false), container_define_property(this, "submitted", false), container_define_property(this, "lastValidation", false), container_define_property(this, "containerElement", void 0), container_define_property(this, "built", false), container_define_property(this, "stopListeningToVisibility", void 0), container_define_property(this, "handleWindowResize", ()=>{
|
|
8766
|
+
if (this.built) this.emit("WINDOW_RESIZE", "container");
|
|
8767
|
+
}), container_define_property(this, "handleBeforeUnload", (e)=>{
|
|
8768
|
+
this.unload({
|
|
8769
|
+
e
|
|
8770
|
+
});
|
|
8771
|
+
}), container_define_property(this, "handleKeyDown", (e)=>{
|
|
8772
|
+
const element = e.target;
|
|
8773
|
+
const tagName = element.tagName;
|
|
8774
|
+
const isEditable = element.isContentEditable || "true" === element.contentEditable;
|
|
8775
|
+
if (!isEditable && tagName && "INPUT" !== tagName.toUpperCase() && "TEXTAREA" !== tagName.toUpperCase() && "Space" === e.code) {
|
|
8776
|
+
e.preventDefault();
|
|
8777
|
+
if (this.options.enablePause) this.visuals.pauseOrResume();
|
|
8778
|
+
else this.visuals.recordOrStop();
|
|
8779
|
+
}
|
|
8780
|
+
});
|
|
8760
8781
|
this.visuals = new wrappers_visuals(this, options);
|
|
8761
8782
|
this.buttons = new buttons(this, options);
|
|
8762
8783
|
this.resource = new src_resource(options);
|
|
@@ -28,6 +28,10 @@ declare class Container extends Despot {
|
|
|
28
28
|
private lastValidation;
|
|
29
29
|
private containerElement?;
|
|
30
30
|
private built;
|
|
31
|
+
private stopListeningToVisibility?;
|
|
32
|
+
private readonly handleWindowResize;
|
|
33
|
+
private readonly handleBeforeUnload;
|
|
34
|
+
private readonly handleKeyDown;
|
|
31
35
|
constructor(options: VideomailClientOptions);
|
|
32
36
|
private buildChildren;
|
|
33
37
|
build(buildOptions?: BuildOptions): HTMLElement | null | undefined;
|
|
@@ -39,6 +43,7 @@ declare class Container extends Despot {
|
|
|
39
43
|
private correctDimensions;
|
|
40
44
|
private removeDimensions;
|
|
41
45
|
private unloadChildren;
|
|
46
|
+
private removeBrowserEventListeners;
|
|
42
47
|
private hideMySelf;
|
|
43
48
|
private submitVideomail;
|
|
44
49
|
limitWidth(width?: number): import("../types/dimension.js").Dimension | undefined;
|
|
@@ -26,6 +26,7 @@ declare class Recorder extends Despot {
|
|
|
26
26
|
private userMediaTimeout?;
|
|
27
27
|
private retryTimeout?;
|
|
28
28
|
private connectionTimeout?;
|
|
29
|
+
private stopTimeout?;
|
|
29
30
|
private frameProgress?;
|
|
30
31
|
private sampleProgress?;
|
|
31
32
|
private canvas?;
|
|
@@ -88,6 +89,7 @@ declare class Recorder extends Despot {
|
|
|
88
89
|
unload(params?: UnloadParams): void;
|
|
89
90
|
reset(): void;
|
|
90
91
|
private clearUserMediaTimeout;
|
|
92
|
+
private clearStopTimeout;
|
|
91
93
|
validate(): boolean;
|
|
92
94
|
isReady(): boolean | undefined;
|
|
93
95
|
pause(params?: PauseParams): void;
|
package/dist/umd/index.js
CHANGED
|
@@ -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.
|
|
10981
|
+
rE: "15.8.0"
|
|
10982
10982
|
};
|
|
10983
10983
|
function isAudioEnabled(options) {
|
|
10984
10984
|
return Boolean(options.audio.enabled);
|
|
@@ -19062,7 +19062,8 @@
|
|
|
19062
19062
|
}
|
|
19063
19063
|
hasInvalidDimensions() {
|
|
19064
19064
|
if (!this.rawVisualUserMedia) return false;
|
|
19065
|
-
|
|
19065
|
+
const { videoWidth, videoHeight } = this.rawVisualUserMedia;
|
|
19066
|
+
return videoWidth > 0 && videoWidth < 3 || videoHeight > 0 && videoHeight < 3;
|
|
19066
19067
|
}
|
|
19067
19068
|
logEvent(eventType, params) {
|
|
19068
19069
|
this.options.logger.debug(`UserMedia: ... ${EVENT_ASCII} event ${eventType}: ${util_pretty(params)}`);
|
|
@@ -19332,6 +19333,7 @@
|
|
|
19332
19333
|
userMediaTimeout;
|
|
19333
19334
|
retryTimeout;
|
|
19334
19335
|
connectionTimeout;
|
|
19336
|
+
stopTimeout;
|
|
19335
19337
|
frameProgress;
|
|
19336
19338
|
sampleProgress;
|
|
19337
19339
|
canvas;
|
|
@@ -19406,13 +19408,16 @@
|
|
|
19406
19408
|
}
|
|
19407
19409
|
}
|
|
19408
19410
|
sendPings() {
|
|
19411
|
+
this.stopPings();
|
|
19409
19412
|
this.pingInterval = window.setInterval(()=>{
|
|
19410
19413
|
this.options.logger.debug("Recorder: pinging...");
|
|
19411
19414
|
this.writeStream(Buffer.from(""));
|
|
19412
19415
|
}, this.options.timeouts.pingInterval);
|
|
19413
19416
|
}
|
|
19414
19417
|
stopPings() {
|
|
19415
|
-
|
|
19418
|
+
if (void 0 === this.pingInterval) return;
|
|
19419
|
+
window.clearInterval(this.pingInterval);
|
|
19420
|
+
this.pingInterval = void 0;
|
|
19416
19421
|
}
|
|
19417
19422
|
onAudioSample(audioSample) {
|
|
19418
19423
|
this.samplesCount++;
|
|
@@ -19443,13 +19448,13 @@
|
|
|
19443
19448
|
}
|
|
19444
19449
|
}
|
|
19445
19450
|
clearRetryTimeout() {
|
|
19446
|
-
if (
|
|
19451
|
+
if (void 0 === this.retryTimeout) return;
|
|
19447
19452
|
this.options.logger.debug("Recorder: clearRetryTimeout()");
|
|
19448
19453
|
window.clearTimeout(this.retryTimeout);
|
|
19449
19454
|
this.retryTimeout = void 0;
|
|
19450
19455
|
}
|
|
19451
19456
|
clearConnectionTimeout() {
|
|
19452
|
-
if (
|
|
19457
|
+
if (void 0 === this.connectionTimeout) return;
|
|
19453
19458
|
this.options.logger.debug("Recorder: clearConnectionTimeout()");
|
|
19454
19459
|
window.clearTimeout(this.connectionTimeout);
|
|
19455
19460
|
this.connectionTimeout = void 0;
|
|
@@ -19774,19 +19779,23 @@
|
|
|
19774
19779
|
const characteristics = this.userMedia?.getCharacteristics();
|
|
19775
19780
|
this.options.logger.debug(`Recorder: userMediaErrorCallback(), name: ${err.name}, message: ${err.message} and Webcam characteristics: ${characteristics ? util_pretty(characteristics) : "none"}`);
|
|
19776
19781
|
const errorListeners = this.getListeners("ERROR");
|
|
19777
|
-
if (errorListeners?.length) {
|
|
19778
|
-
|
|
19779
|
-
|
|
19780
|
-
|
|
19781
|
-
|
|
19782
|
-
|
|
19783
|
-
|
|
19784
|
-
|
|
19785
|
-
|
|
19786
|
-
|
|
19787
|
-
|
|
19788
|
-
this.retryTimeout = window.setTimeout(
|
|
19789
|
-
|
|
19782
|
+
if (errorListeners?.length) if (err.name !== error_VideomailError.MEDIA_DEVICE_NOT_SUPPORTED) {
|
|
19783
|
+
const videomailError = error_createError({
|
|
19784
|
+
err,
|
|
19785
|
+
options: this.options,
|
|
19786
|
+
usedConstraints
|
|
19787
|
+
});
|
|
19788
|
+
this.emit("ERROR", {
|
|
19789
|
+
err: videomailError
|
|
19790
|
+
});
|
|
19791
|
+
} else {
|
|
19792
|
+
this.options.logger.debug(`Recorder: ignore user media error ${util_pretty(err)}`);
|
|
19793
|
+
this.retryTimeout = window.setTimeout(()=>{
|
|
19794
|
+
this.retryTimeout = void 0;
|
|
19795
|
+
this.loadUserMedia();
|
|
19796
|
+
}, this.options.timeouts.userMedia);
|
|
19797
|
+
}
|
|
19798
|
+
else if (this.unloaded) this.options.logger.debug(`Recorder: already unloaded. Not going to throw error ${util_pretty(err)}`);
|
|
19790
19799
|
else {
|
|
19791
19800
|
this.options.logger.debug(`Recorder: no error listeners attached but throwing error ${util_pretty(err)}`);
|
|
19792
19801
|
throw error_createError({
|
|
@@ -20006,7 +20015,8 @@
|
|
|
20006
20015
|
limitReached
|
|
20007
20016
|
});
|
|
20008
20017
|
this.loop?.complete();
|
|
20009
|
-
setTimeout(()=>{
|
|
20018
|
+
this.stopTimeout = window.setTimeout(()=>{
|
|
20019
|
+
this.stopTimeout = void 0;
|
|
20010
20020
|
this.stopTime = Date.now();
|
|
20011
20021
|
const videoType = this.replay.getVideoType();
|
|
20012
20022
|
if (!videoType) throw new Error("Unable to video record when no video type is defined.");
|
|
@@ -20055,6 +20065,9 @@
|
|
|
20055
20065
|
this.reset();
|
|
20056
20066
|
this.clearUserMediaTimeout();
|
|
20057
20067
|
this.clearConnectionTimeout();
|
|
20068
|
+
this.clearRetryTimeout();
|
|
20069
|
+
this.clearStopTimeout();
|
|
20070
|
+
this.stopPings();
|
|
20058
20071
|
this.connecting = false;
|
|
20059
20072
|
if (this.userMedia) this.userMedia.unloadRemainingEventListeners();
|
|
20060
20073
|
if (this.submitting) ;
|
|
@@ -20077,12 +20090,17 @@
|
|
|
20077
20090
|
}
|
|
20078
20091
|
}
|
|
20079
20092
|
clearUserMediaTimeout() {
|
|
20080
|
-
if (this.userMediaTimeout) {
|
|
20093
|
+
if (void 0 !== this.userMediaTimeout) {
|
|
20081
20094
|
this.options.logger.debug("Recorder: clearUserMediaTimeout()");
|
|
20082
20095
|
window.clearTimeout(this.userMediaTimeout);
|
|
20083
20096
|
this.userMediaTimeout = void 0;
|
|
20084
20097
|
}
|
|
20085
20098
|
}
|
|
20099
|
+
clearStopTimeout() {
|
|
20100
|
+
if (void 0 === this.stopTimeout) return;
|
|
20101
|
+
window.clearTimeout(this.stopTimeout);
|
|
20102
|
+
this.stopTimeout = void 0;
|
|
20103
|
+
}
|
|
20086
20104
|
validate() {
|
|
20087
20105
|
return this.connected && void 0 === this.canvas;
|
|
20088
20106
|
}
|
|
@@ -21011,6 +21029,25 @@
|
|
|
21011
21029
|
lastValidation = false;
|
|
21012
21030
|
containerElement;
|
|
21013
21031
|
built = false;
|
|
21032
|
+
stopListeningToVisibility;
|
|
21033
|
+
handleWindowResize = ()=>{
|
|
21034
|
+
if (this.built) this.emit("WINDOW_RESIZE", "container");
|
|
21035
|
+
};
|
|
21036
|
+
handleBeforeUnload = (e)=>{
|
|
21037
|
+
this.unload({
|
|
21038
|
+
e
|
|
21039
|
+
});
|
|
21040
|
+
};
|
|
21041
|
+
handleKeyDown = (e)=>{
|
|
21042
|
+
const element = e.target;
|
|
21043
|
+
const tagName = element.tagName;
|
|
21044
|
+
const isEditable = element.isContentEditable || "true" === element.contentEditable;
|
|
21045
|
+
if (!isEditable && tagName && "INPUT" !== tagName.toUpperCase() && "TEXTAREA" !== tagName.toUpperCase() && "Space" === e.code) {
|
|
21046
|
+
e.preventDefault();
|
|
21047
|
+
if (this.options.enablePause) this.visuals.pauseOrResume();
|
|
21048
|
+
else this.visuals.recordOrStop();
|
|
21049
|
+
}
|
|
21050
|
+
};
|
|
21014
21051
|
constructor(options){
|
|
21015
21052
|
super("Container", options);
|
|
21016
21053
|
this.visuals = new wrappers_visuals(this, options);
|
|
@@ -21093,18 +21130,11 @@
|
|
|
21093
21130
|
}
|
|
21094
21131
|
initEvents(playerOnly = false) {
|
|
21095
21132
|
this.options.logger.debug(`Container: initEvents (playerOnly = ${playerOnly})`);
|
|
21096
|
-
if (this.options.recalculateDimensionsOnWindowResize) window.addEventListener("resize",
|
|
21097
|
-
|
|
21098
|
-
this.emit("WINDOW_RESIZE", "container");
|
|
21099
|
-
});
|
|
21100
|
-
if (this.options.enableAutoUnload) window.addEventListener("beforeunload", (e)=>{
|
|
21101
|
-
this.unload({
|
|
21102
|
-
e
|
|
21103
|
-
});
|
|
21104
|
-
}, {
|
|
21133
|
+
if (this.options.recalculateDimensionsOnWindowResize) window.addEventListener("resize", this.handleWindowResize);
|
|
21134
|
+
if (this.options.enableAutoUnload) window.addEventListener("beforeunload", this.handleBeforeUnload, {
|
|
21105
21135
|
once: true
|
|
21106
21136
|
});
|
|
21107
|
-
if (!playerOnly) this.visibility.onChange((visible)=>{
|
|
21137
|
+
if (!playerOnly) this.stopListeningToVisibility = this.visibility.onChange((visible)=>{
|
|
21108
21138
|
if (this.built) if (visible) {
|
|
21109
21139
|
if (isAutoPauseEnabled(this.options) && this.isCountingDown()) this.resume();
|
|
21110
21140
|
this.emit("VISIBLE");
|
|
@@ -21114,19 +21144,7 @@
|
|
|
21114
21144
|
}
|
|
21115
21145
|
});
|
|
21116
21146
|
if (this.options.enableSpace) {
|
|
21117
|
-
if (!playerOnly) window.addEventListener("keydown",
|
|
21118
|
-
const element = e.target;
|
|
21119
|
-
const tagName = element.tagName;
|
|
21120
|
-
const isEditable = element.isContentEditable || "true" === element.contentEditable;
|
|
21121
|
-
if (!isEditable && tagName && "INPUT" !== tagName.toUpperCase() && "TEXTAREA" !== tagName.toUpperCase()) {
|
|
21122
|
-
const code = e.code;
|
|
21123
|
-
if ("Space" === code) {
|
|
21124
|
-
e.preventDefault();
|
|
21125
|
-
if (this.options.enablePause) this.visuals.pauseOrResume();
|
|
21126
|
-
else this.visuals.recordOrStop();
|
|
21127
|
-
}
|
|
21128
|
-
}
|
|
21129
|
-
});
|
|
21147
|
+
if (!playerOnly) window.addEventListener("keydown", this.handleKeyDown);
|
|
21130
21148
|
}
|
|
21131
21149
|
this.on("ERROR", (params)=>{
|
|
21132
21150
|
this.processError(params);
|
|
@@ -21163,6 +21181,13 @@
|
|
|
21163
21181
|
}
|
|
21164
21182
|
this.endWaiting();
|
|
21165
21183
|
}
|
|
21184
|
+
removeBrowserEventListeners() {
|
|
21185
|
+
window.removeEventListener("resize", this.handleWindowResize);
|
|
21186
|
+
window.removeEventListener("beforeunload", this.handleBeforeUnload);
|
|
21187
|
+
window.removeEventListener("keydown", this.handleKeyDown);
|
|
21188
|
+
this.stopListeningToVisibility?.();
|
|
21189
|
+
this.stopListeningToVisibility = void 0;
|
|
21190
|
+
}
|
|
21166
21191
|
hideMySelf() {
|
|
21167
21192
|
html_hideElement(this.containerElement);
|
|
21168
21193
|
}
|
|
@@ -21229,6 +21254,7 @@
|
|
|
21229
21254
|
exc
|
|
21230
21255
|
});
|
|
21231
21256
|
} finally{
|
|
21257
|
+
this.removeBrowserEventListeners();
|
|
21232
21258
|
this.removeAllListeners();
|
|
21233
21259
|
this.built = this.submitted = false;
|
|
21234
21260
|
}
|