dictate-button 1.1.2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/dictate-button.js +348 -315
- package/dist/dictate-button.styles.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,6 +15,7 @@ Developed for [dictate-button.io](https://dictate-button.io).
|
|
|
15
15
|
- Dark and light theme support
|
|
16
16
|
- Event-based API for interaction with your application
|
|
17
17
|
- Built with SolidJS for optimal performance
|
|
18
|
+
- Accessibility is ensured with ARIA attributes, high-contrast mode support, and clear keyboard focus states
|
|
18
19
|
|
|
19
20
|
## Supported tags (by our inject scripts)
|
|
20
21
|
|
package/dist/dictate-button.js
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
const
|
|
2
|
-
equals:
|
|
1
|
+
const wt = (t, e) => t === e, B = {
|
|
2
|
+
equals: wt
|
|
3
3
|
};
|
|
4
|
-
let
|
|
5
|
-
const
|
|
4
|
+
let vt = ht;
|
|
5
|
+
const S = 1, R = 2, lt = {
|
|
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,
|
|
11
|
+
var _ = null;
|
|
12
|
+
let V = null, Ct = null, p = null, g = null, m = null, L = 0;
|
|
13
|
+
function mt(t, e) {
|
|
14
|
+
const n = p, o = _, r = t.length === 0, i = e === void 0 ? o : e, l = r ? lt : {
|
|
15
15
|
owned: null,
|
|
16
16
|
cleanups: null,
|
|
17
|
-
context:
|
|
18
|
-
owner:
|
|
19
|
-
},
|
|
20
|
-
|
|
17
|
+
context: i ? i.context : null,
|
|
18
|
+
owner: i
|
|
19
|
+
}, s = r ? t : () => t(() => W(() => $(l)));
|
|
20
|
+
_ = l, p = null;
|
|
21
21
|
try {
|
|
22
|
-
return
|
|
22
|
+
return T(s, !0);
|
|
23
23
|
} finally {
|
|
24
|
-
p = n,
|
|
24
|
+
p = n, _ = o;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function at(t, e) {
|
|
28
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
|
-
},
|
|
35
|
-
return [
|
|
34
|
+
}, o = (r) => (typeof r == "function" && (r = r(n.value)), ut(n, r));
|
|
35
|
+
return [ct.bind(n), o];
|
|
36
36
|
}
|
|
37
37
|
function I(t, e, n) {
|
|
38
|
-
const
|
|
39
|
-
K(
|
|
38
|
+
const o = dt(t, e, !1, S);
|
|
39
|
+
K(o);
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function St(t, e, n) {
|
|
42
42
|
n = n ? Object.assign({}, B, n) : B;
|
|
43
|
-
const
|
|
44
|
-
return
|
|
43
|
+
const o = dt(t, e, !0, 0);
|
|
44
|
+
return o.observers = null, o.observerSlots = null, o.comparator = n.equals || void 0, K(o), ct.bind(o);
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function W(t) {
|
|
47
47
|
if (p === null) return t();
|
|
48
48
|
const e = p;
|
|
49
49
|
p = null;
|
|
@@ -53,12 +53,12 @@ function G(t) {
|
|
|
53
53
|
p = e;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
function
|
|
56
|
+
function ct() {
|
|
57
57
|
if (this.sources && this.state)
|
|
58
|
-
if (this.state ===
|
|
58
|
+
if (this.state === S) K(this);
|
|
59
59
|
else {
|
|
60
60
|
const t = g;
|
|
61
|
-
g = null,
|
|
61
|
+
g = null, T(() => D(this), !1), g = t;
|
|
62
62
|
}
|
|
63
63
|
if (p) {
|
|
64
64
|
const t = this.observers ? this.observers.length : 0;
|
|
@@ -66,12 +66,12 @@ function rt() {
|
|
|
66
66
|
}
|
|
67
67
|
return this.value;
|
|
68
68
|
}
|
|
69
|
-
function
|
|
70
|
-
let
|
|
71
|
-
return (!t.comparator || !t.comparator(
|
|
69
|
+
function ut(t, e, n) {
|
|
70
|
+
let o = t.value;
|
|
71
|
+
return (!t.comparator || !t.comparator(o, e)) && (t.value = e, t.observers && t.observers.length && T(() => {
|
|
72
72
|
for (let r = 0; r < t.observers.length; r += 1) {
|
|
73
|
-
const
|
|
74
|
-
l &&
|
|
73
|
+
const i = t.observers[r], l = V && V.running;
|
|
74
|
+
l && V.disposed.has(i), (l ? !i.tState : !i.state) && (i.pure ? g.push(i) : m.push(i), i.observers && pt(i)), l || (i.state = S);
|
|
75
75
|
}
|
|
76
76
|
if (g.length > 1e6)
|
|
77
77
|
throw g = [], new Error();
|
|
@@ -79,105 +79,105 @@ function st(t, e, n) {
|
|
|
79
79
|
}
|
|
80
80
|
function K(t) {
|
|
81
81
|
if (!t.fn) return;
|
|
82
|
-
|
|
82
|
+
$(t);
|
|
83
83
|
const e = L;
|
|
84
|
-
|
|
84
|
+
xt(t, t.value, e);
|
|
85
85
|
}
|
|
86
|
-
function
|
|
87
|
-
let
|
|
88
|
-
const r =
|
|
89
|
-
p =
|
|
86
|
+
function xt(t, e, n) {
|
|
87
|
+
let o;
|
|
88
|
+
const r = _, i = p;
|
|
89
|
+
p = _ = t;
|
|
90
90
|
try {
|
|
91
|
-
|
|
91
|
+
o = t.fn(e);
|
|
92
92
|
} catch (l) {
|
|
93
|
-
return t.pure && (t.state =
|
|
93
|
+
return t.pure && (t.state = S, t.owned && t.owned.forEach($), t.owned = null), t.updatedAt = n + 1, gt(l);
|
|
94
94
|
} finally {
|
|
95
|
-
p =
|
|
95
|
+
p = i, _ = 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 ? ut(t, o) : t.value = o, t.updatedAt = n);
|
|
98
98
|
}
|
|
99
|
-
function
|
|
100
|
-
const
|
|
99
|
+
function dt(t, e, n, o = S, r) {
|
|
100
|
+
const i = {
|
|
101
101
|
fn: t,
|
|
102
|
-
state:
|
|
102
|
+
state: o,
|
|
103
103
|
updatedAt: null,
|
|
104
104
|
owned: null,
|
|
105
105
|
sources: null,
|
|
106
106
|
sourceSlots: null,
|
|
107
107
|
cleanups: null,
|
|
108
108
|
value: e,
|
|
109
|
-
owner:
|
|
110
|
-
context:
|
|
109
|
+
owner: _,
|
|
110
|
+
context: _ ? _.context : null,
|
|
111
111
|
pure: n
|
|
112
112
|
};
|
|
113
|
-
return
|
|
113
|
+
return _ === null || _ !== lt && (_.owned ? _.owned.push(i) : _.owned = [i]), i;
|
|
114
114
|
}
|
|
115
|
-
function
|
|
115
|
+
function ft(t) {
|
|
116
116
|
if (t.state === 0) return;
|
|
117
117
|
if (t.state === R) return D(t);
|
|
118
|
-
if (t.suspense &&
|
|
118
|
+
if (t.suspense && W(t.suspense.inFallback)) return t.suspense.effects.push(t);
|
|
119
119
|
const e = [t];
|
|
120
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 ===
|
|
123
|
+
if (t = e[n], t.state === S)
|
|
124
124
|
K(t);
|
|
125
125
|
else if (t.state === R) {
|
|
126
|
-
const
|
|
127
|
-
g = null,
|
|
126
|
+
const o = g;
|
|
127
|
+
g = null, T(() => D(t, e[0]), !1), g = o;
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function T(t, e) {
|
|
131
131
|
if (g) return t();
|
|
132
132
|
let n = !1;
|
|
133
|
-
e || (g = []),
|
|
133
|
+
e || (g = []), m ? n = !0 : m = [], L++;
|
|
134
134
|
try {
|
|
135
|
-
const
|
|
136
|
-
return
|
|
137
|
-
} catch (
|
|
138
|
-
n || (
|
|
135
|
+
const o = t();
|
|
136
|
+
return At(n), o;
|
|
137
|
+
} catch (o) {
|
|
138
|
+
n || (m = null), g = null, gt(o);
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
function
|
|
142
|
-
if (g && (
|
|
143
|
-
const e =
|
|
144
|
-
|
|
141
|
+
function At(t) {
|
|
142
|
+
if (g && (ht(g), g = null), t) return;
|
|
143
|
+
const e = m;
|
|
144
|
+
m = null, e.length && T(() => vt(e), !1);
|
|
145
145
|
}
|
|
146
|
-
function
|
|
147
|
-
for (let e = 0; e < t.length; e++)
|
|
146
|
+
function ht(t) {
|
|
147
|
+
for (let e = 0; e < t.length; e++) ft(t[e]);
|
|
148
148
|
}
|
|
149
149
|
function D(t, e) {
|
|
150
150
|
t.state = 0;
|
|
151
151
|
for (let n = 0; n < t.sources.length; n += 1) {
|
|
152
|
-
const
|
|
153
|
-
if (
|
|
154
|
-
const r =
|
|
155
|
-
r ===
|
|
152
|
+
const o = t.sources[n];
|
|
153
|
+
if (o.sources) {
|
|
154
|
+
const r = o.state;
|
|
155
|
+
r === S ? o !== e && (!o.updatedAt || o.updatedAt < L) && ft(o) : r === R && D(o, e);
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
function
|
|
159
|
+
function pt(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 = R, n.pure ? g.push(n) :
|
|
162
|
+
n.state || (n.state = R, n.pure ? g.push(n) : m.push(n), n.observers && pt(n));
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
|
-
function
|
|
165
|
+
function $(t) {
|
|
166
166
|
let e;
|
|
167
167
|
if (t.sources)
|
|
168
168
|
for (; t.sources.length; ) {
|
|
169
|
-
const n = t.sources.pop(),
|
|
169
|
+
const n = t.sources.pop(), o = t.sourceSlots.pop(), r = n.observers;
|
|
170
170
|
if (r && r.length) {
|
|
171
|
-
const
|
|
172
|
-
|
|
171
|
+
const i = r.pop(), l = n.observerSlots.pop();
|
|
172
|
+
o < r.length && (i.sourceSlots[l] = o, r[o] = i, n.observerSlots[o] = l);
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
if (t.tOwned) {
|
|
176
|
-
for (e = t.tOwned.length - 1; e >= 0; e--)
|
|
176
|
+
for (e = t.tOwned.length - 1; e >= 0; e--) $(t.tOwned[e]);
|
|
177
177
|
delete t.tOwned;
|
|
178
178
|
}
|
|
179
179
|
if (t.owned) {
|
|
180
|
-
for (e = t.owned.length - 1; e >= 0; e--)
|
|
180
|
+
for (e = t.owned.length - 1; e >= 0; e--) $(t.owned[e]);
|
|
181
181
|
t.owned = null;
|
|
182
182
|
}
|
|
183
183
|
if (t.cleanups) {
|
|
@@ -186,95 +186,95 @@ function E(t) {
|
|
|
186
186
|
}
|
|
187
187
|
t.state = 0;
|
|
188
188
|
}
|
|
189
|
-
function
|
|
189
|
+
function Et(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 gt(t, e = _) {
|
|
195
|
+
throw Et(t);
|
|
196
196
|
}
|
|
197
|
-
function
|
|
198
|
-
return
|
|
197
|
+
function N(t, e) {
|
|
198
|
+
return W(() => t(e || {}));
|
|
199
199
|
}
|
|
200
|
-
const
|
|
201
|
-
function
|
|
202
|
-
let
|
|
203
|
-
for (; l < r ||
|
|
204
|
-
if (e[l] === n[
|
|
205
|
-
l++,
|
|
200
|
+
const j = (t) => St(() => t());
|
|
201
|
+
function kt(t, e, n) {
|
|
202
|
+
let o = n.length, r = e.length, i = o, l = 0, s = 0, a = e[r - 1].nextSibling, u = null;
|
|
203
|
+
for (; l < r || s < i; ) {
|
|
204
|
+
if (e[l] === n[s]) {
|
|
205
|
+
l++, s++;
|
|
206
206
|
continue;
|
|
207
207
|
}
|
|
208
|
-
for (; e[r - 1] === n[
|
|
209
|
-
r--,
|
|
208
|
+
for (; e[r - 1] === n[i - 1]; )
|
|
209
|
+
r--, i--;
|
|
210
210
|
if (r === l) {
|
|
211
|
-
const
|
|
212
|
-
for (;
|
|
213
|
-
} else if (
|
|
211
|
+
const d = i < o ? s ? n[s - 1].nextSibling : n[i - s] : a;
|
|
212
|
+
for (; s < i; ) t.insertBefore(n[s++], d);
|
|
213
|
+
} else if (i === s)
|
|
214
214
|
for (; l < r; )
|
|
215
215
|
(!u || !u.has(e[l])) && e[l].remove(), l++;
|
|
216
|
-
else if (e[l] === n[
|
|
217
|
-
const
|
|
218
|
-
t.insertBefore(n[
|
|
216
|
+
else if (e[l] === n[i - 1] && n[s] === e[r - 1]) {
|
|
217
|
+
const d = e[--r].nextSibling;
|
|
218
|
+
t.insertBefore(n[s++], e[l++].nextSibling), t.insertBefore(n[--i], d), e[r] = n[i];
|
|
219
219
|
} else {
|
|
220
220
|
if (!u) {
|
|
221
221
|
u = /* @__PURE__ */ new Map();
|
|
222
|
-
let
|
|
223
|
-
for (;
|
|
222
|
+
let w = s;
|
|
223
|
+
for (; w < i; ) u.set(n[w], w++);
|
|
224
224
|
}
|
|
225
|
-
const
|
|
226
|
-
if (
|
|
227
|
-
if (
|
|
228
|
-
let
|
|
229
|
-
for (; ++
|
|
230
|
-
|
|
231
|
-
if (
|
|
232
|
-
const
|
|
233
|
-
for (;
|
|
234
|
-
} else t.replaceChild(n[
|
|
225
|
+
const d = u.get(e[l]);
|
|
226
|
+
if (d != null)
|
|
227
|
+
if (s < d && d < i) {
|
|
228
|
+
let w = l, E = 1, P;
|
|
229
|
+
for (; ++w < r && w < i && !((P = u.get(e[w])) == null || P !== d + E); )
|
|
230
|
+
E++;
|
|
231
|
+
if (E > d - s) {
|
|
232
|
+
const M = e[l];
|
|
233
|
+
for (; s < d; ) t.insertBefore(n[s++], M);
|
|
234
|
+
} else t.replaceChild(n[s++], e[l++]);
|
|
235
235
|
} else l++;
|
|
236
236
|
else e[l++].remove();
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
|
-
const
|
|
241
|
-
function
|
|
240
|
+
const et = "_$DX_DELEGATE";
|
|
241
|
+
function O(t, e, n, o) {
|
|
242
242
|
let r;
|
|
243
|
-
const
|
|
244
|
-
const
|
|
245
|
-
return
|
|
246
|
-
}, l = () => (r || (r =
|
|
243
|
+
const i = () => {
|
|
244
|
+
const s = document.createElement("template");
|
|
245
|
+
return s.innerHTML = t, s.content.firstChild;
|
|
246
|
+
}, l = () => (r || (r = i())).cloneNode(!0);
|
|
247
247
|
return l.cloneNode = l, l;
|
|
248
248
|
}
|
|
249
|
-
function
|
|
250
|
-
const n = e[
|
|
251
|
-
for (let
|
|
252
|
-
const
|
|
253
|
-
n.has(
|
|
249
|
+
function $t(t, e = window.document) {
|
|
250
|
+
const n = e[et] || (e[et] = /* @__PURE__ */ new Set());
|
|
251
|
+
for (let o = 0, r = t.length; o < r; o++) {
|
|
252
|
+
const i = t[o];
|
|
253
|
+
n.has(i) || (n.add(i), e.addEventListener(i, Ot));
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
|
-
function
|
|
256
|
+
function k(t, e, n) {
|
|
257
257
|
n == null ? t.removeAttribute(e) : t.setAttribute(e, n);
|
|
258
258
|
}
|
|
259
|
-
function
|
|
260
|
-
if (!e) return n ?
|
|
261
|
-
const
|
|
262
|
-
if (typeof e == "string") return
|
|
263
|
-
typeof n == "string" && (
|
|
264
|
-
let r,
|
|
265
|
-
for (
|
|
266
|
-
e[
|
|
267
|
-
for (
|
|
268
|
-
r = e[
|
|
259
|
+
function Tt(t, e, n) {
|
|
260
|
+
if (!e) return n ? k(t, "style") : e;
|
|
261
|
+
const o = t.style;
|
|
262
|
+
if (typeof e == "string") return o.cssText = e;
|
|
263
|
+
typeof n == "string" && (o.cssText = n = void 0), n || (n = {}), e || (e = {});
|
|
264
|
+
let r, i;
|
|
265
|
+
for (i in n)
|
|
266
|
+
e[i] == null && o.removeProperty(i), delete n[i];
|
|
267
|
+
for (i in e)
|
|
268
|
+
r = e[i], r !== n[i] && (o.setProperty(i, r), n[i] = r);
|
|
269
269
|
return n;
|
|
270
270
|
}
|
|
271
|
-
function
|
|
272
|
-
if (n !== void 0 && !
|
|
273
|
-
I((r) => F(t, e(), r, n),
|
|
271
|
+
function C(t, e, n, o) {
|
|
272
|
+
if (n !== void 0 && !o && (o = []), typeof e != "function") return F(t, e, o, n);
|
|
273
|
+
I((r) => F(t, e(), r, n), o);
|
|
274
274
|
}
|
|
275
|
-
function
|
|
275
|
+
function Ot(t) {
|
|
276
276
|
let e = t.target;
|
|
277
|
-
const n = `$$${t.type}`,
|
|
277
|
+
const n = `$$${t.type}`, o = t.target, r = t.currentTarget, i = (a) => Object.defineProperty(t, "target", {
|
|
278
278
|
configurable: !0,
|
|
279
279
|
value: a
|
|
280
280
|
}), l = () => {
|
|
@@ -283,8 +283,8 @@ function Et(t) {
|
|
|
283
283
|
const u = e[`${n}Data`];
|
|
284
284
|
if (u !== void 0 ? a.call(e, u, t) : a.call(e, t), t.cancelBubble) return;
|
|
285
285
|
}
|
|
286
|
-
return e.host && typeof e.host != "string" && !e.host._$host && e.contains(t.target) &&
|
|
287
|
-
},
|
|
286
|
+
return e.host && typeof e.host != "string" && !e.host._$host && e.contains(t.target) && i(e.host), !0;
|
|
287
|
+
}, s = () => {
|
|
288
288
|
for (; l() && (e = e._$host || e.parentNode || e.host); ) ;
|
|
289
289
|
};
|
|
290
290
|
if (Object.defineProperty(t, "currentTarget", {
|
|
@@ -294,133 +294,133 @@ function Et(t) {
|
|
|
294
294
|
}
|
|
295
295
|
}), t.composedPath) {
|
|
296
296
|
const a = t.composedPath();
|
|
297
|
-
|
|
297
|
+
i(a[0]);
|
|
298
298
|
for (let u = 0; u < a.length - 2 && (e = a[u], !!l()); u++) {
|
|
299
299
|
if (e._$host) {
|
|
300
|
-
e = e._$host,
|
|
300
|
+
e = e._$host, s();
|
|
301
301
|
break;
|
|
302
302
|
}
|
|
303
303
|
if (e.parentNode === r)
|
|
304
304
|
break;
|
|
305
305
|
}
|
|
306
|
-
} else
|
|
307
|
-
o
|
|
306
|
+
} else s();
|
|
307
|
+
i(o);
|
|
308
308
|
}
|
|
309
|
-
function F(t, e, n,
|
|
309
|
+
function F(t, e, n, o, r) {
|
|
310
310
|
for (; typeof n == "function"; ) n = n();
|
|
311
311
|
if (e === n) return n;
|
|
312
|
-
const
|
|
313
|
-
if (t = l && n[0] && n[0].parentNode || t,
|
|
314
|
-
if (
|
|
312
|
+
const i = typeof e, l = o !== void 0;
|
|
313
|
+
if (t = l && n[0] && n[0].parentNode || t, i === "string" || i === "number") {
|
|
314
|
+
if (i === "number" && (e = e.toString(), e === n))
|
|
315
315
|
return n;
|
|
316
316
|
if (l) {
|
|
317
|
-
let
|
|
318
|
-
|
|
317
|
+
let s = n[0];
|
|
318
|
+
s && s.nodeType === 3 ? s.data !== e && (s.data = e) : s = document.createTextNode(e), n = x(t, n, o, s);
|
|
319
319
|
} else
|
|
320
320
|
n !== "" && typeof n == "string" ? n = t.firstChild.data = e : n = t.textContent = e;
|
|
321
|
-
} else if (e == null ||
|
|
322
|
-
n =
|
|
321
|
+
} else if (e == null || i === "boolean")
|
|
322
|
+
n = x(t, n, o);
|
|
323
323
|
else {
|
|
324
|
-
if (
|
|
324
|
+
if (i === "function")
|
|
325
325
|
return I(() => {
|
|
326
|
-
let
|
|
327
|
-
for (; typeof
|
|
328
|
-
n = F(t,
|
|
326
|
+
let s = e();
|
|
327
|
+
for (; typeof s == "function"; ) s = s();
|
|
328
|
+
n = F(t, s, n, o);
|
|
329
329
|
}), () => n;
|
|
330
330
|
if (Array.isArray(e)) {
|
|
331
|
-
const
|
|
332
|
-
if (
|
|
333
|
-
return I(() => n = F(t,
|
|
334
|
-
if (
|
|
335
|
-
if (n =
|
|
336
|
-
} else a ? n.length === 0 ?
|
|
337
|
-
n =
|
|
331
|
+
const s = [], a = n && Array.isArray(n);
|
|
332
|
+
if (G(s, e, n, r))
|
|
333
|
+
return I(() => n = F(t, s, n, o, !0)), () => n;
|
|
334
|
+
if (s.length === 0) {
|
|
335
|
+
if (n = x(t, n, o), l) return n;
|
|
336
|
+
} else a ? n.length === 0 ? nt(t, s, o) : kt(t, n, s) : (n && x(t), nt(t, s));
|
|
337
|
+
n = s;
|
|
338
338
|
} else if (e.nodeType) {
|
|
339
339
|
if (Array.isArray(n)) {
|
|
340
|
-
if (l) return n =
|
|
341
|
-
|
|
340
|
+
if (l) return n = x(t, n, o, e);
|
|
341
|
+
x(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
|
}
|
|
345
345
|
}
|
|
346
346
|
return n;
|
|
347
347
|
}
|
|
348
|
-
function
|
|
348
|
+
function G(t, e, n, o) {
|
|
349
349
|
let r = !1;
|
|
350
|
-
for (let
|
|
351
|
-
let
|
|
352
|
-
if (!(
|
|
353
|
-
t.push(
|
|
354
|
-
else if (Array.isArray(
|
|
355
|
-
r =
|
|
350
|
+
for (let i = 0, l = e.length; i < l; i++) {
|
|
351
|
+
let s = e[i], a = n && n[t.length], u;
|
|
352
|
+
if (!(s == null || s === !0 || s === !1)) if ((u = typeof s) == "object" && s.nodeType)
|
|
353
|
+
t.push(s);
|
|
354
|
+
else if (Array.isArray(s))
|
|
355
|
+
r = G(t, s, a) || r;
|
|
356
356
|
else if (u === "function")
|
|
357
|
-
if (
|
|
358
|
-
for (; typeof
|
|
359
|
-
r =
|
|
357
|
+
if (o) {
|
|
358
|
+
for (; typeof s == "function"; ) s = s();
|
|
359
|
+
r = G(t, Array.isArray(s) ? s : [s], Array.isArray(a) ? a : [a]) || r;
|
|
360
360
|
} else
|
|
361
|
-
t.push(
|
|
361
|
+
t.push(s), r = !0;
|
|
362
362
|
else {
|
|
363
|
-
const
|
|
364
|
-
a && a.nodeType === 3 && a.data ===
|
|
363
|
+
const d = String(s);
|
|
364
|
+
a && a.nodeType === 3 && a.data === d ? t.push(a) : t.push(document.createTextNode(d));
|
|
365
365
|
}
|
|
366
366
|
}
|
|
367
367
|
return r;
|
|
368
368
|
}
|
|
369
|
-
function
|
|
370
|
-
for (let
|
|
369
|
+
function nt(t, e, n = null) {
|
|
370
|
+
for (let o = 0, r = e.length; o < r; o++) t.insertBefore(e[o], n);
|
|
371
371
|
}
|
|
372
|
-
function
|
|
372
|
+
function x(t, e, n, o) {
|
|
373
373
|
if (n === void 0) return t.textContent = "";
|
|
374
|
-
const r =
|
|
374
|
+
const r = o || document.createTextNode("");
|
|
375
375
|
if (e.length) {
|
|
376
|
-
let
|
|
376
|
+
let i = !1;
|
|
377
377
|
for (let l = e.length - 1; l >= 0; l--) {
|
|
378
|
-
const
|
|
379
|
-
if (r !==
|
|
380
|
-
const a =
|
|
381
|
-
!
|
|
382
|
-
} else
|
|
378
|
+
const s = e[l];
|
|
379
|
+
if (r !== s) {
|
|
380
|
+
const a = s.parentNode === t;
|
|
381
|
+
!i && !l ? a ? t.replaceChild(r, s) : t.insertBefore(r, n) : a && s.remove();
|
|
382
|
+
} else i = !0;
|
|
383
383
|
}
|
|
384
384
|
} else t.insertBefore(r, n);
|
|
385
385
|
return [r];
|
|
386
386
|
}
|
|
387
|
-
function
|
|
388
|
-
return Object.keys(t).reduce((n,
|
|
389
|
-
const r = t[
|
|
390
|
-
return n[
|
|
387
|
+
function Pt(t) {
|
|
388
|
+
return Object.keys(t).reduce((n, o) => {
|
|
389
|
+
const r = t[o];
|
|
390
|
+
return n[o] = Object.assign({}, r), _t(r.value) && !Rt(r.value) && !Array.isArray(r.value) && (n[o].value = Object.assign({}, r.value)), Array.isArray(r.value) && (n[o].value = r.value.slice(0)), n;
|
|
391
391
|
}, {});
|
|
392
392
|
}
|
|
393
|
-
function
|
|
394
|
-
return t ? Object.keys(t).reduce((n,
|
|
395
|
-
const r = t[
|
|
396
|
-
return n[
|
|
393
|
+
function Mt(t) {
|
|
394
|
+
return t ? Object.keys(t).reduce((n, o) => {
|
|
395
|
+
const r = t[o];
|
|
396
|
+
return n[o] = _t(r) && "value" in r ? r : {
|
|
397
397
|
value: r
|
|
398
|
-
}, n[
|
|
398
|
+
}, n[o].attribute || (n[o].attribute = Bt(o)), n[o].parse = "parse" in n[o] ? n[o].parse : typeof n[o].value != "string", n;
|
|
399
399
|
}, {}) : {};
|
|
400
400
|
}
|
|
401
|
-
function
|
|
402
|
-
return Object.keys(t).reduce((n,
|
|
401
|
+
function Nt(t) {
|
|
402
|
+
return Object.keys(t).reduce((n, o) => (n[o] = t[o].value, n), {});
|
|
403
403
|
}
|
|
404
|
-
function
|
|
405
|
-
const n =
|
|
404
|
+
function jt(t, e) {
|
|
405
|
+
const n = Pt(e);
|
|
406
406
|
return Object.keys(e).forEach((r) => {
|
|
407
|
-
const
|
|
408
|
-
l != null && (
|
|
407
|
+
const i = n[r], l = t.getAttribute(i.attribute), s = t[r];
|
|
408
|
+
l != null && (i.value = i.parse ? bt(l) : l), s != null && (i.value = Array.isArray(s) ? s.slice(0) : s), i.reflect && rt(t, i.attribute, i.value, !!i.parse), Object.defineProperty(t, r, {
|
|
409
409
|
get() {
|
|
410
|
-
return
|
|
410
|
+
return i.value;
|
|
411
411
|
},
|
|
412
412
|
set(a) {
|
|
413
|
-
const u =
|
|
414
|
-
|
|
415
|
-
for (let
|
|
416
|
-
this.__propertyChangedCallbacks[
|
|
413
|
+
const u = i.value;
|
|
414
|
+
i.value = a, i.reflect && rt(this, i.attribute, i.value, !!i.parse);
|
|
415
|
+
for (let d = 0, w = this.__propertyChangedCallbacks.length; d < w; d++)
|
|
416
|
+
this.__propertyChangedCallbacks[d](r, a, u);
|
|
417
417
|
},
|
|
418
418
|
enumerable: !0,
|
|
419
419
|
configurable: !0
|
|
420
420
|
});
|
|
421
421
|
}), n;
|
|
422
422
|
}
|
|
423
|
-
function
|
|
423
|
+
function bt(t) {
|
|
424
424
|
if (t)
|
|
425
425
|
try {
|
|
426
426
|
return JSON.parse(t);
|
|
@@ -428,25 +428,25 @@ function ft(t) {
|
|
|
428
428
|
return t;
|
|
429
429
|
}
|
|
430
430
|
}
|
|
431
|
-
function
|
|
431
|
+
function rt(t, e, n, o) {
|
|
432
432
|
if (n == null || n === !1) return t.removeAttribute(e);
|
|
433
|
-
let r =
|
|
433
|
+
let r = o ? 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 Bt(t) {
|
|
437
437
|
return t.replace(/\.?([A-Z]+)/g, (e, n) => "-" + n.toLowerCase()).replace("_", "-").replace(/^-/, "");
|
|
438
438
|
}
|
|
439
|
-
function
|
|
439
|
+
function _t(t) {
|
|
440
440
|
return t != null && (typeof t == "object" || typeof t == "function");
|
|
441
441
|
}
|
|
442
|
-
function
|
|
442
|
+
function Rt(t) {
|
|
443
443
|
return Object.prototype.toString.call(t) === "[object Function]";
|
|
444
444
|
}
|
|
445
|
-
function
|
|
445
|
+
function It(t) {
|
|
446
446
|
return typeof t == "function" && t.toString().indexOf("class") === 0;
|
|
447
447
|
}
|
|
448
|
-
let
|
|
449
|
-
function
|
|
448
|
+
let q;
|
|
449
|
+
function Dt(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 Nt(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 = jt(this, e);
|
|
461
|
+
const r = Nt(this.props), i = this.Component, l = q;
|
|
462
462
|
try {
|
|
463
|
-
|
|
463
|
+
q = this, this.__initialized = !0, It(i) ? new i(r, {
|
|
464
464
|
element: this
|
|
465
|
-
}) :
|
|
465
|
+
}) : i(r, {
|
|
466
466
|
element: this
|
|
467
467
|
});
|
|
468
468
|
} finally {
|
|
469
|
-
|
|
469
|
+
q = l;
|
|
470
470
|
}
|
|
471
471
|
}
|
|
472
472
|
async disconnectedCallback() {
|
|
@@ -476,15 +476,15 @@ function Nt(t, e) {
|
|
|
476
476
|
for (; r = this.__releaseCallbacks.pop(); ) r(this);
|
|
477
477
|
delete this.__initialized, this.__released = !0;
|
|
478
478
|
}
|
|
479
|
-
attributeChangedCallback(r,
|
|
479
|
+
attributeChangedCallback(r, i, 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 ? bt(l) : l;
|
|
483
483
|
}
|
|
484
484
|
}
|
|
485
485
|
lookupProp(r) {
|
|
486
486
|
if (e)
|
|
487
|
-
return n.find((
|
|
487
|
+
return n.find((i) => r === i || r === e[i].attribute);
|
|
488
488
|
}
|
|
489
489
|
get renderRoot() {
|
|
490
490
|
return this.shadowRoot || this.attachShadow({
|
|
@@ -499,54 +499,54 @@ function Nt(t, e) {
|
|
|
499
499
|
}
|
|
500
500
|
};
|
|
501
501
|
}
|
|
502
|
-
function
|
|
502
|
+
function Ft(t, e = {}, n = {}) {
|
|
503
503
|
const {
|
|
504
|
-
BaseElement:
|
|
504
|
+
BaseElement: o = HTMLElement,
|
|
505
505
|
extension: r,
|
|
506
|
-
customElements:
|
|
506
|
+
customElements: i = window.customElements
|
|
507
507
|
} = n;
|
|
508
508
|
return (l) => {
|
|
509
|
-
let
|
|
510
|
-
return
|
|
509
|
+
let s = i.get(t);
|
|
510
|
+
return s ? (s.prototype.Component = l, s) : (s = Dt(o, Mt(e)), s.prototype.Component = l, s.prototype.registeredTag = t, i.define(t, s, r), s);
|
|
511
511
|
};
|
|
512
512
|
}
|
|
513
|
-
function
|
|
513
|
+
function Lt(t) {
|
|
514
514
|
const e = Object.keys(t), n = {};
|
|
515
|
-
for (let
|
|
516
|
-
const [r,
|
|
517
|
-
Object.defineProperty(n, e[
|
|
515
|
+
for (let o = 0; o < e.length; o++) {
|
|
516
|
+
const [r, i] = at(t[e[o]]);
|
|
517
|
+
Object.defineProperty(n, e[o], {
|
|
518
518
|
get: r,
|
|
519
519
|
set(l) {
|
|
520
|
-
|
|
520
|
+
i(() => l);
|
|
521
521
|
}
|
|
522
522
|
});
|
|
523
523
|
}
|
|
524
524
|
return n;
|
|
525
525
|
}
|
|
526
|
-
function
|
|
526
|
+
function Kt(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 Ut(t) {
|
|
534
534
|
return (e, n) => {
|
|
535
|
-
const { element:
|
|
536
|
-
return
|
|
537
|
-
const
|
|
538
|
-
|
|
539
|
-
|
|
535
|
+
const { element: o } = n;
|
|
536
|
+
return mt((r) => {
|
|
537
|
+
const i = Lt(e);
|
|
538
|
+
o.addPropertyChangedCallback((s, a) => i[s] = a), o.addReleaseCallback(() => {
|
|
539
|
+
o.renderRoot.textContent = "", r();
|
|
540
540
|
});
|
|
541
|
-
const l = t(
|
|
542
|
-
return
|
|
543
|
-
},
|
|
541
|
+
const l = t(i, n);
|
|
542
|
+
return C(o.renderRoot, l);
|
|
543
|
+
}, Kt(o));
|
|
544
544
|
};
|
|
545
545
|
}
|
|
546
|
-
function
|
|
547
|
-
return arguments.length === 2 && (n = e, e = {}),
|
|
546
|
+
function zt(t, e, n) {
|
|
547
|
+
return arguments.length === 2 && (n = e, e = {}), Ft(t, e)(Ut(n));
|
|
548
548
|
}
|
|
549
|
-
const
|
|
549
|
+
const Vt = `
|
|
550
550
|
:host([theme="dark"]) {
|
|
551
551
|
color-scheme: only dark;
|
|
552
552
|
}
|
|
@@ -560,15 +560,25 @@ const Ft = `
|
|
|
560
560
|
display: inline-flex;
|
|
561
561
|
align-items: center;
|
|
562
562
|
justify-content: center;
|
|
563
|
-
color: light-dark(rgba(0, 0, 0, 0.
|
|
564
|
-
background-color: light-dark(rgba(0, 0, 0, 0.
|
|
563
|
+
color: light-dark(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 1));
|
|
564
|
+
background-color: light-dark(rgba(0, 0, 0, 0.08), rgba(255, 255, 255, 0.85));
|
|
565
565
|
border-radius: 50%;
|
|
566
566
|
border: none;
|
|
567
|
-
transition: box-shadow 0.05s linear;
|
|
567
|
+
transition: box-shadow 0.05s linear, background-color 0.2s ease;
|
|
568
568
|
box-sizing: border-box;
|
|
569
569
|
}
|
|
570
|
-
:host .dictate-button__button:hover
|
|
571
|
-
background-color: light-dark(rgba(0, 0, 0, 0.
|
|
570
|
+
:host .dictate-button__button:hover {
|
|
571
|
+
background-color: light-dark(rgba(0, 0, 0, 0.15), rgba(255, 255, 255, 0.7));
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
:host .dictate-button__button:focus {
|
|
575
|
+
background-color: light-dark(rgba(0, 0, 0, 0.15), rgba(255, 255, 255, 0.7));
|
|
576
|
+
outline: none;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
:host .dictate-button__button:focus-visible {
|
|
580
|
+
outline: 2px solid light-dark(rgba(0, 0, 0, 0.8), rgba(255, 255, 255, 0.8));
|
|
581
|
+
outline-offset: 2px;
|
|
572
582
|
}
|
|
573
583
|
|
|
574
584
|
:host .dictate-button__button .dictate-button__icon {
|
|
@@ -584,121 +594,144 @@ const Ft = `
|
|
|
584
594
|
0% { transform: rotate(0deg); }
|
|
585
595
|
100% { transform: rotate(360deg); }
|
|
586
596
|
}
|
|
597
|
+
|
|
598
|
+
@media (forced-colors: active) {
|
|
599
|
+
:host .dictate-button__button {
|
|
600
|
+
border: 1px solid currentColor;
|
|
601
|
+
}
|
|
602
|
+
:host .dictate-button__button:focus-visible {
|
|
603
|
+
outline: 3px solid currentColor;
|
|
604
|
+
}
|
|
605
|
+
}
|
|
587
606
|
`;
|
|
588
|
-
var
|
|
589
|
-
console.debug("dictate-button version:", "1.
|
|
590
|
-
const
|
|
591
|
-
|
|
607
|
+
var qt = /* @__PURE__ */ O('<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>'), Ht = /* @__PURE__ */ O('<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">'), Gt = /* @__PURE__ */ O('<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>'), Wt = /* @__PURE__ */ O('<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 role=img aria-hidden=true><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">'), Xt = /* @__PURE__ */ O('<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>');
|
|
608
|
+
console.debug("dictate-button version:", "1.2.0");
|
|
609
|
+
const Jt = "https://api.dictate-button.io/transcribe", v = "dictate-button.io", H = -70, ot = -10, it = 0, Zt = 4, Qt = 0.25, Yt = 0.05;
|
|
610
|
+
zt("dictate-button", {
|
|
592
611
|
size: 30,
|
|
593
|
-
apiEndpoint:
|
|
612
|
+
apiEndpoint: Jt,
|
|
594
613
|
language: void 0
|
|
595
614
|
}, (t, {
|
|
596
615
|
element: e
|
|
597
616
|
}) => {
|
|
598
617
|
console.debug("api", t.apiEndpoint);
|
|
599
|
-
const [n,
|
|
600
|
-
let r = null,
|
|
601
|
-
const
|
|
618
|
+
const [n, o] = at("idle");
|
|
619
|
+
let r = null, i = [], l = null, s = null, a = null, u = !1, d = 0;
|
|
620
|
+
const w = (f) => f <= H ? 0 : f >= ot ? 1 : (f - H) / (ot - H), E = (f) => {
|
|
602
621
|
let y = 0;
|
|
603
|
-
for (let
|
|
604
|
-
const c = (
|
|
622
|
+
for (let b = 0; b < f.length; b++) {
|
|
623
|
+
const c = (f[b] - 128) / 128;
|
|
605
624
|
y += c * c;
|
|
606
625
|
}
|
|
607
|
-
return Math.sqrt(y /
|
|
608
|
-
},
|
|
626
|
+
return Math.sqrt(y / f.length);
|
|
627
|
+
}, P = (f) => 20 * Math.log10(Math.max(f, 1e-8)), M = (f) => {
|
|
609
628
|
const y = e.shadowRoot.querySelector(".dictate-button__button");
|
|
610
629
|
if (!y)
|
|
611
630
|
return;
|
|
612
|
-
const
|
|
613
|
-
y.style.boxShadow = `0 0 0 ${
|
|
614
|
-
},
|
|
615
|
-
if (!u || !
|
|
616
|
-
|
|
617
|
-
const
|
|
618
|
-
|
|
631
|
+
const b = it + f * (Zt - it), c = 0 + f * 0.4;
|
|
632
|
+
y.style.boxShadow = `0 0 0 ${b}px light-dark(rgba(0, 0, 0, ${c}), rgba(255, 255, 255, ${c}))`;
|
|
633
|
+
}, X = () => {
|
|
634
|
+
if (!u || !s || !a) return;
|
|
635
|
+
s.getByteTimeDomainData(a);
|
|
636
|
+
const f = E(a), y = P(f), b = w(y), c = b > d ? Qt : Yt;
|
|
637
|
+
d = c * b + (1 - c) * d, M(d), requestAnimationFrame(X);
|
|
619
638
|
}, U = () => {
|
|
620
|
-
r && r.state !== "inactive" && r.stop(),
|
|
639
|
+
r && r.state !== "inactive" && r.stop(), i = [], u = !1, l && l.state !== "closed" && l.close(), l = null, s = null, a = null, d = 0, M(0);
|
|
621
640
|
};
|
|
622
641
|
e.addEventListener("disconnected", U);
|
|
623
|
-
const
|
|
642
|
+
const yt = async () => {
|
|
624
643
|
if (U(), n() === "idle")
|
|
625
644
|
try {
|
|
626
|
-
const
|
|
645
|
+
const f = await navigator.mediaDevices.getUserMedia({
|
|
627
646
|
audio: !0
|
|
628
647
|
});
|
|
629
648
|
l = new (window.AudioContext || window.webkitAudioContext)();
|
|
630
|
-
const y = l.createMediaStreamSource(
|
|
631
|
-
|
|
649
|
+
const y = l.createMediaStreamSource(f);
|
|
650
|
+
s = l.createAnalyser(), s.fftSize = 2048, y.connect(s), a = new Uint8Array(s.fftSize), r = new MediaRecorder(f, {
|
|
632
651
|
mimeType: "audio/webm"
|
|
633
|
-
}),
|
|
634
|
-
|
|
652
|
+
}), i = [], r.ondataavailable = (b) => {
|
|
653
|
+
i.push(b.data);
|
|
635
654
|
}, r.onstop = async () => {
|
|
636
|
-
u = !1,
|
|
637
|
-
const
|
|
655
|
+
u = !1, o("processing"), A(e, "transcribing:started", "Started transcribing");
|
|
656
|
+
const b = new Blob(i, {
|
|
638
657
|
type: "audio/webm"
|
|
639
658
|
});
|
|
640
659
|
try {
|
|
641
660
|
const c = new FormData();
|
|
642
|
-
c.append("audio",
|
|
643
|
-
const
|
|
661
|
+
c.append("audio", b, "recording.webm"), c.append("origin", window?.location?.origin), t.language && c.append("language", t.language);
|
|
662
|
+
const h = await fetch(t.apiEndpoint, {
|
|
644
663
|
method: "POST",
|
|
645
664
|
body: c
|
|
646
665
|
});
|
|
647
|
-
if (!
|
|
648
|
-
const
|
|
666
|
+
if (!h.ok) throw new Error("Failed to transcribe audio");
|
|
667
|
+
const z = await h.json();
|
|
649
668
|
if (n() !== "processing") return;
|
|
650
|
-
|
|
669
|
+
A(e, "transcribing:finished", z.text), o("idle");
|
|
651
670
|
} catch (c) {
|
|
652
|
-
console.error("Failed to transcribe audio:", c),
|
|
671
|
+
console.error("Failed to transcribe audio:", c), A(e, "transcribing:failed", "Failed to transcribe audio"), J();
|
|
653
672
|
}
|
|
654
|
-
}, r.start(),
|
|
655
|
-
} catch (
|
|
656
|
-
console.error("Failed to start recording:",
|
|
673
|
+
}, r.start(), A(e, "recording:started", "Started recording"), u = !0, X(), o("recording");
|
|
674
|
+
} catch (f) {
|
|
675
|
+
console.error("Failed to start recording:", f), A(e, "recording:failed", "Failed to start recording"), J();
|
|
657
676
|
}
|
|
658
677
|
else
|
|
659
|
-
|
|
660
|
-
},
|
|
661
|
-
|
|
678
|
+
A(e, "recording:stopped", "Stopped recording"), o("idle"), U();
|
|
679
|
+
}, J = () => {
|
|
680
|
+
o("error"), setTimeout(() => o("idle"), 2e3);
|
|
662
681
|
};
|
|
663
682
|
return (() => {
|
|
664
|
-
var
|
|
665
|
-
return
|
|
666
|
-
var
|
|
667
|
-
return () =>
|
|
668
|
-
})(), null),
|
|
669
|
-
var
|
|
670
|
-
return () =>
|
|
671
|
-
})(), null),
|
|
672
|
-
var
|
|
673
|
-
return () =>
|
|
674
|
-
})(), null),
|
|
675
|
-
var
|
|
676
|
-
return () =>
|
|
677
|
-
})(), null), I((
|
|
678
|
-
var
|
|
679
|
-
return
|
|
683
|
+
var f = qt(), y = f.firstChild, b = y.nextSibling, c = b.nextSibling;
|
|
684
|
+
return C(y, Vt), C(b, () => st(n())), c.$$click = yt, C(c, (() => {
|
|
685
|
+
var h = j(() => n() === "idle");
|
|
686
|
+
return () => h() && N(ee, {});
|
|
687
|
+
})(), null), C(c, (() => {
|
|
688
|
+
var h = j(() => n() === "recording");
|
|
689
|
+
return () => h() && N(ne, {});
|
|
690
|
+
})(), null), C(c, (() => {
|
|
691
|
+
var h = j(() => n() === "processing");
|
|
692
|
+
return () => h() && N(re, {});
|
|
693
|
+
})(), null), C(c, (() => {
|
|
694
|
+
var h = j(() => n() === "error");
|
|
695
|
+
return () => h() && N(oe, {});
|
|
696
|
+
})(), null), I((h) => {
|
|
697
|
+
var z = `width:${t.size}px;height:${t.size}px"`, Z = te(n()), Q = st(n()), Y = n() === "recording", tt = n() === "processing";
|
|
698
|
+
return h.e = Tt(c, z, h.e), Z !== h.t && k(c, "title", h.t = Z), Q !== h.a && k(c, "aria-label", h.a = Q), Y !== h.o && k(c, "aria-pressed", h.o = Y), tt !== h.i && k(c, "aria-busy", h.i = tt), h;
|
|
680
699
|
}, {
|
|
681
700
|
e: void 0,
|
|
682
|
-
t: void 0
|
|
683
|
-
|
|
701
|
+
t: void 0,
|
|
702
|
+
a: void 0,
|
|
703
|
+
o: void 0,
|
|
704
|
+
i: void 0
|
|
705
|
+
}), f;
|
|
684
706
|
})();
|
|
685
707
|
});
|
|
686
|
-
const
|
|
708
|
+
const te = (t) => {
|
|
709
|
+
switch (t) {
|
|
710
|
+
case "idle":
|
|
711
|
+
return `Start dictation (${v})`;
|
|
712
|
+
case "recording":
|
|
713
|
+
return `Stop dictation (${v})`;
|
|
714
|
+
case "processing":
|
|
715
|
+
return `Stop processing (${v})`;
|
|
716
|
+
case "error":
|
|
717
|
+
return `Click to reset (${v})`;
|
|
718
|
+
}
|
|
719
|
+
}, st = (t) => {
|
|
687
720
|
switch (t) {
|
|
688
721
|
case "idle":
|
|
689
|
-
return `Start dictation (${
|
|
722
|
+
return `Start dictation (${v})`;
|
|
690
723
|
case "recording":
|
|
691
|
-
return `
|
|
724
|
+
return `Dictation in progress. Click to stop it (${v})`;
|
|
692
725
|
case "processing":
|
|
693
|
-
return `
|
|
726
|
+
return `Processing dictation. Click to cancel it (${v})`;
|
|
694
727
|
case "error":
|
|
695
|
-
return `Click to reset (${
|
|
728
|
+
return `Dictation error. Click to reset (${v})`;
|
|
696
729
|
}
|
|
697
|
-
},
|
|
730
|
+
}, A = (t, e, n) => {
|
|
698
731
|
t.dispatchEvent(new CustomEvent(e, {
|
|
699
732
|
detail: n,
|
|
700
733
|
bubbles: !0,
|
|
701
734
|
composed: !0
|
|
702
735
|
}));
|
|
703
|
-
},
|
|
704
|
-
|
|
736
|
+
}, ee = () => Ht(), ne = () => Gt(), re = () => Wt(), oe = () => Xt();
|
|
737
|
+
$t(["click"]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const dictateButtonStyles = "\n:host([theme=\"dark\"]) {\n color-scheme: only dark;\n}\n:host([theme=\"light\"]) {\n color-scheme: only light;\n}\n\n:host .dictate-button__button {\n cursor: pointer;\n padding: 8px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n color: light-dark(rgba(0, 0, 0, 0.
|
|
1
|
+
export declare const dictateButtonStyles = "\n:host([theme=\"dark\"]) {\n color-scheme: only dark;\n}\n:host([theme=\"light\"]) {\n color-scheme: only light;\n}\n\n:host .dictate-button__button {\n cursor: pointer;\n padding: 8px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n color: light-dark(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 1));\n background-color: light-dark(rgba(0, 0, 0, 0.08), rgba(255, 255, 255, 0.85));\n border-radius: 50%;\n border: none;\n transition: box-shadow 0.05s linear, background-color 0.2s ease;\n box-sizing: border-box;\n}\n:host .dictate-button__button:hover {\n background-color: light-dark(rgba(0, 0, 0, 0.15), rgba(255, 255, 255, 0.7));\n}\n\n:host .dictate-button__button:focus {\n background-color: light-dark(rgba(0, 0, 0, 0.15), rgba(255, 255, 255, 0.7));\n outline: none;\n}\n\n:host .dictate-button__button:focus-visible {\n outline: 2px solid light-dark(rgba(0, 0, 0, 0.8), rgba(255, 255, 255, 0.8));\n outline-offset: 2px;\n}\n\n:host .dictate-button__button .dictate-button__icon {\n width: 100%;\n height: 100%;\n}\n\n:host .dictate-button__button .dictate-button__icon.dictate-button__icon--processing {\n animation: dictate-button-rotate 1s linear infinite;\n}\n\n@keyframes dictate-button-rotate {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n}\n\n@media (forced-colors: active) {\n :host .dictate-button__button {\n border: 1px solid currentColor;\n }\n :host .dictate-button__button:focus-visible {\n outline: 3px solid currentColor;\n }\n}\n";
|