videomail-client 15.11.0 → 16.0.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/README.md +45 -91
- package/dist/cjs/index.cjs +207 -87
- package/dist/esm/index.js +30 -10
- package/dist/esm/resource.d.ts +1 -2
- package/dist/esm/wrappers/container.d.ts +3 -1
- package/dist/umd/index.js +194 -86
- package/package.json +13 -13
package/dist/esm/index.js
CHANGED
|
@@ -3620,7 +3620,7 @@ const constants = {
|
|
|
3620
3620
|
}
|
|
3621
3621
|
};
|
|
3622
3622
|
var package_namespaceObject = {
|
|
3623
|
-
rE: "
|
|
3623
|
+
rE: "16.0.0"
|
|
3624
3624
|
};
|
|
3625
3625
|
function isAudioEnabled(options) {
|
|
3626
3626
|
return Boolean(options.audio.enabled);
|
|
@@ -4339,6 +4339,7 @@ class Form extends util_Despot {
|
|
|
4339
4339
|
this.options.logger.debug(`Form: doTheSubmit(${string_pretty(e)})`);
|
|
4340
4340
|
e.preventDefault();
|
|
4341
4341
|
} else this.options.logger.debug("Form: doTheSubmit()");
|
|
4342
|
+
const hasHostAction = this.formElement.hasAttribute("action");
|
|
4342
4343
|
const url = this.formElement.getAttribute("action") ?? this.options.apiUrl;
|
|
4343
4344
|
const method = this.formElement.getAttribute("method");
|
|
4344
4345
|
let chosenMethod;
|
|
@@ -4352,7 +4353,7 @@ class Form extends util_Despot {
|
|
|
4352
4353
|
default:
|
|
4353
4354
|
chosenMethod = FormMethod.POST;
|
|
4354
4355
|
}
|
|
4355
|
-
if (this.container.hasElement()) await this.container.submitAll(this.getData(), chosenMethod, url);
|
|
4356
|
+
if (this.container.hasElement()) await this.container.submitAll(this.getData(), chosenMethod, url, hasHostAction);
|
|
4356
4357
|
return false;
|
|
4357
4358
|
}
|
|
4358
4359
|
getInvalidElement() {
|
|
@@ -4640,7 +4641,7 @@ const options_options = {
|
|
|
4640
4641
|
audio: {
|
|
4641
4642
|
enabled: false,
|
|
4642
4643
|
switch: false,
|
|
4643
|
-
volume:
|
|
4644
|
+
volume: 1,
|
|
4644
4645
|
bufferSize: "auto"
|
|
4645
4646
|
},
|
|
4646
4647
|
video: {
|
|
@@ -6282,10 +6283,9 @@ class AudioRecorder {
|
|
|
6282
6283
|
});
|
|
6283
6284
|
volume.gain.value = this.options.audio.volume;
|
|
6284
6285
|
this.scriptProcessor = this.getAudioContext().createScriptProcessor(bufferSize, CHANNELS, CHANNELS);
|
|
6285
|
-
this.audioInput.connect(this.scriptProcessor);
|
|
6286
|
-
this.scriptProcessor.connect(this.getAudioContext().destination);
|
|
6287
6286
|
this.audioInput.connect(volume);
|
|
6288
6287
|
volume.connect(this.scriptProcessor);
|
|
6288
|
+
this.scriptProcessor.connect(this.getAudioContext().destination);
|
|
6289
6289
|
}
|
|
6290
6290
|
record(cb) {
|
|
6291
6291
|
this.options.logger.debug("AudioRecorder: record()");
|
|
@@ -8814,6 +8814,7 @@ class Container extends util_Despot {
|
|
|
8814
8814
|
this.removeBrowserEventListeners();
|
|
8815
8815
|
this.removeAllListeners();
|
|
8816
8816
|
this.built = this.submitted = false;
|
|
8817
|
+
this.pendingHostSubmission = void 0;
|
|
8817
8818
|
}
|
|
8818
8819
|
}
|
|
8819
8820
|
show(params) {
|
|
@@ -8849,6 +8850,7 @@ class Container extends util_Despot {
|
|
|
8849
8850
|
const keepHidden = params?.keepHidden;
|
|
8850
8851
|
this.options.logger.debug(`Container: startOver(keepHidden = ${keepHidden})`);
|
|
8851
8852
|
this.submitted = false;
|
|
8853
|
+
this.pendingHostSubmission = void 0;
|
|
8852
8854
|
const replay = this.getReplay();
|
|
8853
8855
|
replay.hide();
|
|
8854
8856
|
replay.reset();
|
|
@@ -8978,10 +8980,15 @@ class Container extends util_Despot {
|
|
|
8978
8980
|
buttonsAreReady() {
|
|
8979
8981
|
return this.buttons.isReady();
|
|
8980
8982
|
}
|
|
8981
|
-
|
|
8983
|
+
getPendingHostSubmissionResponse(key) {
|
|
8984
|
+
return this.pendingHostSubmission?.key === key ? this.pendingHostSubmission?.response : void 0;
|
|
8985
|
+
}
|
|
8986
|
+
async submitAll(formData, method, url, hasHostAction = false) {
|
|
8982
8987
|
let response;
|
|
8988
|
+
let hostResponse;
|
|
8989
|
+
const videomailKey = formData[this.options.selectors.keyInputName];
|
|
8983
8990
|
try {
|
|
8984
|
-
const hasVideomailKey = Boolean(
|
|
8991
|
+
const hasVideomailKey = Boolean(videomailKey);
|
|
8985
8992
|
if (!hasVideomailKey && !this.options.enableAutoSubmission) return;
|
|
8986
8993
|
const output = [
|
|
8987
8994
|
method,
|
|
@@ -8992,7 +8999,19 @@ class Container extends util_Despot {
|
|
|
8992
8999
|
if (this.options.disableFormWhenSubmitting) this.disableForm(true);
|
|
8993
9000
|
this.emit("SUBMITTING");
|
|
8994
9001
|
if (hasVideomailKey) {
|
|
8995
|
-
response = await this.submitVideomail(formData, method);
|
|
9002
|
+
response = this.getPendingHostSubmissionResponse(videomailKey) ?? await this.submitVideomail(formData, method);
|
|
9003
|
+
if (this.options.enableAutoSubmission && hasHostAction) {
|
|
9004
|
+
if (videomailKey) this.pendingHostSubmission = {
|
|
9005
|
+
key: videomailKey,
|
|
9006
|
+
response
|
|
9007
|
+
};
|
|
9008
|
+
const hostFormData = {
|
|
9009
|
+
...formData
|
|
9010
|
+
};
|
|
9011
|
+
if (this.options.submitWithVideomail) hostFormData.videomail = response.body.videomail;
|
|
9012
|
+
hostResponse = await this.resource.form(hostFormData, url);
|
|
9013
|
+
this.pendingHostSubmission = void 0;
|
|
9014
|
+
}
|
|
8996
9015
|
this.submitted = true;
|
|
8997
9016
|
this.emit("SUBMITTED", {
|
|
8998
9017
|
videomail: response.body.videomail,
|
|
@@ -9015,7 +9034,8 @@ class Container extends util_Despot {
|
|
|
9015
9034
|
err
|
|
9016
9035
|
});
|
|
9017
9036
|
} finally{
|
|
9018
|
-
|
|
9037
|
+
const finalResponse = hostResponse ?? response;
|
|
9038
|
+
if (finalResponse?.text && "text/html" === finalResponse.type) document.body.innerHTML = dompurify.sanitize(finalResponse.text);
|
|
9019
9039
|
this.endWaiting();
|
|
9020
9040
|
}
|
|
9021
9041
|
}
|
|
@@ -9081,7 +9101,7 @@ class Container extends util_Despot {
|
|
|
9081
9101
|
this.visuals.setLimitSeconds(limitSeconds);
|
|
9082
9102
|
}
|
|
9083
9103
|
constructor(options){
|
|
9084
|
-
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", ()=>{
|
|
9104
|
+
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, "pendingHostSubmission", void 0), 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", ()=>{
|
|
9085
9105
|
if (this.built) this.emit("WINDOW_RESIZE", "container");
|
|
9086
9106
|
}), container_define_property(this, "handleBeforeUnload", (e)=>{
|
|
9087
9107
|
this.unload({
|
package/dist/esm/resource.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { VideomailClientOptions } from "./types/options.js";
|
|
|
3
3
|
import { VideomailThread } from "./types/thread.js";
|
|
4
4
|
import { PartialVideomail, Videomail } from "./types/Videomail.js";
|
|
5
5
|
import VideomailError from "./util/error/VideomailError.js";
|
|
6
|
-
import { FormInputs } from "./wrappers/form.js";
|
|
7
6
|
declare class Resource {
|
|
8
7
|
private readonly options;
|
|
9
8
|
private readonly timezoneId;
|
|
@@ -19,6 +18,6 @@ declare class Resource {
|
|
|
19
18
|
reportError(err: VideomailError): Promise<void>;
|
|
20
19
|
post(videomail: PartialVideomail): Promise<Response>;
|
|
21
20
|
put(videomail: PartialVideomail): Promise<Response>;
|
|
22
|
-
form(formData:
|
|
21
|
+
form(formData: Record<string, unknown>, url: string): Promise<Response>;
|
|
23
22
|
}
|
|
24
23
|
export default Resource;
|
|
@@ -25,6 +25,7 @@ declare class Container extends Despot {
|
|
|
25
25
|
private form;
|
|
26
26
|
private hasError;
|
|
27
27
|
private submitted;
|
|
28
|
+
private pendingHostSubmission;
|
|
28
29
|
private lastValidation;
|
|
29
30
|
private containerElement?;
|
|
30
31
|
private built;
|
|
@@ -71,7 +72,8 @@ declare class Container extends Despot {
|
|
|
71
72
|
enableForm(buttonsToo: boolean): void;
|
|
72
73
|
hasForm(): boolean;
|
|
73
74
|
private buttonsAreReady;
|
|
74
|
-
|
|
75
|
+
private getPendingHostSubmissionResponse;
|
|
76
|
+
submitAll(formData: FormInputs, method: FormMethodType, url: string, hasHostAction?: boolean): Promise<void>;
|
|
75
77
|
isBuilt(): boolean;
|
|
76
78
|
isReplayShown(): boolean;
|
|
77
79
|
isDirty(): boolean;
|