@mobilon-dev/chotto 0.3.107 → 0.3.109
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 +33 -0
- package/dist/chotto.css +1 -1
- package/dist/components/2_chatinput_elements/ButtonWabaTemplateSelector/ButtonWabaTemplateSelector.vue.js +32 -27
- package/dist/components/2_chatinput_elements/FileUploader/FileUploader.vue.js +1 -1
- package/dist/components/2_chatinput_elements/FileUploader/FileUploader.vue2.js +58 -54
- package/dist/components/2_chatinput_elements/WABAAttachmentSection/WABAAttachmentSection.vue.js +2 -2
- package/dist/components/2_chatinput_elements/WABAAttachmentSection/WABAAttachmentSection.vue2.js +55 -56
- package/dist/components/2_elements/AudioRecorder/AudioRecorder.vue.js +2 -2
- package/dist/components/2_elements/AudioRecorder/AudioRecorder.vue2.js +42 -35
- package/dist/components/2_elements/VideoRecorder/VideoRecorder.vue.js +2 -2
- package/dist/components/2_elements/VideoRecorder/VideoRecorder.vue2.js +29 -22
- package/dist/hooks/messages/useMessageHoverActions.js +9 -8
- package/dist/hooks/uploadFile/types.js +4 -0
- package/dist/hooks/uploadFile/uploadFile.js +12 -13
- package/dist/hooks/uploadFile/useChottoUploader.js +56 -0
- package/dist/index.js +157 -152
- package/dist/types/apps/data/messages.d.ts +197 -0
- package/dist/types/components/2_chatinput_elements/ButtonWabaTemplateSelector/ButtonWabaTemplateSelector.vue.d.ts +2 -0
- package/dist/types/components/2_chatinput_elements/FileUploader/FileUploader.vue.d.ts +11 -0
- package/dist/types/components/2_chatinput_elements/FileUploader/stories/FileUploader.stories.d.ts +2 -0
- package/dist/types/components/2_chatinput_elements/WABAAttachmentSection/WABAAttachmentSection.vue.d.ts +13 -1
- package/dist/types/components/2_chatinput_elements/WABAAttachmentSection/stories/WABAAttachmentSection.stories.d.ts +11 -1
- package/dist/types/components/2_elements/AudioRecorder/AudioRecorder.vue.d.ts +11 -0
- package/dist/types/components/2_elements/VideoRecorder/VideoRecorder.vue.d.ts +11 -0
- package/dist/types/hooks/messages/useMessageHoverActions.d.ts +2 -1
- package/dist/types/hooks/uploadFile/index.d.ts +2 -0
- package/dist/types/hooks/uploadFile/types.d.ts +12 -0
- package/dist/types/hooks/uploadFile/uploadFile.d.ts +2 -3
- package/dist/types/hooks/uploadFile/useChottoUploader.d.ts +16 -0
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { buildFilePreview as
|
|
3
|
-
import {
|
|
4
|
-
import { useMessageDraft as
|
|
1
|
+
import { defineComponent as D, inject as j, ref as t, computed as x, createElementBlock as v, openBlock as p, createCommentVNode as g, createElementVNode as l, toDisplayString as B, unref as C, normalizeClass as E } from "vue";
|
|
2
|
+
import { buildFilePreview as L } from "../../../hooks/uploadFile/generatePreview.js";
|
|
3
|
+
import { useChottoUploader as N } from "../../../hooks/uploadFile/useChottoUploader.js";
|
|
4
|
+
import { useMessageDraft as T } from "../../../hooks/useMessageDraft.js";
|
|
5
5
|
import "../../../hooks/useSearchModel.js";
|
|
6
6
|
import "../../../hooks/useTheme.js";
|
|
7
7
|
import "../../../hooks/useEmojiNative.js";
|
|
@@ -12,13 +12,13 @@ import "../../../locale/useLocale.js";
|
|
|
12
12
|
import "../../../node_modules/linkifyjs/dist/linkify.js";
|
|
13
13
|
import "../../../node_modules/linkify-string/dist/linkify-string.js";
|
|
14
14
|
import "../../../functions/parseMarkdown.js";
|
|
15
|
-
const
|
|
15
|
+
const V = { class: "audio-recorder__container" }, O = {
|
|
16
16
|
key: 0,
|
|
17
17
|
class: "audio-recorder__status"
|
|
18
|
-
},
|
|
18
|
+
}, P = {
|
|
19
19
|
key: 1,
|
|
20
20
|
class: "audio-recorder__recording-container"
|
|
21
|
-
},
|
|
21
|
+
}, q = { class: "audio-recorder__recording-time" }, le = /* @__PURE__ */ D({
|
|
22
22
|
__name: "AudioRecorder",
|
|
23
23
|
props: {
|
|
24
24
|
state: {
|
|
@@ -28,69 +28,76 @@ const T = { class: "audio-recorder__container" }, V = {
|
|
|
28
28
|
filebumpUrl: {
|
|
29
29
|
type: String,
|
|
30
30
|
default: null
|
|
31
|
+
},
|
|
32
|
+
uploader: {
|
|
33
|
+
type: Function,
|
|
34
|
+
default: void 0
|
|
31
35
|
}
|
|
32
36
|
},
|
|
33
|
-
setup(
|
|
34
|
-
const
|
|
35
|
-
let s = n.value < 10 ? "0" + n.value : n.value, e =
|
|
36
|
-
return s + ":" + e + ":" + o + ":" +
|
|
37
|
-
}),
|
|
38
|
-
|
|
37
|
+
setup(b) {
|
|
38
|
+
const U = j("chatAppId"), { getMessage: m, setMessageFile: A, setRecordingMessage: y } = T(U), R = t(), a = t(0), u = t(0), r = t(0), n = t(0), M = x(() => {
|
|
39
|
+
let s = n.value < 10 ? "0" + n.value : n.value, e = r.value < 10 ? "0" + r.value : r.value, o = u.value < 10 ? "0" + u.value : u.value, z = a.value < 10 ? "00" + a.value : a.value < 100 ? "0" + a.value : a.value;
|
|
40
|
+
return s + ":" + e + ":" + o + ":" + z;
|
|
41
|
+
}), d = t(""), c = t(!1), i = t(), f = t([]), k = t(), _ = b, { upload: h } = N({
|
|
42
|
+
uploader: () => _.uploader,
|
|
43
|
+
filebumpUrl: () => _.filebumpUrl
|
|
44
|
+
}), F = async () => {
|
|
45
|
+
if (!m().file && _.state == "active") {
|
|
39
46
|
const s = await navigator.mediaDevices.getUserMedia({ audio: !0, video: !1 });
|
|
40
|
-
|
|
41
|
-
a.value += 10, a.value == 1e3 && (a.value = 0,
|
|
42
|
-
}, 10),
|
|
47
|
+
R.value = setInterval(() => {
|
|
48
|
+
a.value += 10, a.value == 1e3 && (a.value = 0, u.value++, u.value == 60 && (u.value = 0, r.value++, r.value == 60 && (r.value = 0, n.value++)));
|
|
49
|
+
}, 10), y(!0), c.value = !0, i.value = new MediaRecorder(s), i.value.start(), i.value.ondataavailable = (e) => {
|
|
43
50
|
f.value.push(e.data);
|
|
44
51
|
};
|
|
45
52
|
}
|
|
46
|
-
}, F = () => {
|
|
47
|
-
w(), R.value = void 0;
|
|
48
53
|
}, I = () => {
|
|
54
|
+
w(), k.value = void 0;
|
|
55
|
+
}, S = () => {
|
|
49
56
|
i.value && (i.value.stop(), i.value.onstop = async () => {
|
|
50
57
|
const s = new File(f.value, "voicemessage.mp3", { type: "audio/*" }), e = URL.createObjectURL(s);
|
|
51
|
-
|
|
52
|
-
|
|
58
|
+
k.value = e, d.value = "uploading", await h(s, { kind: "audio" }).then((o) => {
|
|
59
|
+
d.value = o.status, o.status == "success" && A({
|
|
53
60
|
url: o.url,
|
|
54
61
|
name: o.name,
|
|
55
62
|
size: o.size,
|
|
56
63
|
type: o.type,
|
|
57
|
-
preview:
|
|
64
|
+
preview: L(o.name, o.preview)
|
|
58
65
|
});
|
|
59
66
|
});
|
|
60
67
|
}), w();
|
|
61
68
|
}, w = () => {
|
|
62
|
-
clearInterval(
|
|
69
|
+
clearInterval(R.value), a.value = 0, u.value = 0, r.value = 0, n.value = 0, y(!1), c.value = !1, i.value = void 0, f.value = [];
|
|
63
70
|
};
|
|
64
|
-
return (s, e) => (p(), v("div",
|
|
65
|
-
|
|
71
|
+
return (s, e) => (p(), v("div", V, [
|
|
72
|
+
d.value === "uploading" ? (p(), v("div", O, [...e[0] || (e[0] = [
|
|
66
73
|
l("span", null, "Загрузка файла...", -1)
|
|
67
|
-
])])) :
|
|
68
|
-
|
|
74
|
+
])])) : g("", !0),
|
|
75
|
+
c.value && d.value != "uploading" ? (p(), v("div", P, [
|
|
69
76
|
e[3] || (e[3] = l("span", { class: "audio-recorder__recording-icon pi pi-circle-fill" }, null, -1)),
|
|
70
77
|
l("button", {
|
|
71
78
|
class: "audio-recorder__button audio-recorder__button-record",
|
|
72
|
-
onClick:
|
|
79
|
+
onClick: I
|
|
73
80
|
}, [...e[1] || (e[1] = [
|
|
74
81
|
l("span", { class: "pi pi-trash" }, null, -1)
|
|
75
82
|
])]),
|
|
76
83
|
l("button", {
|
|
77
84
|
class: "audio-recorder__button audio-recorder__button-record",
|
|
78
|
-
onClick:
|
|
85
|
+
onClick: S
|
|
79
86
|
}, [...e[2] || (e[2] = [
|
|
80
87
|
l("div", { class: "audio-recorder__stop" }, null, -1)
|
|
81
88
|
])]),
|
|
82
|
-
l("span",
|
|
83
|
-
])) :
|
|
84
|
-
!
|
|
89
|
+
l("span", q, B(M.value), 1)
|
|
90
|
+
])) : g("", !0),
|
|
91
|
+
!c.value && d.value != "uploading" && !C(m)().isRecording ? (p(), v("button", {
|
|
85
92
|
key: 2,
|
|
86
|
-
class:
|
|
87
|
-
onClick:
|
|
93
|
+
class: E(["audio-recorder__button", { "audio-recorder__button-disabled": b.state == "disabled" || C(m)().file }]),
|
|
94
|
+
onClick: F
|
|
88
95
|
}, [...e[4] || (e[4] = [
|
|
89
96
|
l("span", { class: "pi pi-microphone" }, null, -1)
|
|
90
|
-
])], 2)) :
|
|
97
|
+
])], 2)) : g("", !0)
|
|
91
98
|
]));
|
|
92
99
|
}
|
|
93
100
|
});
|
|
94
101
|
export {
|
|
95
|
-
|
|
102
|
+
le as default
|
|
96
103
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import o from "./VideoRecorder.vue2.js";
|
|
2
2
|
/* empty css */
|
|
3
3
|
import r from "../../../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
-
const
|
|
4
|
+
const m = /* @__PURE__ */ r(o, [["__scopeId", "data-v-731d9314"]]);
|
|
5
5
|
export {
|
|
6
|
-
|
|
6
|
+
m as default
|
|
7
7
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { buildFilePreview as
|
|
3
|
-
import {
|
|
1
|
+
import { defineComponent as y, inject as b, ref as h, createElementBlock as r, openBlock as i, Fragment as k, createCommentVNode as n, unref as f, normalizeClass as F, createElementVNode as l } from "vue";
|
|
2
|
+
import { buildFilePreview as w } from "../../../hooks/uploadFile/generatePreview.js";
|
|
3
|
+
import { useChottoUploader as C } from "../../../hooks/uploadFile/useChottoUploader.js";
|
|
4
4
|
import { useMessageDraft as M } from "../../../hooks/useMessageDraft.js";
|
|
5
5
|
import "../../../hooks/useSearchModel.js";
|
|
6
6
|
import { useTheme as R } from "../../../hooks/useTheme.js";
|
|
@@ -13,13 +13,13 @@ import { useModalVideoRecorder as V } from "../../../hooks/modals/useVideoRecord
|
|
|
13
13
|
import "../../../node_modules/linkifyjs/dist/linkify.js";
|
|
14
14
|
import "../../../node_modules/linkify-string/dist/linkify-string.js";
|
|
15
15
|
import "../../../functions/parseMarkdown.js";
|
|
16
|
-
const
|
|
16
|
+
const U = {
|
|
17
17
|
key: 0,
|
|
18
18
|
class: "video-recorder__container"
|
|
19
19
|
}, z = {
|
|
20
20
|
key: 1,
|
|
21
21
|
class: "video-recorder__container"
|
|
22
|
-
},
|
|
22
|
+
}, K = /* @__PURE__ */ y({
|
|
23
23
|
__name: "VideoRecorder",
|
|
24
24
|
props: {
|
|
25
25
|
state: {
|
|
@@ -29,43 +29,50 @@ const C = {
|
|
|
29
29
|
filebumpUrl: {
|
|
30
30
|
type: String,
|
|
31
31
|
default: null
|
|
32
|
+
},
|
|
33
|
+
uploader: {
|
|
34
|
+
type: Function,
|
|
35
|
+
default: void 0
|
|
32
36
|
}
|
|
33
37
|
},
|
|
34
|
-
setup(
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
setup(d) {
|
|
39
|
+
const p = b("chatAppId"), { getMessage: s, setMessageFile: v, setRecordingMessage: m } = M(p), { getTheme: c } = R(p), o = h(""), a = d, { upload: g } = C({
|
|
40
|
+
uploader: () => a.uploader,
|
|
41
|
+
filebumpUrl: () => a.filebumpUrl
|
|
42
|
+
}), _ = async () => {
|
|
43
|
+
if (!s().file && a.state == "active") {
|
|
44
|
+
const u = c().theme ? c().theme : "";
|
|
38
45
|
await V(u).then(async (t) => {
|
|
39
|
-
t.videoFile && (o.value = "uploading",
|
|
40
|
-
|
|
46
|
+
t.videoFile && (o.value = "uploading", m(!0), await g(t.videoFile, { kind: "video" }).then((e) => {
|
|
47
|
+
m(!1), o.value = e.status, e.status == "success" && v({
|
|
41
48
|
url: e.url,
|
|
42
49
|
name: e.name,
|
|
43
50
|
size: e.size,
|
|
44
51
|
type: e.type,
|
|
45
|
-
preview:
|
|
52
|
+
preview: w(e.name, e.preview)
|
|
46
53
|
});
|
|
47
54
|
}));
|
|
48
55
|
});
|
|
49
56
|
}
|
|
50
57
|
};
|
|
51
|
-
return (u, t) => (i(), r(
|
|
52
|
-
f(s)().isRecording ?
|
|
58
|
+
return (u, t) => (i(), r(k, null, [
|
|
59
|
+
f(s)().isRecording ? n("", !0) : (i(), r("div", U, [
|
|
53
60
|
o.value != "uploading" ? (i(), r("button", {
|
|
54
61
|
key: 0,
|
|
55
|
-
class:
|
|
56
|
-
onClick:
|
|
62
|
+
class: F(["video-recorder__button", { "video-recorder__button-disabled": d.state == "disabled" || f(s)().file }]),
|
|
63
|
+
onClick: _
|
|
57
64
|
}, [...t[0] || (t[0] = [
|
|
58
|
-
|
|
59
|
-
])], 2)) :
|
|
65
|
+
l("span", { class: "pi pi-video" }, null, -1)
|
|
66
|
+
])], 2)) : n("", !0)
|
|
60
67
|
])),
|
|
61
68
|
o.value === "uploading" ? (i(), r("div", z, [...t[1] || (t[1] = [
|
|
62
|
-
|
|
63
|
-
|
|
69
|
+
l("div", { class: "video-recorder__status" }, [
|
|
70
|
+
l("span", null, "Загрузка файла...")
|
|
64
71
|
], -1)
|
|
65
|
-
])])) :
|
|
72
|
+
])])) : n("", !0)
|
|
66
73
|
], 64));
|
|
67
74
|
}
|
|
68
75
|
});
|
|
69
76
|
export {
|
|
70
|
-
|
|
77
|
+
K as default
|
|
71
78
|
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { computed as
|
|
1
|
+
import { computed as r, toValue as t } from "vue";
|
|
2
2
|
import { isSmsFeedMessage as c } from "../../functions/isSmsChannel.js";
|
|
3
|
-
function
|
|
4
|
-
const o =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
function f(s, n = !0, i = void 0) {
|
|
4
|
+
const o = r(() => {
|
|
5
|
+
const e = t(i);
|
|
6
|
+
return (e == null ? void 0 : e.deleted) === !0 ? !1 : !c(e, t(s));
|
|
7
|
+
}), u = r(
|
|
8
|
+
() => t(n) && o.value
|
|
8
9
|
);
|
|
9
|
-
return { hoverActionsEnabled: o, reactionsActive:
|
|
10
|
+
return { hoverActionsEnabled: o, reactionsActive: u };
|
|
10
11
|
}
|
|
11
12
|
export {
|
|
12
|
-
|
|
13
|
+
f as useMessageHoverActions
|
|
13
14
|
};
|
|
@@ -1,28 +1,27 @@
|
|
|
1
|
-
import { generatePreview as
|
|
2
|
-
import { getTypeFileByMime as
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
const s = (o || "https://filebump2.services.mobilon.ru") + "/upload";
|
|
1
|
+
import { generatePreview as a } from "./generatePreview.js";
|
|
2
|
+
import { getTypeFileByMime as s } from "./getTypeFileByMime.js";
|
|
3
|
+
const m = async (e, r) => {
|
|
4
|
+
const o = new FormData();
|
|
5
|
+
o.append("file", r);
|
|
7
6
|
try {
|
|
8
7
|
return {
|
|
9
8
|
url: (await (await fetch(
|
|
10
|
-
|
|
9
|
+
e + "/upload",
|
|
11
10
|
{
|
|
12
11
|
method: "POST",
|
|
13
|
-
body:
|
|
12
|
+
body: o
|
|
14
13
|
}
|
|
15
14
|
)).json()).url,
|
|
16
15
|
name: r.name,
|
|
17
16
|
size: r.size,
|
|
18
|
-
type:
|
|
17
|
+
type: s(r.type),
|
|
19
18
|
status: "success",
|
|
20
|
-
preview:
|
|
19
|
+
preview: a(r)
|
|
21
20
|
};
|
|
22
|
-
} catch (
|
|
23
|
-
return console.error("Ошибка при загрузке файла:",
|
|
21
|
+
} catch (t) {
|
|
22
|
+
return console.error("Ошибка при загрузке файла:", t), { status: "error" };
|
|
24
23
|
}
|
|
25
24
|
};
|
|
26
25
|
export {
|
|
27
|
-
|
|
26
|
+
m as uploadFile
|
|
28
27
|
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { inject as u, toValue as i } from "vue";
|
|
2
|
+
import { generatePreview as f } from "./generatePreview.js";
|
|
3
|
+
import { getTypeFileByMime as c } from "./getTypeFileByMime.js";
|
|
4
|
+
import { chottoUploadFileKey as p } from "./types.js";
|
|
5
|
+
import { uploadFile as s } from "./uploadFile.js";
|
|
6
|
+
const d = "[chotto] Uploader is not provided and filebump-url is missing. Pass `uploader` prop, provide(chottoUploadFileKey), or `filebump-url`.";
|
|
7
|
+
function l(e, o = "file") {
|
|
8
|
+
return e instanceof File ? e : new File([e], o, { type: e.type });
|
|
9
|
+
}
|
|
10
|
+
function a(e, o) {
|
|
11
|
+
if (typeof e == "function") return e;
|
|
12
|
+
if (typeof o == "function") return o;
|
|
13
|
+
}
|
|
14
|
+
function m(e) {
|
|
15
|
+
return typeof e == "string" ? e.trim() : "";
|
|
16
|
+
}
|
|
17
|
+
function y(e, o) {
|
|
18
|
+
const t = o.filename || e.name || "file";
|
|
19
|
+
return {
|
|
20
|
+
url: o.url,
|
|
21
|
+
name: t,
|
|
22
|
+
size: e.size,
|
|
23
|
+
type: c(e.type),
|
|
24
|
+
status: "success",
|
|
25
|
+
preview: f(e)
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
async function U(e) {
|
|
29
|
+
const o = a(e.uploader, e.injectedUploader);
|
|
30
|
+
if (o)
|
|
31
|
+
try {
|
|
32
|
+
const r = await o(e.file, e.meta);
|
|
33
|
+
if (!(r != null && r.url))
|
|
34
|
+
return console.error("[chotto] Uploader returned no url"), { status: "error" };
|
|
35
|
+
const n = e.file instanceof File ? e.file : l(e.file, r.filename || "file");
|
|
36
|
+
return y(n, r);
|
|
37
|
+
} catch (r) {
|
|
38
|
+
return console.error("Ошибка при загрузке файла:", r), { status: "error" };
|
|
39
|
+
}
|
|
40
|
+
const t = m(e.filebumpUrl);
|
|
41
|
+
return t ? s(t, l(e.file)) : (console.error(d), { status: "error" });
|
|
42
|
+
}
|
|
43
|
+
function w(e) {
|
|
44
|
+
const o = u(p, void 0);
|
|
45
|
+
return { upload: (r, n) => U({
|
|
46
|
+
file: r,
|
|
47
|
+
meta: n,
|
|
48
|
+
uploader: e ? i(e.uploader) : void 0,
|
|
49
|
+
injectedUploader: o,
|
|
50
|
+
filebumpUrl: e ? i(e.filebumpUrl) : void 0
|
|
51
|
+
}) };
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
U as runChottoUpload,
|
|
55
|
+
w as useChottoUploader
|
|
56
|
+
};
|