@wexio/messenger-widget-react 1.4.0 → 1.5.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/CHANGELOG.md +127 -0
- package/README.md +2 -1
- package/dist/widget-react-3V_rXy9h2.js +2 -0
- package/dist/widget-react-3f61yzjR2.js +2 -0
- package/dist/widget-react-B-ZYj6cV2.js +2 -0
- package/dist/widget-react-B4Cru-SF.js +2 -0
- package/dist/widget-react-B5AYwhao.js +2 -0
- package/dist/widget-react-B6YWdHd3.js +2 -0
- package/dist/widget-react-BOjoaxsM2.js +2 -0
- package/dist/widget-react-BPFWT7Xe2.js +4 -0
- package/dist/widget-react-BSvxi-Z42.js +2 -0
- package/dist/widget-react-BbznnvpE2.js +2 -0
- package/dist/widget-react-Bebf7ovl.js +140 -0
- package/dist/widget-react-BrRmLgRl.js +163 -0
- package/dist/widget-react-BwK-nNjy2.js +2 -0
- package/dist/widget-react-BxEMz2N0.js +2 -0
- package/dist/widget-react-BzFUXA092.js +2 -0
- package/dist/widget-react-C-hnCqBf.js +2 -0
- package/dist/widget-react-C40Ha_9C.js +2 -0
- package/dist/widget-react-C7KHTFEo.js +2 -0
- package/dist/widget-react-CAfHMzrc2.js +2 -0
- package/dist/widget-react-CLJmIz_q.js +2 -0
- package/dist/widget-react-CLLhrdTm.js +2 -0
- package/dist/widget-react-CO7DyU51.js +201 -0
- package/dist/widget-react-CZoYXyup.js +2 -0
- package/dist/widget-react-C_NCNYY02.js +7 -0
- package/dist/widget-react-CnP2-ZB-.js +285 -0
- package/dist/widget-react-CuUeo68W.js +2 -0
- package/dist/widget-react-D2sqPDts.js +2 -0
- package/dist/widget-react-D5n4whHu2.js +2 -0
- package/dist/widget-react-D8W_ZdMH.js +2 -0
- package/dist/widget-react-DA0S6cIc.js +2 -0
- package/dist/widget-react-DE0LS-6-.js +2 -0
- package/dist/widget-react-DGh__emN.js +2 -0
- package/dist/widget-react-DIFOZ3QT.js +2 -0
- package/dist/widget-react-DJczk-Ax.js +2 -0
- package/dist/widget-react-DQJxxVB92.js +2 -0
- package/dist/widget-react-DS_ZoY1F.js +2 -0
- package/dist/widget-react-DUnaBOfT.js +10 -0
- package/dist/widget-react-DhLRmjli.js +2 -0
- package/dist/widget-react-Dl2PevZk.js +2 -0
- package/dist/widget-react-DmRVdLdI.js +2 -0
- package/dist/widget-react-DouawI6y.js +2 -0
- package/dist/widget-react-DozV7eMU2.js +2 -0
- package/dist/widget-react-Dpkdglv0.js +2 -0
- package/dist/widget-react-Dry9kqXE2.js +2 -0
- package/dist/widget-react-FX5W7RyV.js +4 -0
- package/dist/widget-react-G9X1DcTe.js +2 -0
- package/dist/widget-react-KAEA8ONo.js +2 -0
- package/dist/widget-react-Ov6re_Q9.js +2 -0
- package/dist/widget-react-XV6SIcqN2.js +2 -0
- package/dist/widget-react-XZ_nYDTj.js +2 -0
- package/dist/widget-react-oNTR-eNh.js +2 -0
- package/dist/widget-react-txPtcpni.js +2 -0
- package/dist/widget-react-zZBDvBBt2.js +2 -0
- package/dist/widget-react.js +50 -36283
- package/dist/widget-react.licenses.txt +3604 -0
- package/package.json +1 -1
- package/dist/widget-react--IUy5lNt.js +0 -510
- package/dist/widget-react-B7es3n1-.js +0 -32
- package/dist/widget-react-BAUpSGhZ.js +0 -1345
- package/dist/widget-react-BS9kUSRS.js +0 -255
- package/dist/widget-react-BT30ojz0.js +0 -371
- package/dist/widget-react-BXf2Ty8d.js +0 -364
- package/dist/widget-react-BgALABDe.js +0 -39
- package/dist/widget-react-BgunakAG.js +0 -566
- package/dist/widget-react-BkXA6ytR.js +0 -23856
- package/dist/widget-react-Bvtklo8g.js +0 -356
- package/dist/widget-react-BxEjM2it.js +0 -118
- package/dist/widget-react-CN_FIvMD.js +0 -834
- package/dist/widget-react-CTdz_dwX.js +0 -306
- package/dist/widget-react-Ck8JAYqT.js +0 -22122
- package/dist/widget-react-CyAVDflZ.js +0 -273
- package/dist/widget-react-DSAyUf2U.js +0 -229
- package/dist/widget-react-DbOJZl9F.js +0 -4932
- package/dist/widget-react-DgIxSjv7.js +0 -25
- package/dist/widget-react-Ds5J9FbQ.js +0 -27
- package/dist/widget-react-SI7deQTE.js +0 -35
- package/dist/widget-react-krPPnv02.js +0 -4438
- package/dist/widget-react-wSc9gIfG.js +0 -198
package/package.json
CHANGED
|
@@ -1,510 +0,0 @@
|
|
|
1
|
-
globalThis.process === void 0 && (globalThis.process = {
|
|
2
|
-
env: {},
|
|
3
|
-
nextTick: function(e) {
|
|
4
|
-
setTimeout(e, 0);
|
|
5
|
-
},
|
|
6
|
-
emit: function() {
|
|
7
|
-
return !1;
|
|
8
|
-
}
|
|
9
|
-
});
|
|
10
|
-
import "react";
|
|
11
|
-
import "react-dom";
|
|
12
|
-
import "react/jsx-runtime";
|
|
13
|
-
import "react-dom/client";
|
|
14
|
-
import { t as e } from "./widget-react-DbOJZl9F.js";
|
|
15
|
-
import { i as t, n, t as r } from "./widget-react-krPPnv02.js";
|
|
16
|
-
import { l as i, o as a, s as o } from "./widget-react-CN_FIvMD.js";
|
|
17
|
-
import { t as s } from "./widget-react-DgIxSjv7.js";
|
|
18
|
-
import { t as c } from "./widget-react-SI7deQTE.js";
|
|
19
|
-
import { t as l } from "./widget-react-BAUpSGhZ.js";
|
|
20
|
-
import { useEffect as u, useRef as d, useState as f } from "react";
|
|
21
|
-
import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
22
|
-
var g = r("square", [["rect", {
|
|
23
|
-
width: "18",
|
|
24
|
-
height: "18",
|
|
25
|
-
x: "3",
|
|
26
|
-
y: "3",
|
|
27
|
-
rx: "2",
|
|
28
|
-
key: "afitv7"
|
|
29
|
-
}]]);
|
|
30
|
-
//#endregion
|
|
31
|
-
//#region node_modules/wavesurfer.js/dist/plugins/record.esm.js
|
|
32
|
-
function _(e, t, n, r) {
|
|
33
|
-
return new (n || (n = Promise))((function(i, a) {
|
|
34
|
-
function o(e) {
|
|
35
|
-
try {
|
|
36
|
-
c(r.next(e));
|
|
37
|
-
} catch (e) {
|
|
38
|
-
a(e);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
function s(e) {
|
|
42
|
-
try {
|
|
43
|
-
c(r.throw(e));
|
|
44
|
-
} catch (e) {
|
|
45
|
-
a(e);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
function c(e) {
|
|
49
|
-
var t;
|
|
50
|
-
e.done ? i(e.value) : (t = e.value, t instanceof n ? t : new n((function(e) {
|
|
51
|
-
e(t);
|
|
52
|
-
}))).then(o, s);
|
|
53
|
-
}
|
|
54
|
-
c((r = r.apply(e, t || [])).next());
|
|
55
|
-
}));
|
|
56
|
-
}
|
|
57
|
-
var v = class {
|
|
58
|
-
constructor() {
|
|
59
|
-
this.listeners = {};
|
|
60
|
-
}
|
|
61
|
-
on(e, t, n) {
|
|
62
|
-
if (this.listeners[e] || (this.listeners[e] = /* @__PURE__ */ new Set()), n?.once) {
|
|
63
|
-
let n = (...r) => {
|
|
64
|
-
this.un(e, n), t(...r);
|
|
65
|
-
};
|
|
66
|
-
return this.listeners[e].add(n), () => this.un(e, n);
|
|
67
|
-
}
|
|
68
|
-
return this.listeners[e].add(t), () => this.un(e, t);
|
|
69
|
-
}
|
|
70
|
-
un(e, t) {
|
|
71
|
-
var n;
|
|
72
|
-
(n = this.listeners[e]) == null || n.delete(t);
|
|
73
|
-
}
|
|
74
|
-
once(e, t) {
|
|
75
|
-
return this.on(e, t, { once: !0 });
|
|
76
|
-
}
|
|
77
|
-
unAll() {
|
|
78
|
-
this.listeners = {};
|
|
79
|
-
}
|
|
80
|
-
emit(e, ...t) {
|
|
81
|
-
this.listeners[e] && this.listeners[e].forEach(((e) => e(...t)));
|
|
82
|
-
}
|
|
83
|
-
}, y = class extends v {
|
|
84
|
-
constructor(e) {
|
|
85
|
-
super(), this.subscriptions = [], this.isDestroyed = !1, this.options = e;
|
|
86
|
-
}
|
|
87
|
-
onInit() {}
|
|
88
|
-
_init(e) {
|
|
89
|
-
this.isDestroyed && (this.subscriptions = [], this.isDestroyed = !1), this.wavesurfer = e, this.onInit();
|
|
90
|
-
}
|
|
91
|
-
destroy() {
|
|
92
|
-
this.emit("destroy"), this.subscriptions.forEach(((e) => e())), this.subscriptions = [], this.isDestroyed = !0, this.wavesurfer = void 0;
|
|
93
|
-
}
|
|
94
|
-
}, b = class extends v {
|
|
95
|
-
constructor() {
|
|
96
|
-
super(...arguments), this.animationFrameId = null, this.isRunning = !1;
|
|
97
|
-
}
|
|
98
|
-
start() {
|
|
99
|
-
if (this.isRunning) return;
|
|
100
|
-
this.isRunning = !0;
|
|
101
|
-
let e = () => {
|
|
102
|
-
this.isRunning && (this.emit("tick"), this.animationFrameId = requestAnimationFrame(e));
|
|
103
|
-
};
|
|
104
|
-
e();
|
|
105
|
-
}
|
|
106
|
-
stop() {
|
|
107
|
-
this.isRunning = !1, this.animationFrameId !== null && (cancelAnimationFrame(this.animationFrameId), this.animationFrameId = null);
|
|
108
|
-
}
|
|
109
|
-
destroy() {
|
|
110
|
-
this.stop();
|
|
111
|
-
}
|
|
112
|
-
}, x = 100, S = [
|
|
113
|
-
"audio/webm",
|
|
114
|
-
"audio/wav",
|
|
115
|
-
"audio/mpeg",
|
|
116
|
-
"audio/mp4",
|
|
117
|
-
"audio/mp3"
|
|
118
|
-
], C = class e extends y {
|
|
119
|
-
constructor(e) {
|
|
120
|
-
var t, n, r;
|
|
121
|
-
super(Object.assign(Object.assign({}, e), {
|
|
122
|
-
audioBitsPerSecond: e.audioBitsPerSecond ?? 128e3,
|
|
123
|
-
scrollingWaveform: (t = e.scrollingWaveform) != null && t,
|
|
124
|
-
scrollingWaveformWindow: e.scrollingWaveformWindow ?? 5,
|
|
125
|
-
continuousWaveform: (n = e.continuousWaveform) != null && n,
|
|
126
|
-
renderRecordedAudio: (r = e.renderRecordedAudio) == null || r,
|
|
127
|
-
mediaRecorderTimeslice: e.mediaRecorderTimeslice ?? void 0
|
|
128
|
-
})), this.stream = null, this.mediaRecorder = null, this.dataWindow = null, this.isWaveformPaused = !1, this.lastStartTime = 0, this.lastDuration = 0, this.duration = 0, this.micStream = null, this.recordedBlobUrl = null, this.timer = new b(), this.subscriptions.push(this.timer.on("tick", (() => {
|
|
129
|
-
let e = performance.now() - this.lastStartTime;
|
|
130
|
-
this.duration = this.isPaused() ? this.duration : this.lastDuration + e, this.emit("record-progress", this.duration);
|
|
131
|
-
})));
|
|
132
|
-
}
|
|
133
|
-
static create(t) {
|
|
134
|
-
return new e(t || {});
|
|
135
|
-
}
|
|
136
|
-
renderMicStream(e) {
|
|
137
|
-
let t = new AudioContext(), n = t.createMediaStreamSource(e), r = t.createAnalyser();
|
|
138
|
-
n.connect(r), (this.options.continuousWaveform || this.options.scrollingWaveform) && (r.fftSize = 32);
|
|
139
|
-
let i = r.frequencyBinCount, a = new Float32Array(i), o = 0;
|
|
140
|
-
this.wavesurfer && (this.originalOptions ?? (this.originalOptions = Object.assign({}, this.wavesurfer.options)), this.wavesurfer.options.interact = !1, this.options.scrollingWaveform && (this.wavesurfer.options.cursorWidth = 0, this.wavesurfer.options.normalize = !0, this.wavesurfer.options.maxPeak = 1));
|
|
141
|
-
let s = setInterval((() => {
|
|
142
|
-
if (!this.isWaveformPaused) {
|
|
143
|
-
if (r.getFloatTimeDomainData(a), this.options.scrollingWaveform) {
|
|
144
|
-
let e = Math.floor((this.options.scrollingWaveformWindow || 0) * x), t = 0;
|
|
145
|
-
for (let e = 0; e < i; e++) {
|
|
146
|
-
let n = Math.abs(a[e]);
|
|
147
|
-
n > t && (t = n);
|
|
148
|
-
}
|
|
149
|
-
this.dataWindow || (this.dataWindow = new Float32Array(e));
|
|
150
|
-
let n = new Float32Array(e);
|
|
151
|
-
if (this.dataWindow && this.dataWindow.length > 0) {
|
|
152
|
-
let t = e - 1, r = this.dataWindow.slice(-t);
|
|
153
|
-
n.set(r, 0);
|
|
154
|
-
}
|
|
155
|
-
n[e - 1] = t, this.dataWindow = n;
|
|
156
|
-
} else if (this.options.continuousWaveform) {
|
|
157
|
-
if (!this.dataWindow) {
|
|
158
|
-
let e = this.options.continuousWaveformDuration ? Math.round(this.options.continuousWaveformDuration * x) : (this.wavesurfer?.getWidth() ?? 0) * window.devicePixelRatio;
|
|
159
|
-
this.dataWindow = new Float32Array(e);
|
|
160
|
-
}
|
|
161
|
-
let e = 0;
|
|
162
|
-
for (let t = 0; t < i; t++) {
|
|
163
|
-
let n = Math.abs(a[t]);
|
|
164
|
-
n > e && (e = n);
|
|
165
|
-
}
|
|
166
|
-
if (o + 1 > this.dataWindow.length) {
|
|
167
|
-
let e = new Float32Array(2 * this.dataWindow.length);
|
|
168
|
-
e.set(this.dataWindow, 0), this.dataWindow = e;
|
|
169
|
-
}
|
|
170
|
-
this.dataWindow[o] = e, o++;
|
|
171
|
-
} else this.dataWindow = a;
|
|
172
|
-
if (this.wavesurfer) {
|
|
173
|
-
let e = (this.dataWindow?.length ?? 0) / x;
|
|
174
|
-
this.wavesurfer.load("", [this.dataWindow], this.options.scrollingWaveform ? this.options.scrollingWaveformWindow : e).then((() => {
|
|
175
|
-
this.wavesurfer && this.options.continuousWaveform && (this.wavesurfer.setTime(this.getDuration() / 1e3), this.wavesurfer.options.minPxPerSec || this.wavesurfer.setOptions({ minPxPerSec: this.wavesurfer.getWidth() / this.wavesurfer.getDuration() }));
|
|
176
|
-
})).catch(((e) => {
|
|
177
|
-
console.error("Error rendering real-time recording data:", e);
|
|
178
|
-
}));
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}), 10);
|
|
182
|
-
return {
|
|
183
|
-
onDestroy: () => {
|
|
184
|
-
clearInterval(s), n?.disconnect(), t?.close();
|
|
185
|
-
},
|
|
186
|
-
onEnd: () => {
|
|
187
|
-
this.isWaveformPaused = !0, this.stopMic();
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
startMic(e) {
|
|
192
|
-
return _(this, void 0, void 0, (function* () {
|
|
193
|
-
let t;
|
|
194
|
-
this.micStream && this.stopMic();
|
|
195
|
-
try {
|
|
196
|
-
t = yield navigator.mediaDevices.getUserMedia({ audio: e == null || e });
|
|
197
|
-
} catch (e) {
|
|
198
|
-
throw Error("Error accessing the microphone: " + e.message);
|
|
199
|
-
}
|
|
200
|
-
let n = this.renderMicStream(t);
|
|
201
|
-
return this.micStream = n, this.unsubscribeDestroy = this.once("destroy", n.onDestroy), this.unsubscribeRecordEnd = this.once("record-end", n.onEnd), this.stream = t, t;
|
|
202
|
-
}));
|
|
203
|
-
}
|
|
204
|
-
stopMic() {
|
|
205
|
-
var e, t, n;
|
|
206
|
-
(e = this.micStream) == null || e.onDestroy(), (t = this.unsubscribeDestroy) == null || t.call(this), (n = this.unsubscribeRecordEnd) == null || n.call(this), this.micStream = null, this.unsubscribeDestroy = void 0, this.unsubscribeRecordEnd = void 0, this.stream && (this.stream.getTracks().forEach(((e) => e.stop())), this.stream = null, this.mediaRecorder = null);
|
|
207
|
-
}
|
|
208
|
-
startRecording(e) {
|
|
209
|
-
return _(this, void 0, void 0, (function* () {
|
|
210
|
-
let t = this.stream || (yield this.startMic(e));
|
|
211
|
-
this.dataWindow = null;
|
|
212
|
-
let n = this.mediaRecorder || new MediaRecorder(t, {
|
|
213
|
-
mimeType: this.options.mimeType || S.find(((e) => MediaRecorder.isTypeSupported(e))),
|
|
214
|
-
audioBitsPerSecond: this.options.audioBitsPerSecond
|
|
215
|
-
});
|
|
216
|
-
this.mediaRecorder = n, this.stopRecording();
|
|
217
|
-
let r = [];
|
|
218
|
-
n.ondataavailable = (e) => {
|
|
219
|
-
e.data.size > 0 && r.push(e.data), this.emit("record-data-available", e.data);
|
|
220
|
-
};
|
|
221
|
-
let i = (e) => {
|
|
222
|
-
var t;
|
|
223
|
-
let i = new Blob(r, { type: n.mimeType });
|
|
224
|
-
this.emit(e, i), this.options.renderRecordedAudio && (this.applyOriginalOptionsIfNeeded(), this.recordedBlobUrl && URL.revokeObjectURL(this.recordedBlobUrl), this.recordedBlobUrl = URL.createObjectURL(i), (t = this.wavesurfer) == null || t.load(this.recordedBlobUrl));
|
|
225
|
-
};
|
|
226
|
-
n.onpause = () => i("record-pause"), n.onstop = () => i("record-end"), n.start(this.options.mediaRecorderTimeslice), this.lastStartTime = performance.now(), this.lastDuration = 0, this.duration = 0, this.isWaveformPaused = !1, this.timer.start(), this.emit("record-start");
|
|
227
|
-
}));
|
|
228
|
-
}
|
|
229
|
-
getDuration() {
|
|
230
|
-
return this.duration;
|
|
231
|
-
}
|
|
232
|
-
isRecording() {
|
|
233
|
-
return this.mediaRecorder?.state === "recording";
|
|
234
|
-
}
|
|
235
|
-
isPaused() {
|
|
236
|
-
return this.mediaRecorder?.state === "paused";
|
|
237
|
-
}
|
|
238
|
-
isActive() {
|
|
239
|
-
return this.mediaRecorder?.state !== "inactive";
|
|
240
|
-
}
|
|
241
|
-
stopRecording() {
|
|
242
|
-
var e;
|
|
243
|
-
this.isActive() && ((e = this.mediaRecorder) == null || e.stop(), this.timer.stop());
|
|
244
|
-
}
|
|
245
|
-
pauseRecording() {
|
|
246
|
-
var e, t;
|
|
247
|
-
this.isRecording() && (this.isWaveformPaused = !0, (e = this.mediaRecorder) == null || e.requestData(), (t = this.mediaRecorder) == null || t.pause(), this.timer.stop(), this.lastDuration = this.duration);
|
|
248
|
-
}
|
|
249
|
-
resumeRecording() {
|
|
250
|
-
var e;
|
|
251
|
-
this.isPaused() && (this.isWaveformPaused = !1, (e = this.mediaRecorder) == null || e.resume(), this.timer.start(), this.lastStartTime = performance.now(), this.emit("record-resume"));
|
|
252
|
-
}
|
|
253
|
-
static getAvailableAudioDevices() {
|
|
254
|
-
return _(this, void 0, void 0, (function* () {
|
|
255
|
-
return navigator.mediaDevices.enumerateDevices().then(((e) => e.filter(((e) => e.kind === "audioinput"))));
|
|
256
|
-
}));
|
|
257
|
-
}
|
|
258
|
-
destroy() {
|
|
259
|
-
this.applyOriginalOptionsIfNeeded(), super.destroy(), this.stopRecording(), this.stopMic(), this.recordedBlobUrl && (URL.revokeObjectURL(this.recordedBlobUrl), this.recordedBlobUrl = null);
|
|
260
|
-
}
|
|
261
|
-
applyOriginalOptionsIfNeeded() {
|
|
262
|
-
this.wavesurfer && this.originalOptions && (this.wavesurfer.setOptions(this.originalOptions), delete this.originalOptions);
|
|
263
|
-
}
|
|
264
|
-
};
|
|
265
|
-
//#endregion
|
|
266
|
-
//#region components/widget/tabs/messages-tab/composer/voice-recorder-bar/helpers.ts
|
|
267
|
-
function w(e) {
|
|
268
|
-
let t = Math.max(0, e);
|
|
269
|
-
return `${Math.floor(t / 60)}:${(t % 60).toString().padStart(2, "0")}`;
|
|
270
|
-
}
|
|
271
|
-
function T() {
|
|
272
|
-
if (typeof MediaRecorder > "u") return null;
|
|
273
|
-
for (let e of [
|
|
274
|
-
"audio/webm;codecs=opus",
|
|
275
|
-
"audio/webm",
|
|
276
|
-
"audio/mp4",
|
|
277
|
-
"audio/ogg"
|
|
278
|
-
]) if (MediaRecorder.isTypeSupported?.(e)) return e;
|
|
279
|
-
return null;
|
|
280
|
-
}
|
|
281
|
-
async function E(e) {
|
|
282
|
-
return new Promise((t, n) => {
|
|
283
|
-
let r = new FileReader();
|
|
284
|
-
r.onload = () => {
|
|
285
|
-
let e = r.result;
|
|
286
|
-
if (typeof e != "string") {
|
|
287
|
-
n(/* @__PURE__ */ Error("FileReader returned non-string result"));
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
let i = e.indexOf(",");
|
|
291
|
-
t(i >= 0 ? e.slice(i + 1) : e);
|
|
292
|
-
}, r.onerror = () => n(r.error ?? /* @__PURE__ */ Error("read failed")), r.readAsDataURL(e);
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
//#endregion
|
|
296
|
-
//#region components/widget/tabs/messages-tab/composer/voice-recorder-bar/index.tsx
|
|
297
|
-
function D(e) {
|
|
298
|
-
let t = e?.name ?? "", n = e?.message ?? "";
|
|
299
|
-
return t === "NotAllowedError" || t === "PermissionDeniedError" ? "denied" : t === "NotFoundError" || t === "NotReadableError" || t === "OverconstrainedError" || t === "SecurityError" || t === "AbortError" || t === "TypeError" || /not found|could not start|secure origin|not readable|in use/i.test(n) ? "failed" : /permission|denied|not allowed/i.test(n) ? "denied" : "failed";
|
|
300
|
-
}
|
|
301
|
-
function O({ onComplete: r, onCancel: c, onError: _ }) {
|
|
302
|
-
let v = t("messages"), y = d(null), b = d(null), x = d(null), S = d(null), O = d([]), A = d(null), [j, M] = f("recording"), [N, P] = f(0), [F, I] = f(!1), L = d(null), R = d(!1);
|
|
303
|
-
return u(() => {
|
|
304
|
-
let e = y.current;
|
|
305
|
-
if (!e) return;
|
|
306
|
-
if (typeof window > "u" || !window.MediaRecorder) {
|
|
307
|
-
_("unsupported");
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
let t = !1;
|
|
311
|
-
R.current = !1;
|
|
312
|
-
let n = getComputedStyle(e), r = n.getPropertyValue("--wx-primary").trim() || "#5b6cff", i = n.getPropertyValue("--wx-fg-muted").trim() || "#6b7280", a = l.create({
|
|
313
|
-
container: e,
|
|
314
|
-
waveColor: i,
|
|
315
|
-
progressColor: r,
|
|
316
|
-
cursorColor: r,
|
|
317
|
-
cursorWidth: 2,
|
|
318
|
-
height: 32,
|
|
319
|
-
barWidth: 2,
|
|
320
|
-
barGap: 2,
|
|
321
|
-
barRadius: 2,
|
|
322
|
-
interact: !0,
|
|
323
|
-
hideScrollbar: !0
|
|
324
|
-
});
|
|
325
|
-
b.current = a, a.on("play", () => I(!0)), a.on("pause", () => I(!1)), a.on("finish", () => I(!1));
|
|
326
|
-
let o = a.registerPlugin(C.create({
|
|
327
|
-
continuousWaveform: !0,
|
|
328
|
-
continuousWaveformDuration: 60,
|
|
329
|
-
renderRecordedAudio: !1
|
|
330
|
-
}));
|
|
331
|
-
x.current = o;
|
|
332
|
-
let s = null, c = null;
|
|
333
|
-
return o.startMic().then((e) => {
|
|
334
|
-
if (t || R.current) {
|
|
335
|
-
try {
|
|
336
|
-
e.getTracks().forEach((e) => {
|
|
337
|
-
e.stop();
|
|
338
|
-
});
|
|
339
|
-
} catch {}
|
|
340
|
-
try {
|
|
341
|
-
o.stopMic();
|
|
342
|
-
} catch {}
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
let n = T(), r = n ? new MediaRecorder(e, { mimeType: n }) : new MediaRecorder(e);
|
|
346
|
-
S.current = r, c = r, O.current = [], r.addEventListener("dataavailable", (e) => {
|
|
347
|
-
e.data && e.data.size > 0 && O.current.push(e.data);
|
|
348
|
-
}), r.addEventListener("stop", () => {
|
|
349
|
-
if (t || R.current) return;
|
|
350
|
-
try {
|
|
351
|
-
o.stopMic();
|
|
352
|
-
} catch {}
|
|
353
|
-
s !== null && (clearInterval(s), s = null, A.current = null);
|
|
354
|
-
let e = r.mimeType || n || "audio/webm", i = new Blob(O.current, { type: e });
|
|
355
|
-
E(i).then((n) => {
|
|
356
|
-
if (t || R.current) return;
|
|
357
|
-
let r = e.includes("mp4") ? "mp4" : "webm";
|
|
358
|
-
L.current = {
|
|
359
|
-
base64: n,
|
|
360
|
-
mimetype: e.split(";")[0].trim(),
|
|
361
|
-
size: i.size,
|
|
362
|
-
filename: `voice-${Date.now()}.${r}`
|
|
363
|
-
}, a.loadBlob(i).then(() => {
|
|
364
|
-
if (!(t || R.current)) {
|
|
365
|
-
try {
|
|
366
|
-
a.setOptions({ interact: !0 });
|
|
367
|
-
} catch {}
|
|
368
|
-
try {
|
|
369
|
-
a.setTime(0);
|
|
370
|
-
} catch {}
|
|
371
|
-
}
|
|
372
|
-
}).catch(() => {}), M("preview");
|
|
373
|
-
}).catch(() => _("failed"));
|
|
374
|
-
}), r.start();
|
|
375
|
-
let i = performance.now();
|
|
376
|
-
s = window.setInterval(() => {
|
|
377
|
-
let e = performance.now() - i, t = Math.floor(e / 1e3);
|
|
378
|
-
P((e) => e === t ? e : t);
|
|
379
|
-
}, 250), A.current = s;
|
|
380
|
-
}).catch((e) => {
|
|
381
|
-
t || _(D(e));
|
|
382
|
-
}), () => {
|
|
383
|
-
t = !0, s !== null && clearInterval(s);
|
|
384
|
-
try {
|
|
385
|
-
c?.state === "recording" && c.stop();
|
|
386
|
-
} catch {}
|
|
387
|
-
try {
|
|
388
|
-
o.stopMic();
|
|
389
|
-
} catch {}
|
|
390
|
-
a.destroy(), b.current === a && (b.current = null), x.current === o && (x.current = null), S.current === c && (S.current = null);
|
|
391
|
-
};
|
|
392
|
-
}, []), /* @__PURE__ */ h(e.div, {
|
|
393
|
-
initial: {
|
|
394
|
-
opacity: 0,
|
|
395
|
-
y: 6
|
|
396
|
-
},
|
|
397
|
-
animate: {
|
|
398
|
-
opacity: 1,
|
|
399
|
-
y: 0
|
|
400
|
-
},
|
|
401
|
-
transition: { duration: .18 },
|
|
402
|
-
className: n("flex items-center gap-1.5 rounded-wx-lg border border-wx-border bg-wx-bg px-2 py-2"),
|
|
403
|
-
children: [
|
|
404
|
-
/* @__PURE__ */ m(k, {
|
|
405
|
-
Icon: i,
|
|
406
|
-
onClick: () => {
|
|
407
|
-
R.current = !0;
|
|
408
|
-
try {
|
|
409
|
-
S.current?.state === "recording" && S.current.stop();
|
|
410
|
-
} catch {}
|
|
411
|
-
try {
|
|
412
|
-
x.current?.stopMic();
|
|
413
|
-
} catch {}
|
|
414
|
-
try {
|
|
415
|
-
b.current?.pause();
|
|
416
|
-
} catch {}
|
|
417
|
-
c();
|
|
418
|
-
},
|
|
419
|
-
ariaLabel: v("cancelRecording"),
|
|
420
|
-
intent: "ghost"
|
|
421
|
-
}),
|
|
422
|
-
/* @__PURE__ */ h("div", {
|
|
423
|
-
className: "flex h-9 min-w-0 flex-1 items-center gap-2 rounded-full bg-wx-bg-elevated px-3",
|
|
424
|
-
children: [
|
|
425
|
-
j === "recording" && /* @__PURE__ */ m("span", {
|
|
426
|
-
"aria-hidden": "true",
|
|
427
|
-
className: "h-2 w-2 shrink-0 animate-pulse rounded-full bg-wx-danger"
|
|
428
|
-
}),
|
|
429
|
-
/* @__PURE__ */ m("div", {
|
|
430
|
-
ref: y,
|
|
431
|
-
"aria-hidden": "true",
|
|
432
|
-
className: n("min-w-0 flex-1 overflow-hidden", j !== "preview" && "pointer-events-none")
|
|
433
|
-
}),
|
|
434
|
-
/* @__PURE__ */ m("span", {
|
|
435
|
-
className: "shrink-0 font-mono text-xs tabular-nums text-wx-fg-muted",
|
|
436
|
-
children: w(N)
|
|
437
|
-
})
|
|
438
|
-
]
|
|
439
|
-
}),
|
|
440
|
-
j === "recording" && /* @__PURE__ */ m(e.button, {
|
|
441
|
-
type: "button",
|
|
442
|
-
onClick: () => {
|
|
443
|
-
try {
|
|
444
|
-
S.current?.state === "recording" && S.current.stop();
|
|
445
|
-
} catch {}
|
|
446
|
-
},
|
|
447
|
-
"aria-label": v("stopRecording"),
|
|
448
|
-
whileHover: { scale: 1.08 },
|
|
449
|
-
whileTap: { scale: .9 },
|
|
450
|
-
transition: {
|
|
451
|
-
type: "spring",
|
|
452
|
-
stiffness: 400,
|
|
453
|
-
damping: 22
|
|
454
|
-
},
|
|
455
|
-
className: n("flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition-colors", "text-wx-fg-muted hover:bg-wx-bg-elevated hover:text-wx-fg"),
|
|
456
|
-
children: /* @__PURE__ */ m(g, { size: 14 })
|
|
457
|
-
}),
|
|
458
|
-
j === "preview" && /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m(k, {
|
|
459
|
-
Icon: F ? a : o,
|
|
460
|
-
onClick: () => {
|
|
461
|
-
let e = b.current;
|
|
462
|
-
e && (e.isPlaying() ? e.pause() : e.play());
|
|
463
|
-
},
|
|
464
|
-
ariaLabel: v(F ? "pauseRecording" : "playPreview"),
|
|
465
|
-
intent: "ghost"
|
|
466
|
-
}), /* @__PURE__ */ m(e.button, {
|
|
467
|
-
type: "button",
|
|
468
|
-
onClick: () => {
|
|
469
|
-
let e = L.current;
|
|
470
|
-
e && r(e);
|
|
471
|
-
},
|
|
472
|
-
"aria-label": v("sendCta"),
|
|
473
|
-
whileHover: { scale: 1.08 },
|
|
474
|
-
whileTap: { scale: .9 },
|
|
475
|
-
transition: {
|
|
476
|
-
type: "spring",
|
|
477
|
-
stiffness: 400,
|
|
478
|
-
damping: 22
|
|
479
|
-
},
|
|
480
|
-
className: n("flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition-colors", "bg-wx-primary text-wx-primary-fg hover:bg-wx-primary-hover"),
|
|
481
|
-
children: /* @__PURE__ */ m(s, { size: 14 })
|
|
482
|
-
})] })
|
|
483
|
-
]
|
|
484
|
-
}, "voice-recorder");
|
|
485
|
-
}
|
|
486
|
-
function k({ Icon: t, onClick: r, ariaLabel: i, intent: a, size: o = 16 }) {
|
|
487
|
-
let s = c();
|
|
488
|
-
return /* @__PURE__ */ m(e.button, {
|
|
489
|
-
type: "button",
|
|
490
|
-
onClick: r,
|
|
491
|
-
"aria-label": i,
|
|
492
|
-
whileHover: { scale: 1.08 },
|
|
493
|
-
whileTap: { scale: .9 },
|
|
494
|
-
transition: {
|
|
495
|
-
type: "spring",
|
|
496
|
-
stiffness: 400,
|
|
497
|
-
damping: 22
|
|
498
|
-
},
|
|
499
|
-
...s.parentHandlers,
|
|
500
|
-
className: n("flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition-colors", a === "primary" ? "bg-wx-primary text-wx-primary-fg hover:bg-wx-primary-hover" : "text-wx-fg-muted hover:bg-wx-bg-elevated hover:text-wx-fg"),
|
|
501
|
-
children: /* @__PURE__ */ m(t, {
|
|
502
|
-
ref: s.iconRef,
|
|
503
|
-
size: o
|
|
504
|
-
})
|
|
505
|
-
});
|
|
506
|
-
}
|
|
507
|
-
//#endregion
|
|
508
|
-
export { O as VoiceRecorderBar };
|
|
509
|
-
|
|
510
|
-
//# sourceMappingURL=widget-react--IUy5lNt.js.map
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
globalThis.process === void 0 && (globalThis.process = {
|
|
2
|
-
env: {},
|
|
3
|
-
nextTick: function(e) {
|
|
4
|
-
setTimeout(e, 0);
|
|
5
|
-
},
|
|
6
|
-
emit: function() {
|
|
7
|
-
return !1;
|
|
8
|
-
}
|
|
9
|
-
});
|
|
10
|
-
import "react";
|
|
11
|
-
import "react-dom";
|
|
12
|
-
import "react/jsx-runtime";
|
|
13
|
-
import "react-dom/client";
|
|
14
|
-
import { t as e } from "./widget-react-krPPnv02.js";
|
|
15
|
-
var t = e("external-link", [
|
|
16
|
-
["path", {
|
|
17
|
-
d: "M15 3h6v6",
|
|
18
|
-
key: "1q9fwt"
|
|
19
|
-
}],
|
|
20
|
-
["path", {
|
|
21
|
-
d: "M10 14 21 3",
|
|
22
|
-
key: "gplh6r"
|
|
23
|
-
}],
|
|
24
|
-
["path", {
|
|
25
|
-
d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",
|
|
26
|
-
key: "a6xqqp"
|
|
27
|
-
}]
|
|
28
|
-
]);
|
|
29
|
-
//#endregion
|
|
30
|
-
export { t };
|
|
31
|
-
|
|
32
|
-
//# sourceMappingURL=widget-react-B7es3n1-.js.map
|