dictate-button 1.1.0 → 1.1.2
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 +207 -212
- package/dist/inject-exclusive.js +1 -1
- package/dist/inject-inclusive.js +1 -1
- package/package.json +1 -1
package/dist/dictate-button.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
const
|
|
2
|
-
equals:
|
|
1
|
+
const pt = (t, e) => t === e, B = {
|
|
2
|
+
equals: pt
|
|
3
3
|
};
|
|
4
|
-
let
|
|
5
|
-
const
|
|
4
|
+
let gt = lt;
|
|
5
|
+
const C = 1, R = 2, et = {
|
|
6
6
|
owned: null,
|
|
7
7
|
cleanups: null,
|
|
8
8
|
context: null,
|
|
9
9
|
owner: null
|
|
10
10
|
};
|
|
11
|
-
var
|
|
12
|
-
let
|
|
13
|
-
function
|
|
14
|
-
const n = p, s =
|
|
11
|
+
var b = null;
|
|
12
|
+
let z = null, bt = null, p = null, g = null, w = null, L = 0;
|
|
13
|
+
function yt(t, e) {
|
|
14
|
+
const n = p, s = b, r = t.length === 0, o = e === void 0 ? s : e, l = r ? et : {
|
|
15
15
|
owned: null,
|
|
16
16
|
cleanups: null,
|
|
17
17
|
context: o ? o.context : null,
|
|
18
18
|
owner: o
|
|
19
19
|
}, i = r ? t : () => t(() => G(() => E(l)));
|
|
20
|
-
|
|
20
|
+
b = l, p = null;
|
|
21
21
|
try {
|
|
22
|
-
return
|
|
22
|
+
return x(i, !0);
|
|
23
23
|
} finally {
|
|
24
|
-
p = n,
|
|
24
|
+
p = n, b = s;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
e = e ? Object.assign({},
|
|
27
|
+
function nt(t, e) {
|
|
28
|
+
e = e ? Object.assign({}, B, e) : B;
|
|
29
29
|
const n = {
|
|
30
30
|
value: t,
|
|
31
31
|
observers: null,
|
|
32
32
|
observerSlots: null,
|
|
33
33
|
comparator: e.equals || void 0
|
|
34
|
-
}, s = (r) => (typeof r == "function" && (r = r(n.value)),
|
|
35
|
-
return [
|
|
34
|
+
}, s = (r) => (typeof r == "function" && (r = r(n.value)), st(n, r));
|
|
35
|
+
return [rt.bind(n), s];
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
const s =
|
|
39
|
-
|
|
37
|
+
function I(t, e, n) {
|
|
38
|
+
const s = ot(t, e, !1, C);
|
|
39
|
+
K(s);
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
n = n ? Object.assign({},
|
|
43
|
-
const s =
|
|
44
|
-
return s.observers = null, s.observerSlots = null, s.comparator = n.equals || void 0,
|
|
41
|
+
function _t(t, e, n) {
|
|
42
|
+
n = n ? Object.assign({}, B, n) : B;
|
|
43
|
+
const s = ot(t, e, !0, 0);
|
|
44
|
+
return s.observers = null, s.observerSlots = null, s.comparator = n.equals || void 0, K(s), rt.bind(s);
|
|
45
45
|
}
|
|
46
46
|
function G(t) {
|
|
47
47
|
if (p === null) return t();
|
|
@@ -53,12 +53,12 @@ function G(t) {
|
|
|
53
53
|
p = e;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
function
|
|
56
|
+
function rt() {
|
|
57
57
|
if (this.sources && this.state)
|
|
58
|
-
if (this.state ===
|
|
58
|
+
if (this.state === C) K(this);
|
|
59
59
|
else {
|
|
60
60
|
const t = g;
|
|
61
|
-
g = null,
|
|
61
|
+
g = null, x(() => D(this), !1), g = t;
|
|
62
62
|
}
|
|
63
63
|
if (p) {
|
|
64
64
|
const t = this.observers ? this.observers.length : 0;
|
|
@@ -66,37 +66,37 @@ function st() {
|
|
|
66
66
|
}
|
|
67
67
|
return this.value;
|
|
68
68
|
}
|
|
69
|
-
function
|
|
69
|
+
function st(t, e, n) {
|
|
70
70
|
let s = t.value;
|
|
71
|
-
return (!t.comparator || !t.comparator(s, e)) && (t.value = e, t.observers && t.observers.length &&
|
|
71
|
+
return (!t.comparator || !t.comparator(s, e)) && (t.value = e, t.observers && t.observers.length && x(() => {
|
|
72
72
|
for (let r = 0; r < t.observers.length; r += 1) {
|
|
73
|
-
const o = t.observers[r], l =
|
|
74
|
-
l &&
|
|
73
|
+
const o = t.observers[r], l = z && z.running;
|
|
74
|
+
l && z.disposed.has(o), (l ? !o.tState : !o.state) && (o.pure ? g.push(o) : w.push(o), o.observers && at(o)), l || (o.state = C);
|
|
75
75
|
}
|
|
76
76
|
if (g.length > 1e6)
|
|
77
77
|
throw g = [], new Error();
|
|
78
78
|
}, !1)), e;
|
|
79
79
|
}
|
|
80
|
-
function
|
|
80
|
+
function K(t) {
|
|
81
81
|
if (!t.fn) return;
|
|
82
82
|
E(t);
|
|
83
|
-
const e =
|
|
84
|
-
|
|
83
|
+
const e = L;
|
|
84
|
+
wt(t, t.value, e);
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function wt(t, e, n) {
|
|
87
87
|
let s;
|
|
88
|
-
const r =
|
|
89
|
-
p =
|
|
88
|
+
const r = b, o = p;
|
|
89
|
+
p = b = t;
|
|
90
90
|
try {
|
|
91
91
|
s = t.fn(e);
|
|
92
92
|
} catch (l) {
|
|
93
|
-
return t.pure && (t.state =
|
|
93
|
+
return t.pure && (t.state = C, t.owned && t.owned.forEach(E), t.owned = null), t.updatedAt = n + 1, ct(l);
|
|
94
94
|
} finally {
|
|
95
|
-
p = o,
|
|
95
|
+
p = o, b = r;
|
|
96
96
|
}
|
|
97
|
-
(!t.updatedAt || t.updatedAt <= n) && (t.updatedAt != null && "observers" in t ?
|
|
97
|
+
(!t.updatedAt || t.updatedAt <= n) && (t.updatedAt != null && "observers" in t ? st(t, s) : t.value = s, t.updatedAt = n);
|
|
98
98
|
}
|
|
99
|
-
function
|
|
99
|
+
function ot(t, e, n, s = C, r) {
|
|
100
100
|
const o = {
|
|
101
101
|
fn: t,
|
|
102
102
|
state: s,
|
|
@@ -106,60 +106,60 @@ function it(t, e, n, s = m, r) {
|
|
|
106
106
|
sourceSlots: null,
|
|
107
107
|
cleanups: null,
|
|
108
108
|
value: e,
|
|
109
|
-
owner:
|
|
110
|
-
context:
|
|
109
|
+
owner: b,
|
|
110
|
+
context: b ? b.context : null,
|
|
111
111
|
pure: n
|
|
112
112
|
};
|
|
113
|
-
return
|
|
113
|
+
return b === null || b !== et && (b.owned ? b.owned.push(o) : b.owned = [o]), o;
|
|
114
114
|
}
|
|
115
|
-
function
|
|
115
|
+
function it(t) {
|
|
116
116
|
if (t.state === 0) return;
|
|
117
|
-
if (t.state ===
|
|
117
|
+
if (t.state === R) return D(t);
|
|
118
118
|
if (t.suspense && G(t.suspense.inFallback)) return t.suspense.effects.push(t);
|
|
119
119
|
const e = [t];
|
|
120
|
-
for (; (t = t.owner) && (!t.updatedAt || t.updatedAt <
|
|
120
|
+
for (; (t = t.owner) && (!t.updatedAt || t.updatedAt < L); )
|
|
121
121
|
t.state && e.push(t);
|
|
122
122
|
for (let n = e.length - 1; n >= 0; n--)
|
|
123
|
-
if (t = e[n], t.state ===
|
|
124
|
-
|
|
125
|
-
else if (t.state ===
|
|
123
|
+
if (t = e[n], t.state === C)
|
|
124
|
+
K(t);
|
|
125
|
+
else if (t.state === R) {
|
|
126
126
|
const s = g;
|
|
127
|
-
g = null,
|
|
127
|
+
g = null, x(() => D(t, e[0]), !1), g = s;
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function x(t, e) {
|
|
131
131
|
if (g) return t();
|
|
132
132
|
let n = !1;
|
|
133
|
-
e || (g = []),
|
|
133
|
+
e || (g = []), w ? n = !0 : w = [], L++;
|
|
134
134
|
try {
|
|
135
135
|
const s = t();
|
|
136
|
-
return
|
|
136
|
+
return Ct(n), s;
|
|
137
137
|
} catch (s) {
|
|
138
|
-
n || (
|
|
138
|
+
n || (w = null), g = null, ct(s);
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
function
|
|
142
|
-
if (g && (
|
|
143
|
-
const e =
|
|
144
|
-
|
|
141
|
+
function Ct(t) {
|
|
142
|
+
if (g && (lt(g), g = null), t) return;
|
|
143
|
+
const e = w;
|
|
144
|
+
w = null, e.length && x(() => gt(e), !1);
|
|
145
145
|
}
|
|
146
|
-
function
|
|
147
|
-
for (let e = 0; e < t.length; e++)
|
|
146
|
+
function lt(t) {
|
|
147
|
+
for (let e = 0; e < t.length; e++) it(t[e]);
|
|
148
148
|
}
|
|
149
|
-
function
|
|
149
|
+
function D(t, e) {
|
|
150
150
|
t.state = 0;
|
|
151
151
|
for (let n = 0; n < t.sources.length; n += 1) {
|
|
152
152
|
const s = t.sources[n];
|
|
153
153
|
if (s.sources) {
|
|
154
154
|
const r = s.state;
|
|
155
|
-
r ===
|
|
155
|
+
r === C ? s !== e && (!s.updatedAt || s.updatedAt < L) && it(s) : r === R && D(s, e);
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
function
|
|
159
|
+
function at(t) {
|
|
160
160
|
for (let e = 0; e < t.observers.length; e += 1) {
|
|
161
161
|
const n = t.observers[e];
|
|
162
|
-
n.state || (n.state =
|
|
162
|
+
n.state || (n.state = R, n.pure ? g.push(n) : w.push(n), n.observers && at(n));
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
function E(t) {
|
|
@@ -186,19 +186,19 @@ function E(t) {
|
|
|
186
186
|
}
|
|
187
187
|
t.state = 0;
|
|
188
188
|
}
|
|
189
|
-
function
|
|
189
|
+
function St(t) {
|
|
190
190
|
return t instanceof Error ? t : new Error(typeof t == "string" ? t : "Unknown error", {
|
|
191
191
|
cause: t
|
|
192
192
|
});
|
|
193
193
|
}
|
|
194
|
-
function
|
|
195
|
-
throw
|
|
194
|
+
function ct(t, e = b) {
|
|
195
|
+
throw St(t);
|
|
196
196
|
}
|
|
197
|
-
function
|
|
197
|
+
function M(t, e) {
|
|
198
198
|
return G(() => t(e || {}));
|
|
199
199
|
}
|
|
200
|
-
const
|
|
201
|
-
function
|
|
200
|
+
const N = (t) => _t(() => t());
|
|
201
|
+
function mt(t, e, n) {
|
|
202
202
|
let s = n.length, r = e.length, o = s, l = 0, i = 0, a = e[r - 1].nextSibling, u = null;
|
|
203
203
|
for (; l < r || i < o; ) {
|
|
204
204
|
if (e[l] === n[i]) {
|
|
@@ -219,26 +219,26 @@ function xt(t, e, n) {
|
|
|
219
219
|
} else {
|
|
220
220
|
if (!u) {
|
|
221
221
|
u = /* @__PURE__ */ new Map();
|
|
222
|
-
let
|
|
223
|
-
for (;
|
|
222
|
+
let _ = i;
|
|
223
|
+
for (; _ < o; ) u.set(n[_], _++);
|
|
224
224
|
}
|
|
225
225
|
const f = u.get(e[l]);
|
|
226
226
|
if (f != null)
|
|
227
227
|
if (i < f && f < o) {
|
|
228
|
-
let
|
|
229
|
-
for (; ++
|
|
230
|
-
|
|
231
|
-
if (
|
|
232
|
-
const
|
|
233
|
-
for (; i < f; ) t.insertBefore(n[i++],
|
|
228
|
+
let _ = l, v = 1, T;
|
|
229
|
+
for (; ++_ < r && _ < o && !((T = u.get(e[_])) == null || T !== f + v); )
|
|
230
|
+
v++;
|
|
231
|
+
if (v > f - i) {
|
|
232
|
+
const $ = e[l];
|
|
233
|
+
for (; i < f; ) t.insertBefore(n[i++], $);
|
|
234
234
|
} else t.replaceChild(n[i++], e[l++]);
|
|
235
235
|
} else l++;
|
|
236
236
|
else e[l++].remove();
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
|
-
const
|
|
241
|
-
function
|
|
240
|
+
const J = "_$DX_DELEGATE";
|
|
241
|
+
function k(t, e, n, s) {
|
|
242
242
|
let r;
|
|
243
243
|
const o = () => {
|
|
244
244
|
const i = document.createElement("template");
|
|
@@ -246,18 +246,18 @@ function T(t, e, n, s) {
|
|
|
246
246
|
}, l = () => (r || (r = o())).cloneNode(!0);
|
|
247
247
|
return l.cloneNode = l, l;
|
|
248
248
|
}
|
|
249
|
-
function
|
|
250
|
-
const n = e[
|
|
249
|
+
function At(t, e = window.document) {
|
|
250
|
+
const n = e[J] || (e[J] = /* @__PURE__ */ new Set());
|
|
251
251
|
for (let s = 0, r = t.length; s < r; s++) {
|
|
252
252
|
const o = t[s];
|
|
253
|
-
n.has(o) || (n.add(o), e.addEventListener(o,
|
|
253
|
+
n.has(o) || (n.add(o), e.addEventListener(o, Et));
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
|
-
function
|
|
256
|
+
function ut(t, e, n) {
|
|
257
257
|
n == null ? t.removeAttribute(e) : t.setAttribute(e, n);
|
|
258
258
|
}
|
|
259
|
-
function
|
|
260
|
-
if (!e) return n ?
|
|
259
|
+
function vt(t, e, n) {
|
|
260
|
+
if (!e) return n ? ut(t, "style") : e;
|
|
261
261
|
const s = t.style;
|
|
262
262
|
if (typeof e == "string") return s.cssText = e;
|
|
263
263
|
typeof n == "string" && (s.cssText = n = void 0), n || (n = {}), e || (e = {});
|
|
@@ -268,11 +268,11 @@ function kt(t, e, n) {
|
|
|
268
268
|
r = e[o], r !== n[o] && (s.setProperty(o, r), n[o] = r);
|
|
269
269
|
return n;
|
|
270
270
|
}
|
|
271
|
-
function
|
|
272
|
-
if (n !== void 0 && !s && (s = []), typeof e != "function") return
|
|
273
|
-
|
|
271
|
+
function A(t, e, n, s) {
|
|
272
|
+
if (n !== void 0 && !s && (s = []), typeof e != "function") return F(t, e, s, n);
|
|
273
|
+
I((r) => F(t, e(), r, n), s);
|
|
274
274
|
}
|
|
275
|
-
function
|
|
275
|
+
function Et(t) {
|
|
276
276
|
let e = t.target;
|
|
277
277
|
const n = `$$${t.type}`, s = t.target, r = t.currentTarget, o = (a) => Object.defineProperty(t, "target", {
|
|
278
278
|
configurable: !0,
|
|
@@ -306,7 +306,7 @@ function Tt(t) {
|
|
|
306
306
|
} else i();
|
|
307
307
|
o(s);
|
|
308
308
|
}
|
|
309
|
-
function
|
|
309
|
+
function F(t, e, n, s, r) {
|
|
310
310
|
for (; typeof n == "function"; ) n = n();
|
|
311
311
|
if (e === n) return n;
|
|
312
312
|
const o = typeof e, l = s !== void 0;
|
|
@@ -315,30 +315,30 @@ function D(t, e, n, s, r) {
|
|
|
315
315
|
return n;
|
|
316
316
|
if (l) {
|
|
317
317
|
let i = n[0];
|
|
318
|
-
i && i.nodeType === 3 ? i.data !== e && (i.data = e) : i = document.createTextNode(e), n =
|
|
318
|
+
i && i.nodeType === 3 ? i.data !== e && (i.data = e) : i = document.createTextNode(e), n = S(t, n, s, i);
|
|
319
319
|
} else
|
|
320
320
|
n !== "" && typeof n == "string" ? n = t.firstChild.data = e : n = t.textContent = e;
|
|
321
321
|
} else if (e == null || o === "boolean")
|
|
322
|
-
n =
|
|
322
|
+
n = S(t, n, s);
|
|
323
323
|
else {
|
|
324
324
|
if (o === "function")
|
|
325
|
-
return
|
|
325
|
+
return I(() => {
|
|
326
326
|
let i = e();
|
|
327
327
|
for (; typeof i == "function"; ) i = i();
|
|
328
|
-
n =
|
|
328
|
+
n = F(t, i, n, s);
|
|
329
329
|
}), () => n;
|
|
330
330
|
if (Array.isArray(e)) {
|
|
331
331
|
const i = [], a = n && Array.isArray(n);
|
|
332
332
|
if (H(i, e, n, r))
|
|
333
|
-
return
|
|
333
|
+
return I(() => n = F(t, i, n, s, !0)), () => n;
|
|
334
334
|
if (i.length === 0) {
|
|
335
|
-
if (n =
|
|
336
|
-
} else a ? n.length === 0 ?
|
|
335
|
+
if (n = S(t, n, s), l) return n;
|
|
336
|
+
} else a ? n.length === 0 ? Z(t, i, s) : mt(t, n, i) : (n && S(t), Z(t, i));
|
|
337
337
|
n = i;
|
|
338
338
|
} else if (e.nodeType) {
|
|
339
339
|
if (Array.isArray(n)) {
|
|
340
|
-
if (l) return n =
|
|
341
|
-
|
|
340
|
+
if (l) return n = S(t, n, s, e);
|
|
341
|
+
S(t, n, null, e);
|
|
342
342
|
} else n == null || n === "" || !t.firstChild ? t.appendChild(e) : t.replaceChild(e, t.firstChild);
|
|
343
343
|
n = e;
|
|
344
344
|
}
|
|
@@ -366,10 +366,10 @@ function H(t, e, n, s) {
|
|
|
366
366
|
}
|
|
367
367
|
return r;
|
|
368
368
|
}
|
|
369
|
-
function
|
|
369
|
+
function Z(t, e, n = null) {
|
|
370
370
|
for (let s = 0, r = e.length; s < r; s++) t.insertBefore(e[s], n);
|
|
371
371
|
}
|
|
372
|
-
function
|
|
372
|
+
function S(t, e, n, s) {
|
|
373
373
|
if (n === void 0) return t.textContent = "";
|
|
374
374
|
const r = s || document.createTextNode("");
|
|
375
375
|
if (e.length) {
|
|
@@ -384,35 +384,35 @@ function A(t, e, n, s) {
|
|
|
384
384
|
} else t.insertBefore(r, n);
|
|
385
385
|
return [r];
|
|
386
386
|
}
|
|
387
|
-
function
|
|
387
|
+
function xt(t) {
|
|
388
388
|
return Object.keys(t).reduce((n, s) => {
|
|
389
389
|
const r = t[s];
|
|
390
|
-
return n[s] = Object.assign({}, r),
|
|
390
|
+
return n[s] = Object.assign({}, r), dt(r.value) && !Pt(r.value) && !Array.isArray(r.value) && (n[s].value = Object.assign({}, r.value)), Array.isArray(r.value) && (n[s].value = r.value.slice(0)), n;
|
|
391
391
|
}, {});
|
|
392
392
|
}
|
|
393
|
-
function
|
|
393
|
+
function kt(t) {
|
|
394
394
|
return t ? Object.keys(t).reduce((n, s) => {
|
|
395
395
|
const r = t[s];
|
|
396
|
-
return n[s] =
|
|
396
|
+
return n[s] = dt(r) && "value" in r ? r : {
|
|
397
397
|
value: r
|
|
398
|
-
}, n[s].attribute || (n[s].attribute =
|
|
398
|
+
}, n[s].attribute || (n[s].attribute = Ot(s)), n[s].parse = "parse" in n[s] ? n[s].parse : typeof n[s].value != "string", n;
|
|
399
399
|
}, {}) : {};
|
|
400
400
|
}
|
|
401
|
-
function
|
|
401
|
+
function Tt(t) {
|
|
402
402
|
return Object.keys(t).reduce((n, s) => (n[s] = t[s].value, n), {});
|
|
403
403
|
}
|
|
404
|
-
function
|
|
405
|
-
const n =
|
|
404
|
+
function $t(t, e) {
|
|
405
|
+
const n = xt(e);
|
|
406
406
|
return Object.keys(e).forEach((r) => {
|
|
407
407
|
const o = n[r], l = t.getAttribute(o.attribute), i = t[r];
|
|
408
|
-
l != null && (o.value = o.parse ?
|
|
408
|
+
l != null && (o.value = o.parse ? ft(l) : l), i != null && (o.value = Array.isArray(i) ? i.slice(0) : i), o.reflect && Q(t, o.attribute, o.value, !!o.parse), Object.defineProperty(t, r, {
|
|
409
409
|
get() {
|
|
410
410
|
return o.value;
|
|
411
411
|
},
|
|
412
412
|
set(a) {
|
|
413
413
|
const u = o.value;
|
|
414
|
-
o.value = a, o.reflect &&
|
|
415
|
-
for (let f = 0,
|
|
414
|
+
o.value = a, o.reflect && Q(this, o.attribute, o.value, !!o.parse);
|
|
415
|
+
for (let f = 0, _ = this.__propertyChangedCallbacks.length; f < _; f++)
|
|
416
416
|
this.__propertyChangedCallbacks[f](r, a, u);
|
|
417
417
|
},
|
|
418
418
|
enumerable: !0,
|
|
@@ -420,7 +420,7 @@ function Mt(t, e) {
|
|
|
420
420
|
});
|
|
421
421
|
}), n;
|
|
422
422
|
}
|
|
423
|
-
function
|
|
423
|
+
function ft(t) {
|
|
424
424
|
if (t)
|
|
425
425
|
try {
|
|
426
426
|
return JSON.parse(t);
|
|
@@ -428,25 +428,25 @@ function dt(t) {
|
|
|
428
428
|
return t;
|
|
429
429
|
}
|
|
430
430
|
}
|
|
431
|
-
function
|
|
431
|
+
function Q(t, e, n, s) {
|
|
432
432
|
if (n == null || n === !1) return t.removeAttribute(e);
|
|
433
433
|
let r = s ? JSON.stringify(n) : n;
|
|
434
434
|
t.__updating[e] = !0, r === "true" && (r = ""), t.setAttribute(e, r), Promise.resolve().then(() => delete t.__updating[e]);
|
|
435
435
|
}
|
|
436
|
-
function
|
|
436
|
+
function Ot(t) {
|
|
437
437
|
return t.replace(/\.?([A-Z]+)/g, (e, n) => "-" + n.toLowerCase()).replace("_", "-").replace(/^-/, "");
|
|
438
438
|
}
|
|
439
|
-
function
|
|
439
|
+
function dt(t) {
|
|
440
440
|
return t != null && (typeof t == "object" || typeof t == "function");
|
|
441
441
|
}
|
|
442
|
-
function
|
|
442
|
+
function Pt(t) {
|
|
443
443
|
return Object.prototype.toString.call(t) === "[object Function]";
|
|
444
444
|
}
|
|
445
|
-
function
|
|
445
|
+
function Mt(t) {
|
|
446
446
|
return typeof t == "function" && t.toString().indexOf("class") === 0;
|
|
447
447
|
}
|
|
448
|
-
let
|
|
449
|
-
function
|
|
448
|
+
let V;
|
|
449
|
+
function Nt(t, e) {
|
|
450
450
|
const n = Object.keys(e);
|
|
451
451
|
return class extends t {
|
|
452
452
|
static get observedAttributes() {
|
|
@@ -457,16 +457,16 @@ function Rt(t, e) {
|
|
|
457
457
|
}
|
|
458
458
|
connectedCallback() {
|
|
459
459
|
if (this.__initialized) return;
|
|
460
|
-
this.__releaseCallbacks = [], this.__propertyChangedCallbacks = [], this.__updating = {}, this.props =
|
|
461
|
-
const r =
|
|
460
|
+
this.__releaseCallbacks = [], this.__propertyChangedCallbacks = [], this.__updating = {}, this.props = $t(this, e);
|
|
461
|
+
const r = Tt(this.props), o = this.Component, l = V;
|
|
462
462
|
try {
|
|
463
|
-
|
|
463
|
+
V = this, this.__initialized = !0, Mt(o) ? new o(r, {
|
|
464
464
|
element: this
|
|
465
465
|
}) : o(r, {
|
|
466
466
|
element: this
|
|
467
467
|
});
|
|
468
468
|
} finally {
|
|
469
|
-
|
|
469
|
+
V = l;
|
|
470
470
|
}
|
|
471
471
|
}
|
|
472
472
|
async disconnectedCallback() {
|
|
@@ -479,7 +479,7 @@ function Rt(t, e) {
|
|
|
479
479
|
attributeChangedCallback(r, o, l) {
|
|
480
480
|
if (this.__initialized && !this.__updating[r] && (r = this.lookupProp(r), r in e)) {
|
|
481
481
|
if (l == null && !this[r]) return;
|
|
482
|
-
this[r] = e[r].parse ?
|
|
482
|
+
this[r] = e[r].parse ? ft(l) : l;
|
|
483
483
|
}
|
|
484
484
|
}
|
|
485
485
|
lookupProp(r) {
|
|
@@ -499,7 +499,7 @@ function Rt(t, e) {
|
|
|
499
499
|
}
|
|
500
500
|
};
|
|
501
501
|
}
|
|
502
|
-
function
|
|
502
|
+
function jt(t, e = {}, n = {}) {
|
|
503
503
|
const {
|
|
504
504
|
BaseElement: s = HTMLElement,
|
|
505
505
|
extension: r,
|
|
@@ -507,13 +507,13 @@ function It(t, e = {}, n = {}) {
|
|
|
507
507
|
} = n;
|
|
508
508
|
return (l) => {
|
|
509
509
|
let i = o.get(t);
|
|
510
|
-
return i ? (i.prototype.Component = l, i) : (i =
|
|
510
|
+
return i ? (i.prototype.Component = l, i) : (i = Nt(s, kt(e)), i.prototype.Component = l, i.prototype.registeredTag = t, o.define(t, i, r), i);
|
|
511
511
|
};
|
|
512
512
|
}
|
|
513
|
-
function
|
|
513
|
+
function Bt(t) {
|
|
514
514
|
const e = Object.keys(t), n = {};
|
|
515
515
|
for (let s = 0; s < e.length; s++) {
|
|
516
|
-
const [r, o] =
|
|
516
|
+
const [r, o] = nt(t[e[s]]);
|
|
517
517
|
Object.defineProperty(n, e[s], {
|
|
518
518
|
get: r,
|
|
519
519
|
set(l) {
|
|
@@ -523,30 +523,30 @@ function Dt(t) {
|
|
|
523
523
|
}
|
|
524
524
|
return n;
|
|
525
525
|
}
|
|
526
|
-
function
|
|
526
|
+
function Rt(t) {
|
|
527
527
|
if (t.assignedSlot && t.assignedSlot._$owner) return t.assignedSlot._$owner;
|
|
528
528
|
let e = t.parentNode;
|
|
529
529
|
for (; e && !e._$owner && !(e.assignedSlot && e.assignedSlot._$owner); )
|
|
530
530
|
e = e.parentNode;
|
|
531
531
|
return e && e.assignedSlot ? e.assignedSlot._$owner : t._$owner;
|
|
532
532
|
}
|
|
533
|
-
function
|
|
533
|
+
function It(t) {
|
|
534
534
|
return (e, n) => {
|
|
535
535
|
const { element: s } = n;
|
|
536
|
-
return
|
|
537
|
-
const o =
|
|
536
|
+
return yt((r) => {
|
|
537
|
+
const o = Bt(e);
|
|
538
538
|
s.addPropertyChangedCallback((i, a) => o[i] = a), s.addReleaseCallback(() => {
|
|
539
539
|
s.renderRoot.textContent = "", r();
|
|
540
540
|
});
|
|
541
541
|
const l = t(o, n);
|
|
542
|
-
return
|
|
543
|
-
},
|
|
542
|
+
return A(s.renderRoot, l);
|
|
543
|
+
}, Rt(s));
|
|
544
544
|
};
|
|
545
545
|
}
|
|
546
|
-
function
|
|
547
|
-
return arguments.length === 2 && (n = e, e = {}),
|
|
546
|
+
function Dt(t, e, n) {
|
|
547
|
+
return arguments.length === 2 && (n = e, e = {}), jt(t, e)(It(n));
|
|
548
548
|
}
|
|
549
|
-
const
|
|
549
|
+
const Ft = `
|
|
550
550
|
:host([theme="dark"]) {
|
|
551
551
|
color-scheme: only dark;
|
|
552
552
|
}
|
|
@@ -585,125 +585,120 @@ const Ut = `
|
|
|
585
585
|
100% { transform: rotate(360deg); }
|
|
586
586
|
}
|
|
587
587
|
`;
|
|
588
|
-
var
|
|
589
|
-
console.debug("dictate-button version:", "1.1.
|
|
590
|
-
const
|
|
591
|
-
|
|
588
|
+
var Lt = /* @__PURE__ */ k("<div part=container class=dictate-button__container><style></style><button part=button class=dictate-button__button>"), Kt = /* @__PURE__ */ k('<svg part=icon class="dictate-button__icon dictate-button__icon--idle"fill=none viewBox="0 0 24 24"stroke-width=1.5 stroke=currentColor><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">'), Ut = /* @__PURE__ */ k('<svg part=icon class="dictate-button__icon dictate-button__icon--recording"viewBox="0 0 24 24"fill=currentColor><circle cx=12 cy=12 r=10>'), zt = /* @__PURE__ */ k('<svg part=icon class="dictate-button__icon dictate-button__icon--processing"viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=1.5 stroke-linecap=round stroke-linejoin=round><path d="M12 2v4"></path><path d="m16.2 7.8 2.9-2.9"></path><path d="M18 12h4"></path><path d="m16.2 16.2 2.9 2.9"></path><path d="M12 18v4"></path><path d="m4.9 19.1 2.9-2.9"></path><path d="M2 12h4"></path><path d="m4.9 4.9 2.9 2.9">'), Vt = /* @__PURE__ */ k('<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><line x1=12 x2=12 y1=4 y2=14></line><line x1=12 x2=12.01 y1=20 y2=20>');
|
|
589
|
+
console.debug("dictate-button version:", "1.1.2");
|
|
590
|
+
const qt = "https://api.dictate-button.io/transcribe", j = "dictate-button.io", q = -70, Y = -10, tt = 0, Ht = 4, Gt = 0.25, Wt = 0.05;
|
|
591
|
+
Dt("dictate-button", {
|
|
592
592
|
size: 30,
|
|
593
|
-
apiEndpoint:
|
|
593
|
+
apiEndpoint: qt,
|
|
594
594
|
language: void 0
|
|
595
595
|
}, (t, {
|
|
596
596
|
element: e
|
|
597
597
|
}) => {
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
console.debug("api", s);
|
|
604
|
-
const [o, l] = rt("idle");
|
|
605
|
-
let i = null, a = [], u = null, f = null, b = null, w = !1, C = 0;
|
|
606
|
-
const K = (d) => d <= z ? 0 : d >= tt ? 1 : (d - z) / (tt - z), pt = (d) => {
|
|
607
|
-
let _ = 0;
|
|
598
|
+
console.debug("api", t.apiEndpoint);
|
|
599
|
+
const [n, s] = nt("idle");
|
|
600
|
+
let r = null, o = [], l = null, i = null, a = null, u = !1, f = 0;
|
|
601
|
+
const _ = (d) => d <= q ? 0 : d >= Y ? 1 : (d - q) / (Y - q), v = (d) => {
|
|
602
|
+
let y = 0;
|
|
608
603
|
for (let h = 0; h < d.length; h++) {
|
|
609
604
|
const c = (d[h] - 128) / 128;
|
|
610
|
-
|
|
605
|
+
y += c * c;
|
|
611
606
|
}
|
|
612
|
-
return Math.sqrt(
|
|
613
|
-
},
|
|
614
|
-
const
|
|
615
|
-
if (!
|
|
607
|
+
return Math.sqrt(y / d.length);
|
|
608
|
+
}, T = (d) => 20 * Math.log10(Math.max(d, 1e-8)), $ = (d) => {
|
|
609
|
+
const y = e.shadowRoot.querySelector(".dictate-button__button");
|
|
610
|
+
if (!y)
|
|
616
611
|
return;
|
|
617
|
-
const h =
|
|
618
|
-
|
|
619
|
-
},
|
|
620
|
-
if (!
|
|
621
|
-
|
|
622
|
-
const d =
|
|
623
|
-
|
|
612
|
+
const h = tt + d * (Ht - tt), c = 0 + d * 0.4;
|
|
613
|
+
y.style.boxShadow = `0 0 0 ${h}px light-dark(rgba(0, 0, 0, ${c}), rgba(255, 255, 255, ${c}))`;
|
|
614
|
+
}, W = () => {
|
|
615
|
+
if (!u || !i || !a) return;
|
|
616
|
+
i.getByteTimeDomainData(a);
|
|
617
|
+
const d = v(a), y = T(d), h = _(y), c = h > f ? Gt : Wt;
|
|
618
|
+
f = c * h + (1 - c) * f, $(f), requestAnimationFrame(W);
|
|
624
619
|
}, U = () => {
|
|
625
|
-
|
|
620
|
+
r && r.state !== "inactive" && r.stop(), o = [], u = !1, l && l.state !== "closed" && l.close(), l = null, i = null, a = null, f = 0, $(0);
|
|
626
621
|
};
|
|
627
622
|
e.addEventListener("disconnected", U);
|
|
628
|
-
const
|
|
629
|
-
if (U(),
|
|
623
|
+
const ht = async () => {
|
|
624
|
+
if (U(), n() === "idle")
|
|
630
625
|
try {
|
|
631
626
|
const d = await navigator.mediaDevices.getUserMedia({
|
|
632
627
|
audio: !0
|
|
633
628
|
});
|
|
634
|
-
|
|
635
|
-
const
|
|
636
|
-
|
|
629
|
+
l = new (window.AudioContext || window.webkitAudioContext)();
|
|
630
|
+
const y = l.createMediaStreamSource(d);
|
|
631
|
+
i = l.createAnalyser(), i.fftSize = 2048, y.connect(i), a = new Uint8Array(i.fftSize), r = new MediaRecorder(d, {
|
|
637
632
|
mimeType: "audio/webm"
|
|
638
|
-
}),
|
|
639
|
-
|
|
640
|
-
},
|
|
641
|
-
|
|
642
|
-
const h = new Blob(
|
|
633
|
+
}), o = [], r.ondataavailable = (h) => {
|
|
634
|
+
o.push(h.data);
|
|
635
|
+
}, r.onstop = async () => {
|
|
636
|
+
u = !1, s("processing"), m(e, "transcribing:started", "Started transcribing");
|
|
637
|
+
const h = new Blob(o, {
|
|
643
638
|
type: "audio/webm"
|
|
644
639
|
});
|
|
645
640
|
try {
|
|
646
641
|
const c = new FormData();
|
|
647
|
-
c.append("audio", h, "recording.webm"), c.append("origin", window?.location?.origin),
|
|
648
|
-
const
|
|
642
|
+
c.append("audio", h, "recording.webm"), c.append("origin", window?.location?.origin), t.language && c.append("language", t.language);
|
|
643
|
+
const O = await fetch(t.apiEndpoint, {
|
|
649
644
|
method: "POST",
|
|
650
645
|
body: c
|
|
651
646
|
});
|
|
652
|
-
if (
|
|
653
|
-
const
|
|
654
|
-
if (
|
|
655
|
-
|
|
647
|
+
if (!O.ok) throw new Error("Failed to transcribe audio");
|
|
648
|
+
const P = await O.json();
|
|
649
|
+
if (n() !== "processing") return;
|
|
650
|
+
m(e, "transcribing:finished", P.text), s("idle");
|
|
656
651
|
} catch (c) {
|
|
657
|
-
console.error("Failed to transcribe audio:", c),
|
|
652
|
+
console.error("Failed to transcribe audio:", c), m(e, "transcribing:failed", "Failed to transcribe audio"), X();
|
|
658
653
|
}
|
|
659
|
-
},
|
|
654
|
+
}, r.start(), m(e, "recording:started", "Started recording"), u = !0, W(), s("recording");
|
|
660
655
|
} catch (d) {
|
|
661
|
-
console.error("Failed to start recording:", d),
|
|
656
|
+
console.error("Failed to start recording:", d), m(e, "recording:failed", "Failed to start recording"), X();
|
|
662
657
|
}
|
|
663
658
|
else
|
|
664
|
-
|
|
665
|
-
},
|
|
666
|
-
|
|
659
|
+
m(e, "recording:stopped", "Stopped recording"), s("idle"), U();
|
|
660
|
+
}, X = () => {
|
|
661
|
+
s("error"), setTimeout(() => s("idle"), 2e3);
|
|
667
662
|
};
|
|
668
663
|
return (() => {
|
|
669
|
-
var d =
|
|
670
|
-
return
|
|
671
|
-
var c =
|
|
672
|
-
return () => c() &&
|
|
673
|
-
})(), null),
|
|
674
|
-
var c =
|
|
675
|
-
return () => c() &&
|
|
676
|
-
})(), null),
|
|
677
|
-
var c =
|
|
678
|
-
return () => c() &&
|
|
679
|
-
})(), null),
|
|
680
|
-
var c =
|
|
681
|
-
return () => c() &&
|
|
682
|
-
})(), null),
|
|
683
|
-
var
|
|
684
|
-
return c.e =
|
|
664
|
+
var d = Lt(), y = d.firstChild, h = y.nextSibling;
|
|
665
|
+
return A(y, Ft), h.$$click = ht, A(h, (() => {
|
|
666
|
+
var c = N(() => n() === "idle");
|
|
667
|
+
return () => c() && M(Jt, {});
|
|
668
|
+
})(), null), A(h, (() => {
|
|
669
|
+
var c = N(() => n() === "recording");
|
|
670
|
+
return () => c() && M(Zt, {});
|
|
671
|
+
})(), null), A(h, (() => {
|
|
672
|
+
var c = N(() => n() === "processing");
|
|
673
|
+
return () => c() && M(Qt, {});
|
|
674
|
+
})(), null), A(h, (() => {
|
|
675
|
+
var c = N(() => n() === "error");
|
|
676
|
+
return () => c() && M(Yt, {});
|
|
677
|
+
})(), null), I((c) => {
|
|
678
|
+
var O = `width:${t.size}px;height:${t.size}px"`, P = Xt(n());
|
|
679
|
+
return c.e = vt(h, O, c.e), P !== c.t && ut(h, "title", c.t = P), c;
|
|
685
680
|
}, {
|
|
686
681
|
e: void 0,
|
|
687
682
|
t: void 0
|
|
688
683
|
}), d;
|
|
689
684
|
})();
|
|
690
685
|
});
|
|
691
|
-
const
|
|
686
|
+
const Xt = (t) => {
|
|
692
687
|
switch (t) {
|
|
693
688
|
case "idle":
|
|
694
|
-
return `Start dictation (${
|
|
689
|
+
return `Start dictation (${j})`;
|
|
695
690
|
case "recording":
|
|
696
|
-
return `Stop dictation (${
|
|
691
|
+
return `Stop dictation (${j})`;
|
|
697
692
|
case "processing":
|
|
698
|
-
return `Stop processing (${
|
|
693
|
+
return `Stop processing (${j})`;
|
|
699
694
|
case "error":
|
|
700
|
-
return `Click to reset (${
|
|
695
|
+
return `Click to reset (${j})`;
|
|
701
696
|
}
|
|
702
|
-
},
|
|
697
|
+
}, m = (t, e, n) => {
|
|
703
698
|
t.dispatchEvent(new CustomEvent(e, {
|
|
704
699
|
detail: n,
|
|
705
700
|
bubbles: !0,
|
|
706
701
|
composed: !0
|
|
707
702
|
}));
|
|
708
|
-
},
|
|
709
|
-
|
|
703
|
+
}, Jt = () => Kt(), Zt = () => Ut(), Qt = () => zt(), Yt = () => Vt();
|
|
704
|
+
At(["click"]);
|
package/dist/inject-exclusive.js
CHANGED
|
@@ -12,7 +12,7 @@ function g() {
|
|
|
12
12
|
const e = document.createElement("dictate-button");
|
|
13
13
|
e.size = 30, e.style.position = "absolute", e.style.right = "0", e.style.top = T(a, n) + "px", e.style.margin = "10px";
|
|
14
14
|
const s = document.documentElement.lang;
|
|
15
|
-
s && s.length
|
|
15
|
+
s && s.length >= 2 && (e.language = s), e.addEventListener("recording:started", (o) => {
|
|
16
16
|
console.log("recording:started", o);
|
|
17
17
|
}), e.addEventListener("recording:stopped", (o) => {
|
|
18
18
|
console.log("recording:stopped", o);
|
package/dist/inject-inclusive.js
CHANGED
|
@@ -12,7 +12,7 @@ function g() {
|
|
|
12
12
|
const e = document.createElement("dictate-button");
|
|
13
13
|
e.size = 30, e.style.position = "absolute", e.style.right = "0", e.style.top = f(a, n) + "px", e.style.margin = "10px";
|
|
14
14
|
const s = document.documentElement.lang;
|
|
15
|
-
s && s.length
|
|
15
|
+
s && s.length >= 2 && (e.language = s), e.addEventListener("recording:started", (o) => {
|
|
16
16
|
console.log("recording:started", o);
|
|
17
17
|
}), e.addEventListener("recording:stopped", (o) => {
|
|
18
18
|
console.log("recording:stopped", o);
|