dictate-button 2.0.0 → 2.0.1
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/dictate-button.js +165 -163
- package/package.json +1 -1
package/dist/dictate-button.js
CHANGED
|
@@ -11,17 +11,17 @@ const T = 1, H = 2, bt = {
|
|
|
11
11
|
var y = null;
|
|
12
12
|
let et = null, Mt = null, b = null, w = null, S = null, Q = 0;
|
|
13
13
|
function Lt(t, e) {
|
|
14
|
-
const n = b,
|
|
14
|
+
const n = b, i = y, r = t.length === 0, o = e === void 0 ? i : e, l = r ? bt : {
|
|
15
15
|
owned: null,
|
|
16
16
|
cleanups: null,
|
|
17
17
|
context: o ? o.context : null,
|
|
18
18
|
owner: o
|
|
19
|
-
},
|
|
19
|
+
}, s = r ? t : () => t(() => Y(() => j(l)));
|
|
20
20
|
y = l, b = null;
|
|
21
21
|
try {
|
|
22
|
-
return B(
|
|
22
|
+
return B(s, !0);
|
|
23
23
|
} finally {
|
|
24
|
-
b = n, y =
|
|
24
|
+
b = n, y = i;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
function yt(t, e) {
|
|
@@ -31,22 +31,22 @@ function yt(t, e) {
|
|
|
31
31
|
observers: null,
|
|
32
32
|
observerSlots: null,
|
|
33
33
|
comparator: e.equals || void 0
|
|
34
|
-
},
|
|
35
|
-
return [_t.bind(n),
|
|
34
|
+
}, i = (r) => (typeof r == "function" && (r = r(n.value)), wt(n, r));
|
|
35
|
+
return [_t.bind(n), i];
|
|
36
36
|
}
|
|
37
37
|
function J(t, e, n) {
|
|
38
|
-
const
|
|
39
|
-
I(
|
|
38
|
+
const i = st(t, e, !1, T);
|
|
39
|
+
I(i);
|
|
40
40
|
}
|
|
41
41
|
function Ot(t, e, n) {
|
|
42
42
|
gt = It;
|
|
43
|
-
const
|
|
44
|
-
|
|
43
|
+
const i = st(t, e, !1, T);
|
|
44
|
+
i.user = !0, S ? S.push(i) : I(i);
|
|
45
45
|
}
|
|
46
46
|
function $t(t, e, n) {
|
|
47
47
|
n = n ? Object.assign({}, q, n) : q;
|
|
48
|
-
const
|
|
49
|
-
return
|
|
48
|
+
const i = st(t, e, !0, 0);
|
|
49
|
+
return i.observers = null, i.observerSlots = null, i.comparator = n.equals || void 0, I(i), _t.bind(i);
|
|
50
50
|
}
|
|
51
51
|
function Y(t) {
|
|
52
52
|
if (b === null) return t();
|
|
@@ -75,8 +75,8 @@ function _t() {
|
|
|
75
75
|
return this.value;
|
|
76
76
|
}
|
|
77
77
|
function wt(t, e, n) {
|
|
78
|
-
let
|
|
79
|
-
return (!t.comparator || !t.comparator(
|
|
78
|
+
let i = t.value;
|
|
79
|
+
return (!t.comparator || !t.comparator(i, e)) && (t.value = e, t.observers && t.observers.length && B(() => {
|
|
80
80
|
for (let r = 0; r < t.observers.length; r += 1) {
|
|
81
81
|
const o = t.observers[r], l = et && et.running;
|
|
82
82
|
l && et.disposed.has(o), (l ? !o.tState : !o.state) && (o.pure ? w.push(o) : S.push(o), o.observers && mt(o)), l || (o.state = T);
|
|
@@ -92,22 +92,22 @@ function I(t) {
|
|
|
92
92
|
Nt(t, t.value, e);
|
|
93
93
|
}
|
|
94
94
|
function Nt(t, e, n) {
|
|
95
|
-
let
|
|
95
|
+
let i;
|
|
96
96
|
const r = y, o = b;
|
|
97
97
|
b = y = t;
|
|
98
98
|
try {
|
|
99
|
-
|
|
99
|
+
i = t.fn(e);
|
|
100
100
|
} catch (l) {
|
|
101
101
|
return t.pure && (t.state = T, t.owned && t.owned.forEach(j), t.owned = null), t.updatedAt = n + 1, Ct(l);
|
|
102
102
|
} finally {
|
|
103
103
|
b = o, y = r;
|
|
104
104
|
}
|
|
105
|
-
(!t.updatedAt || t.updatedAt <= n) && (t.updatedAt != null && "observers" in t ? wt(t,
|
|
105
|
+
(!t.updatedAt || t.updatedAt <= n) && (t.updatedAt != null && "observers" in t ? wt(t, i) : t.value = i, t.updatedAt = n);
|
|
106
106
|
}
|
|
107
|
-
function
|
|
107
|
+
function st(t, e, n, i = T, r) {
|
|
108
108
|
const o = {
|
|
109
109
|
fn: t,
|
|
110
|
-
state:
|
|
110
|
+
state: i,
|
|
111
111
|
updatedAt: null,
|
|
112
112
|
owned: null,
|
|
113
113
|
sources: null,
|
|
@@ -131,8 +131,8 @@ function G(t) {
|
|
|
131
131
|
if (t = e[n], t.state === T)
|
|
132
132
|
I(t);
|
|
133
133
|
else if (t.state === H) {
|
|
134
|
-
const
|
|
135
|
-
w = null, B(() => X(t, e[0]), !1), w =
|
|
134
|
+
const i = w;
|
|
135
|
+
w = null, B(() => X(t, e[0]), !1), w = i;
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
function B(t, e) {
|
|
@@ -140,10 +140,10 @@ function B(t, e) {
|
|
|
140
140
|
let n = !1;
|
|
141
141
|
e || (w = []), S ? n = !0 : S = [], Q++;
|
|
142
142
|
try {
|
|
143
|
-
const
|
|
144
|
-
return jt(n),
|
|
145
|
-
} catch (
|
|
146
|
-
n || (S = null), w = null, Ct(
|
|
143
|
+
const i = t();
|
|
144
|
+
return jt(n), i;
|
|
145
|
+
} catch (i) {
|
|
146
|
+
n || (S = null), w = null, Ct(i);
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
function jt(t) {
|
|
@@ -157,18 +157,18 @@ function vt(t) {
|
|
|
157
157
|
function It(t) {
|
|
158
158
|
let e, n = 0;
|
|
159
159
|
for (e = 0; e < t.length; e++) {
|
|
160
|
-
const
|
|
161
|
-
|
|
160
|
+
const i = t[e];
|
|
161
|
+
i.user ? t[n++] = i : G(i);
|
|
162
162
|
}
|
|
163
163
|
for (e = 0; e < n; e++) G(t[e]);
|
|
164
164
|
}
|
|
165
165
|
function X(t, e) {
|
|
166
166
|
t.state = 0;
|
|
167
167
|
for (let n = 0; n < t.sources.length; n += 1) {
|
|
168
|
-
const
|
|
169
|
-
if (
|
|
170
|
-
const r =
|
|
171
|
-
r === T ?
|
|
168
|
+
const i = t.sources[n];
|
|
169
|
+
if (i.sources) {
|
|
170
|
+
const r = i.state;
|
|
171
|
+
r === T ? i !== e && (!i.updatedAt || i.updatedAt < Q) && G(i) : r === H && X(i, e);
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
}
|
|
@@ -182,10 +182,10 @@ function j(t) {
|
|
|
182
182
|
let e;
|
|
183
183
|
if (t.sources)
|
|
184
184
|
for (; t.sources.length; ) {
|
|
185
|
-
const n = t.sources.pop(),
|
|
185
|
+
const n = t.sources.pop(), i = t.sourceSlots.pop(), r = n.observers;
|
|
186
186
|
if (r && r.length) {
|
|
187
187
|
const o = r.pop(), l = n.observerSlots.pop();
|
|
188
|
-
|
|
188
|
+
i < r.length && (o.sourceSlots[l] = i, r[i] = o, n.observerSlots[i] = l);
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
if (t.tOwned) {
|
|
@@ -215,49 +215,49 @@ function K(t, e) {
|
|
|
215
215
|
}
|
|
216
216
|
const V = (t) => $t(() => t());
|
|
217
217
|
function Dt(t, e, n) {
|
|
218
|
-
let
|
|
219
|
-
for (; l < r ||
|
|
220
|
-
if (e[l] === n[
|
|
221
|
-
l++,
|
|
218
|
+
let i = n.length, r = e.length, o = i, l = 0, s = 0, a = e[r - 1].nextSibling, g = null;
|
|
219
|
+
for (; l < r || s < o; ) {
|
|
220
|
+
if (e[l] === n[s]) {
|
|
221
|
+
l++, s++;
|
|
222
222
|
continue;
|
|
223
223
|
}
|
|
224
224
|
for (; e[r - 1] === n[o - 1]; )
|
|
225
225
|
r--, o--;
|
|
226
226
|
if (r === l) {
|
|
227
|
-
const f = o <
|
|
228
|
-
for (;
|
|
229
|
-
} else if (o ===
|
|
227
|
+
const f = o < i ? s ? n[s - 1].nextSibling : n[o - s] : a;
|
|
228
|
+
for (; s < o; ) t.insertBefore(n[s++], f);
|
|
229
|
+
} else if (o === s)
|
|
230
230
|
for (; l < r; )
|
|
231
231
|
(!g || !g.has(e[l])) && e[l].remove(), l++;
|
|
232
|
-
else if (e[l] === n[o - 1] && n[
|
|
232
|
+
else if (e[l] === n[o - 1] && n[s] === e[r - 1]) {
|
|
233
233
|
const f = e[--r].nextSibling;
|
|
234
|
-
t.insertBefore(n[
|
|
234
|
+
t.insertBefore(n[s++], e[l++].nextSibling), t.insertBefore(n[--o], f), e[r] = n[o];
|
|
235
235
|
} else {
|
|
236
236
|
if (!g) {
|
|
237
237
|
g = /* @__PURE__ */ new Map();
|
|
238
|
-
let d =
|
|
238
|
+
let d = s;
|
|
239
239
|
for (; d < o; ) g.set(n[d], d++);
|
|
240
240
|
}
|
|
241
241
|
const f = g.get(e[l]);
|
|
242
242
|
if (f != null)
|
|
243
|
-
if (
|
|
244
|
-
let d = l, m = 1,
|
|
245
|
-
for (; ++d < r && d < o && !((
|
|
243
|
+
if (s < f && f < o) {
|
|
244
|
+
let d = l, m = 1, c;
|
|
245
|
+
for (; ++d < r && d < o && !((c = g.get(e[d])) == null || c !== f + m); )
|
|
246
246
|
m++;
|
|
247
|
-
if (m > f -
|
|
247
|
+
if (m > f - s) {
|
|
248
248
|
const P = e[l];
|
|
249
|
-
for (;
|
|
250
|
-
} else t.replaceChild(n[
|
|
249
|
+
for (; s < f; ) t.insertBefore(n[s++], P);
|
|
250
|
+
} else t.replaceChild(n[s++], e[l++]);
|
|
251
251
|
} else l++;
|
|
252
252
|
else e[l++].remove();
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
|
-
function D(t, e, n,
|
|
256
|
+
function D(t, e, n, i) {
|
|
257
257
|
let r;
|
|
258
258
|
const o = () => {
|
|
259
|
-
const
|
|
260
|
-
return
|
|
259
|
+
const s = document.createElement("template");
|
|
260
|
+
return s.innerHTML = t, s.content.firstChild;
|
|
261
261
|
}, l = () => (r || (r = o())).cloneNode(!0);
|
|
262
262
|
return l.cloneNode = l, l;
|
|
263
263
|
}
|
|
@@ -266,55 +266,55 @@ function N(t, e, n) {
|
|
|
266
266
|
}
|
|
267
267
|
function Ut(t, e, n) {
|
|
268
268
|
if (!e) return n ? N(t, "style") : e;
|
|
269
|
-
const
|
|
270
|
-
if (typeof e == "string") return
|
|
271
|
-
typeof n == "string" && (
|
|
269
|
+
const i = t.style;
|
|
270
|
+
if (typeof e == "string") return i.cssText = e;
|
|
271
|
+
typeof n == "string" && (i.cssText = n = void 0), n || (n = {}), e || (e = {});
|
|
272
272
|
let r, o;
|
|
273
273
|
for (o in n)
|
|
274
|
-
e[o] == null &&
|
|
274
|
+
e[o] == null && i.removeProperty(o), delete n[o];
|
|
275
275
|
for (o in e)
|
|
276
|
-
r = e[o], r !== n[o] && (
|
|
276
|
+
r = e[o], r !== n[o] && (i.setProperty(o, r), n[o] = r);
|
|
277
277
|
return n;
|
|
278
278
|
}
|
|
279
279
|
function zt(t, e, n) {
|
|
280
280
|
return Y(() => t(e, n));
|
|
281
281
|
}
|
|
282
|
-
function L(t, e, n,
|
|
283
|
-
if (n !== void 0 && !
|
|
284
|
-
J((r) => Z(t, e(), r, n),
|
|
282
|
+
function L(t, e, n, i) {
|
|
283
|
+
if (n !== void 0 && !i && (i = []), typeof e != "function") return Z(t, e, i, n);
|
|
284
|
+
J((r) => Z(t, e(), r, n), i);
|
|
285
285
|
}
|
|
286
|
-
function Z(t, e, n,
|
|
286
|
+
function Z(t, e, n, i, r) {
|
|
287
287
|
for (; typeof n == "function"; ) n = n();
|
|
288
288
|
if (e === n) return n;
|
|
289
|
-
const o = typeof e, l =
|
|
289
|
+
const o = typeof e, l = i !== void 0;
|
|
290
290
|
if (t = l && n[0] && n[0].parentNode || t, o === "string" || o === "number") {
|
|
291
291
|
if (o === "number" && (e = e.toString(), e === n))
|
|
292
292
|
return n;
|
|
293
293
|
if (l) {
|
|
294
|
-
let
|
|
295
|
-
|
|
294
|
+
let s = n[0];
|
|
295
|
+
s && s.nodeType === 3 ? s.data !== e && (s.data = e) : s = document.createTextNode(e), n = $(t, n, i, s);
|
|
296
296
|
} else
|
|
297
297
|
n !== "" && typeof n == "string" ? n = t.firstChild.data = e : n = t.textContent = e;
|
|
298
298
|
} else if (e == null || o === "boolean")
|
|
299
|
-
n = $(t, n,
|
|
299
|
+
n = $(t, n, i);
|
|
300
300
|
else {
|
|
301
301
|
if (o === "function")
|
|
302
302
|
return J(() => {
|
|
303
|
-
let
|
|
304
|
-
for (; typeof
|
|
305
|
-
n = Z(t,
|
|
303
|
+
let s = e();
|
|
304
|
+
for (; typeof s == "function"; ) s = s();
|
|
305
|
+
n = Z(t, s, n, i);
|
|
306
306
|
}), () => n;
|
|
307
307
|
if (Array.isArray(e)) {
|
|
308
|
-
const
|
|
309
|
-
if (
|
|
310
|
-
return J(() => n = Z(t,
|
|
311
|
-
if (
|
|
312
|
-
if (n = $(t, n,
|
|
313
|
-
} else a ? n.length === 0 ? ut(t,
|
|
314
|
-
n =
|
|
308
|
+
const s = [], a = n && Array.isArray(n);
|
|
309
|
+
if (it(s, e, n, r))
|
|
310
|
+
return J(() => n = Z(t, s, n, i, !0)), () => n;
|
|
311
|
+
if (s.length === 0) {
|
|
312
|
+
if (n = $(t, n, i), l) return n;
|
|
313
|
+
} else a ? n.length === 0 ? ut(t, s, i) : Dt(t, n, s) : (n && $(t), ut(t, s));
|
|
314
|
+
n = s;
|
|
315
315
|
} else if (e.nodeType) {
|
|
316
316
|
if (Array.isArray(n)) {
|
|
317
|
-
if (l) return n = $(t, n,
|
|
317
|
+
if (l) return n = $(t, n, i, e);
|
|
318
318
|
$(t, n, null, e);
|
|
319
319
|
} else n == null || n === "" || !t.firstChild ? t.appendChild(e) : t.replaceChild(e, t.firstChild);
|
|
320
320
|
n = e;
|
|
@@ -322,67 +322,67 @@ function Z(t, e, n, s, r) {
|
|
|
322
322
|
}
|
|
323
323
|
return n;
|
|
324
324
|
}
|
|
325
|
-
function
|
|
325
|
+
function it(t, e, n, i) {
|
|
326
326
|
let r = !1;
|
|
327
327
|
for (let o = 0, l = e.length; o < l; o++) {
|
|
328
|
-
let
|
|
329
|
-
if (!(
|
|
330
|
-
t.push(
|
|
331
|
-
else if (Array.isArray(
|
|
332
|
-
r =
|
|
328
|
+
let s = e[o], a = n && n[t.length], g;
|
|
329
|
+
if (!(s == null || s === !0 || s === !1)) if ((g = typeof s) == "object" && s.nodeType)
|
|
330
|
+
t.push(s);
|
|
331
|
+
else if (Array.isArray(s))
|
|
332
|
+
r = it(t, s, a) || r;
|
|
333
333
|
else if (g === "function")
|
|
334
|
-
if (
|
|
335
|
-
for (; typeof
|
|
336
|
-
r =
|
|
334
|
+
if (i) {
|
|
335
|
+
for (; typeof s == "function"; ) s = s();
|
|
336
|
+
r = it(t, Array.isArray(s) ? s : [s], Array.isArray(a) ? a : [a]) || r;
|
|
337
337
|
} else
|
|
338
|
-
t.push(
|
|
338
|
+
t.push(s), r = !0;
|
|
339
339
|
else {
|
|
340
|
-
const f = String(
|
|
340
|
+
const f = String(s);
|
|
341
341
|
a && a.nodeType === 3 && a.data === f ? t.push(a) : t.push(document.createTextNode(f));
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
344
|
return r;
|
|
345
345
|
}
|
|
346
346
|
function ut(t, e, n = null) {
|
|
347
|
-
for (let
|
|
347
|
+
for (let i = 0, r = e.length; i < r; i++) t.insertBefore(e[i], n);
|
|
348
348
|
}
|
|
349
|
-
function $(t, e, n,
|
|
349
|
+
function $(t, e, n, i) {
|
|
350
350
|
if (n === void 0) return t.textContent = "";
|
|
351
|
-
const r =
|
|
351
|
+
const r = i || document.createTextNode("");
|
|
352
352
|
if (e.length) {
|
|
353
353
|
let o = !1;
|
|
354
354
|
for (let l = e.length - 1; l >= 0; l--) {
|
|
355
|
-
const
|
|
356
|
-
if (r !==
|
|
357
|
-
const a =
|
|
358
|
-
!o && !l ? a ? t.replaceChild(r,
|
|
355
|
+
const s = e[l];
|
|
356
|
+
if (r !== s) {
|
|
357
|
+
const a = s.parentNode === t;
|
|
358
|
+
!o && !l ? a ? t.replaceChild(r, s) : t.insertBefore(r, n) : a && s.remove();
|
|
359
359
|
} else o = !0;
|
|
360
360
|
}
|
|
361
361
|
} else t.insertBefore(r, n);
|
|
362
362
|
return [r];
|
|
363
363
|
}
|
|
364
364
|
function Ft(t) {
|
|
365
|
-
return Object.keys(t).reduce((n,
|
|
366
|
-
const r = t[
|
|
367
|
-
return n[
|
|
365
|
+
return Object.keys(t).reduce((n, i) => {
|
|
366
|
+
const r = t[i];
|
|
367
|
+
return n[i] = Object.assign({}, r), St(r.value) && !Ht(r.value) && !Array.isArray(r.value) && (n[i].value = Object.assign({}, r.value)), Array.isArray(r.value) && (n[i].value = r.value.slice(0)), n;
|
|
368
368
|
}, {});
|
|
369
369
|
}
|
|
370
370
|
function Wt(t) {
|
|
371
|
-
return t ? Object.keys(t).reduce((n,
|
|
372
|
-
const r = t[
|
|
373
|
-
return n[
|
|
371
|
+
return t ? Object.keys(t).reduce((n, i) => {
|
|
372
|
+
const r = t[i];
|
|
373
|
+
return n[i] = St(r) && "value" in r ? r : {
|
|
374
374
|
value: r
|
|
375
|
-
}, n[
|
|
375
|
+
}, n[i].attribute || (n[i].attribute = qt(i)), n[i].parse = "parse" in n[i] ? n[i].parse : typeof n[i].value != "string", n;
|
|
376
376
|
}, {}) : {};
|
|
377
377
|
}
|
|
378
378
|
function Kt(t) {
|
|
379
|
-
return Object.keys(t).reduce((n,
|
|
379
|
+
return Object.keys(t).reduce((n, i) => (n[i] = t[i].value, n), {});
|
|
380
380
|
}
|
|
381
381
|
function Vt(t, e) {
|
|
382
382
|
const n = Ft(e);
|
|
383
383
|
return Object.keys(e).forEach((r) => {
|
|
384
|
-
const o = n[r], l = t.getAttribute(o.attribute),
|
|
385
|
-
l != null && (o.value = o.parse ? xt(l) : l),
|
|
384
|
+
const o = n[r], l = t.getAttribute(o.attribute), s = t[r];
|
|
385
|
+
l != null && (o.value = o.parse ? xt(l) : l), s != null && (o.value = Array.isArray(s) ? s.slice(0) : s), o.reflect && ft(t, o.attribute, o.value, !!o.parse), Object.defineProperty(t, r, {
|
|
386
386
|
get() {
|
|
387
387
|
return o.value;
|
|
388
388
|
},
|
|
@@ -405,9 +405,9 @@ function xt(t) {
|
|
|
405
405
|
return t;
|
|
406
406
|
}
|
|
407
407
|
}
|
|
408
|
-
function ft(t, e, n,
|
|
408
|
+
function ft(t, e, n, i) {
|
|
409
409
|
if (n == null || n === !1) return t.removeAttribute(e);
|
|
410
|
-
let r =
|
|
410
|
+
let r = i ? JSON.stringify(n) : n;
|
|
411
411
|
t.__updating[e] = !0, r === "true" && (r = ""), t.setAttribute(e, r), Promise.resolve().then(() => delete t.__updating[e]);
|
|
412
412
|
}
|
|
413
413
|
function qt(t) {
|
|
@@ -480,20 +480,20 @@ function Gt(t, e) {
|
|
|
480
480
|
}
|
|
481
481
|
function Xt(t, e = {}, n = {}) {
|
|
482
482
|
const {
|
|
483
|
-
BaseElement:
|
|
483
|
+
BaseElement: i = HTMLElement,
|
|
484
484
|
extension: r,
|
|
485
485
|
customElements: o = window.customElements
|
|
486
486
|
} = n;
|
|
487
487
|
return (l) => {
|
|
488
|
-
let
|
|
489
|
-
return
|
|
488
|
+
let s = o.get(t);
|
|
489
|
+
return s ? (s.prototype.Component = l, s) : (s = Gt(i, Wt(e)), s.prototype.Component = l, s.prototype.registeredTag = t, o.define(t, s, r), s);
|
|
490
490
|
};
|
|
491
491
|
}
|
|
492
492
|
function Zt(t) {
|
|
493
493
|
const e = Object.keys(t), n = {};
|
|
494
|
-
for (let
|
|
495
|
-
const [r, o] = yt(t[e[
|
|
496
|
-
Object.defineProperty(n, e[
|
|
494
|
+
for (let i = 0; i < e.length; i++) {
|
|
495
|
+
const [r, o] = yt(t[e[i]]);
|
|
496
|
+
Object.defineProperty(n, e[i], {
|
|
497
497
|
get: r,
|
|
498
498
|
set(l) {
|
|
499
499
|
o(() => l);
|
|
@@ -511,15 +511,15 @@ function Qt(t) {
|
|
|
511
511
|
}
|
|
512
512
|
function Yt(t) {
|
|
513
513
|
return (e, n) => {
|
|
514
|
-
const { element:
|
|
514
|
+
const { element: i } = n;
|
|
515
515
|
return Lt((r) => {
|
|
516
516
|
const o = Zt(e);
|
|
517
|
-
|
|
518
|
-
|
|
517
|
+
i.addPropertyChangedCallback((s, a) => o[s] = a), i.addReleaseCallback(() => {
|
|
518
|
+
i.renderRoot.textContent = "", r();
|
|
519
519
|
});
|
|
520
520
|
const l = t(o, n);
|
|
521
|
-
return L(
|
|
522
|
-
}, Qt(
|
|
521
|
+
return L(i.renderRoot, l);
|
|
522
|
+
}, Qt(i));
|
|
523
523
|
};
|
|
524
524
|
}
|
|
525
525
|
function te(t, e, n) {
|
|
@@ -583,8 +583,8 @@ const ee = `
|
|
|
583
583
|
}
|
|
584
584
|
}
|
|
585
585
|
`;
|
|
586
|
-
var ne = /* @__PURE__ */ D('<div part=container class=dictate-button__container><style></style><div aria-live=polite class=dictate-button__status-announcer style="position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0"></div><button part=button class=dictate-button__button>'), re = /* @__PURE__ */ D('<svg part=icon class="dictate-button__icon dictate-button__icon--idle"fill=none viewBox="0 0 24 24"stroke-width=1.5 stroke=currentColor role=img aria-hidden=true><path stroke-linecap=round stroke-linejoin=round d="M12 18.75a6 6 0 0 0 6-6v-1.5m-6 7.5a6 6 0 0 1-6-6v-1.5m6 7.5v3.75m-3.75 0h7.5M12 15.75a3 3 0 0 1-3-3V4.5a3 3 0 1 1 6 0v8.25a3 3 0 0 1-3 3Z">'),
|
|
587
|
-
console.debug("[dictate-button] version:", "2.0.
|
|
586
|
+
var ne = /* @__PURE__ */ D('<div part=container class=dictate-button__container><style></style><div aria-live=polite class=dictate-button__status-announcer style="position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0"></div><button part=button class=dictate-button__button>'), re = /* @__PURE__ */ D('<svg part=icon class="dictate-button__icon dictate-button__icon--idle"fill=none viewBox="0 0 24 24"stroke-width=1.5 stroke=currentColor role=img aria-hidden=true><path stroke-linecap=round stroke-linejoin=round d="M12 18.75a6 6 0 0 0 6-6v-1.5m-6 7.5a6 6 0 0 1-6-6v-1.5m6 7.5v3.75m-3.75 0h7.5M12 15.75a3 3 0 0 1-3-3V4.5a3 3 0 1 1 6 0v8.25a3 3 0 0 1-3 3Z">'), ie = /* @__PURE__ */ D('<svg part=icon class="dictate-button__icon dictate-button__icon--recording"viewBox="0 0 24 24"fill=currentColor role=img aria-hidden=true><circle cx=12 cy=12 r=10>'), se = /* @__PURE__ */ D('<svg part=icon class="dictate-button__icon dictate-button__icon--error"viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=4 stroke-linecap=round stroke-linejoin=round role=img aria-hidden=true><line x1=12 x2=12 y1=4 y2=14></line><line x1=12 x2=12.01 y1=20 y2=20>'), oe = /* @__PURE__ */ D('<svg part=icon class="dictate-button__icon dictate-button__icon--processing"viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round role=img aria-hidden=true><path d="M12 2v4"></path><path d="M12 18v4"></path><path d="M4.93 4.93l2.83 2.83"></path><path d="M16.24 16.24l2.83 2.83"></path><path d="M2 12h4"></path><path d="M18 12h4"></path><path d="M4.93 19.07l2.83-2.83"></path><path d="M16.24 7.76l2.83-2.83">');
|
|
587
|
+
console.debug("[dictate-button] version:", "2.0.1");
|
|
588
588
|
const le = "wss://api.dictate-button.io/v2/transcribe", k = "dictate-button.io", rt = -70, dt = -10, pt = 0, ae = 4, ce = 0.25, ue = 0.05;
|
|
589
589
|
customElements.get("dictate-button") ? console.debug("[dictate-button] We don't require importing the dictate-button component separately anymore, so you may remove the script tag which imports https://cdn.dictate-button.io/dictate-button.js from the HTML head.") : te("dictate-button", {
|
|
590
590
|
size: 30,
|
|
@@ -594,33 +594,33 @@ customElements.get("dictate-button") ? console.debug("[dictate-button] We don't
|
|
|
594
594
|
element: e
|
|
595
595
|
}) => {
|
|
596
596
|
console.debug("[dictate-button] api:", t.apiEndpoint);
|
|
597
|
-
const [n,
|
|
598
|
-
let r = null, o = null, l = null,
|
|
599
|
-
const Et = (
|
|
597
|
+
const [n, i] = yt("idle");
|
|
598
|
+
let r = null, o = null, l = null, s = "", a = "", g = -1, f = "", d = null, m = null, c = null, P = null, U = !1, R = 0;
|
|
599
|
+
const Et = (u) => u <= rt ? 0 : u >= dt ? 1 : (u - rt) / (dt - rt), At = (u) => {
|
|
600
600
|
let _ = 0;
|
|
601
|
-
for (let C = 0; C <
|
|
602
|
-
const p = (
|
|
601
|
+
for (let C = 0; C < u.length; C++) {
|
|
602
|
+
const p = (u[C] - 128) / 128;
|
|
603
603
|
_ += p * p;
|
|
604
604
|
}
|
|
605
|
-
return Math.sqrt(_ /
|
|
606
|
-
}, kt = (
|
|
605
|
+
return Math.sqrt(_ / u.length);
|
|
606
|
+
}, kt = (u) => 20 * Math.log10(Math.max(u, 1e-8)), ot = (u) => {
|
|
607
607
|
const _ = e.shadowRoot.querySelector(".dictate-button__button");
|
|
608
608
|
if (!_)
|
|
609
609
|
return;
|
|
610
|
-
const C = pt +
|
|
610
|
+
const C = pt + u * (ae - pt), p = 0 + u * 0.4;
|
|
611
611
|
_.style.boxShadow = `0 0 0 ${C}px light-dark(rgba(0, 0, 0, ${p}), rgba(255, 255, 255, ${p}))`;
|
|
612
612
|
}, lt = () => {
|
|
613
613
|
if (!U || !m || !P) return;
|
|
614
614
|
m.getByteTimeDomainData(P);
|
|
615
|
-
const
|
|
615
|
+
const u = At(P), _ = kt(u), C = Et(_), p = C > R ? ce : ue;
|
|
616
616
|
R = p * C + (1 - p) * R, ot(R), requestAnimationFrame(lt);
|
|
617
617
|
}, O = () => {
|
|
618
|
-
r && (r.close(), r = null),
|
|
618
|
+
r && (r.close(), r = null), c && (c.disconnect(), c = null), o && (o.getTracks().forEach((u) => u.stop()), o = null), l = null, s = "", a = "", g = -1, f = "", U = !1, d && d.state !== "closed" && d.close(), d = null, m = null, P = null, R = 0, ot(0);
|
|
619
619
|
};
|
|
620
620
|
e.addEventListener("disconnected", O);
|
|
621
|
-
const at = async (
|
|
621
|
+
const at = async (u) => {
|
|
622
622
|
if (n() === "idle") {
|
|
623
|
-
l =
|
|
623
|
+
l = u, s = "", a = "", g = -1, f = "";
|
|
624
624
|
try {
|
|
625
625
|
const _ = await navigator.mediaDevices.getUserMedia({
|
|
626
626
|
audio: {
|
|
@@ -655,19 +655,19 @@ customElements.get("dictate-button") ? console.debug("[dictate-button] We don't
|
|
|
655
655
|
`, F = new Blob([p], {
|
|
656
656
|
type: "application/javascript"
|
|
657
657
|
}), h = URL.createObjectURL(F);
|
|
658
|
-
await d.audioWorklet.addModule(h), URL.revokeObjectURL(h),
|
|
658
|
+
await d.audioWorklet.addModule(h), URL.revokeObjectURL(h), c = new AudioWorkletNode(d, "pcm-processor"), C.connect(c);
|
|
659
659
|
const W = new URL(t.apiEndpoint);
|
|
660
660
|
t.language && W.searchParams.set("language", t.language), r = new WebSocket(W.toString()), r.onmessage = (E) => {
|
|
661
661
|
try {
|
|
662
662
|
const v = JSON.parse(E.data);
|
|
663
663
|
if (v.type === "interim_transcript" && v.text) {
|
|
664
664
|
f = v.text;
|
|
665
|
-
const M = [a,
|
|
665
|
+
const M = [a, s, f].filter(Boolean).join(" ");
|
|
666
666
|
A(e, "dictate-text", M);
|
|
667
667
|
} else if (v.type === "transcript" && v.text) {
|
|
668
668
|
const M = v.turn_order ?? 0, x = v.text;
|
|
669
|
-
f = "", M > g ? (
|
|
670
|
-
const Tt = a ? a + " " +
|
|
669
|
+
f = "", M > g ? (s && (a = a ? a + " " + s : s), g = M, s = x) : x.length > s.length && x.startsWith(s.substring(0, Math.min(10, s.length))) ? s = x : s = s ? s + " " + x : x;
|
|
670
|
+
const Tt = a ? a + " " + s : s;
|
|
671
671
|
A(e, "dictate-text", Tt);
|
|
672
672
|
} else v.type === "error" && (console.error("[dictate-button] Server error:", v.error), A(e, "dictate-error", v.error), tt(), O());
|
|
673
673
|
} catch (v) {
|
|
@@ -676,33 +676,33 @@ customElements.get("dictate-button") ? console.debug("[dictate-button] We don't
|
|
|
676
676
|
}, r.onerror = (E) => {
|
|
677
677
|
console.error("[dictate-button] WebSocket error:", E), A(e, "dictate-error", "Connection error"), tt(), O();
|
|
678
678
|
}, r.onclose = () => {
|
|
679
|
-
},
|
|
679
|
+
}, c.port.onmessage = (E) => {
|
|
680
680
|
r && r.readyState === WebSocket.OPEN && r.send(E.data);
|
|
681
|
-
}, A(e, "dictate-start", "Started transcribing"), U = !0, lt(),
|
|
681
|
+
}, A(e, "dictate-start", "Started transcribing"), U = !0, lt(), i("transcribing");
|
|
682
682
|
} catch (_) {
|
|
683
683
|
console.error("[dictate-button] Failed to start:", _), A(e, "dictate-error", "Failed to start transcription"), tt(), O();
|
|
684
684
|
}
|
|
685
685
|
}
|
|
686
686
|
}, ct = () => {
|
|
687
687
|
if (n() === "transcribing")
|
|
688
|
-
if (U = !1,
|
|
688
|
+
if (U = !1, i("finalizing"), r && r.readyState === WebSocket.OPEN)
|
|
689
689
|
r.send(JSON.stringify({
|
|
690
690
|
type: "close"
|
|
691
691
|
})), setTimeout(() => {
|
|
692
|
-
const
|
|
693
|
-
|
|
692
|
+
const u = a ? a + (s ? " " + s : "") : s;
|
|
693
|
+
u && A(e, "dictate-end", u), O(), i("idle");
|
|
694
694
|
}, 500);
|
|
695
695
|
else {
|
|
696
|
-
const
|
|
697
|
-
|
|
696
|
+
const u = a ? a + (s ? " " + s : "") : s;
|
|
697
|
+
u && A(e, "dictate-end", u), O(), i("idle");
|
|
698
698
|
}
|
|
699
699
|
}, tt = () => {
|
|
700
|
-
|
|
700
|
+
i("error"), setTimeout(() => i("idle"), 2e3);
|
|
701
701
|
};
|
|
702
702
|
let z;
|
|
703
703
|
return Ot(() => {
|
|
704
704
|
if (!z) return;
|
|
705
|
-
const
|
|
705
|
+
const u = be(z, {
|
|
706
706
|
onShortTap: () => {
|
|
707
707
|
n() === "idle" ? at("short-tap") : n() === "transcribing" && l === "short-tap" && ct();
|
|
708
708
|
},
|
|
@@ -713,9 +713,9 @@ customElements.get("dictate-button") ? console.debug("[dictate-button] We don't
|
|
|
713
713
|
n() === "transcribing" && l === "long-press" && ct();
|
|
714
714
|
}
|
|
715
715
|
});
|
|
716
|
-
Rt(
|
|
716
|
+
Rt(u);
|
|
717
717
|
}), (() => {
|
|
718
|
-
var
|
|
718
|
+
var u = ne(), _ = u.firstChild, C = _.nextSibling, p = C.nextSibling;
|
|
719
719
|
L(_, ee), L(C, () => ht(n()));
|
|
720
720
|
var F = z;
|
|
721
721
|
return typeof F == "function" ? zt(F, p) : z = p, L(p, (() => {
|
|
@@ -739,7 +739,7 @@ customElements.get("dictate-button") ? console.debug("[dictate-button] We don't
|
|
|
739
739
|
a: void 0,
|
|
740
740
|
o: void 0,
|
|
741
741
|
i: void 0
|
|
742
|
-
}),
|
|
742
|
+
}), u;
|
|
743
743
|
})();
|
|
744
744
|
});
|
|
745
745
|
const fe = (t) => {
|
|
@@ -770,31 +770,33 @@ const fe = (t) => {
|
|
|
770
770
|
bubbles: !0,
|
|
771
771
|
composed: !0
|
|
772
772
|
}));
|
|
773
|
-
}, de = () => re(), pe = () =>
|
|
773
|
+
}, de = () => re(), pe = () => ie(), he = () => se(), ge = () => oe();
|
|
774
774
|
function be(t, {
|
|
775
775
|
threshold: e = 500,
|
|
776
776
|
preventScroll: n = !0,
|
|
777
|
-
onShortTap:
|
|
777
|
+
onShortTap: i,
|
|
778
778
|
onLongPressStart: r,
|
|
779
779
|
onLongPressEnd: o
|
|
780
780
|
} = {}) {
|
|
781
|
-
let l,
|
|
782
|
-
const a = (
|
|
783
|
-
l && clearTimeout(l),
|
|
784
|
-
|
|
785
|
-
detail:
|
|
781
|
+
let l, s = !1;
|
|
782
|
+
const a = (c) => c.preventDefault(), g = (c) => {
|
|
783
|
+
l && clearTimeout(l), s = !1, c.preventDefault(), t.setPointerCapture(c.pointerId), l = window.setTimeout(() => {
|
|
784
|
+
s = !0, r?.(c), t.dispatchEvent(new CustomEvent("longpress", {
|
|
785
|
+
detail: c
|
|
786
786
|
}));
|
|
787
787
|
}, e);
|
|
788
|
-
}, f = (
|
|
789
|
-
l && clearTimeout(l), t.releasePointerCapture(
|
|
790
|
-
detail:
|
|
791
|
-
}))) : (
|
|
792
|
-
detail:
|
|
788
|
+
}, f = (c) => {
|
|
789
|
+
l && clearTimeout(l), t.releasePointerCapture(c.pointerId), s ? (o?.(c), t.dispatchEvent(new CustomEvent("longpressend", {
|
|
790
|
+
detail: c
|
|
791
|
+
}))) : (i?.(c), t.dispatchEvent(new CustomEvent("shorttap", {
|
|
792
|
+
detail: c
|
|
793
793
|
})));
|
|
794
|
-
}, d = (
|
|
795
|
-
l && clearTimeout(l), t.releasePointerCapture(
|
|
796
|
-
|
|
797
|
-
|
|
794
|
+
}, d = (c) => {
|
|
795
|
+
l && clearTimeout(l), t.releasePointerCapture(c.pointerId), s && (o?.(c), t.dispatchEvent(new CustomEvent("longpressend", {
|
|
796
|
+
detail: c
|
|
797
|
+
}))), s = !1;
|
|
798
|
+
}, m = (c) => {
|
|
799
|
+
c.preventDefault(), c.stopPropagation();
|
|
798
800
|
};
|
|
799
801
|
return n && (t.style.touchAction = "none", t.addEventListener("contextmenu", a)), t.addEventListener("pointerdown", g), t.addEventListener("pointerup", f), t.addEventListener("pointercancel", d), t.addEventListener("click", m), () => {
|
|
800
802
|
n && t.removeEventListener("contextmenu", a), t.removeEventListener("pointerdown", g), t.removeEventListener("pointerup", f), t.removeEventListener("pointercancel", d), t.removeEventListener("click", m);
|