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.
Files changed (2) hide show
  1. package/dist/dictate-button.js +165 -163
  2. package/package.json +1 -1
@@ -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, s = y, r = t.length === 0, o = e === void 0 ? s : e, l = r ? bt : {
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
- }, i = r ? t : () => t(() => Y(() => j(l)));
19
+ }, s = r ? t : () => t(() => Y(() => j(l)));
20
20
  y = l, b = null;
21
21
  try {
22
- return B(i, !0);
22
+ return B(s, !0);
23
23
  } finally {
24
- b = n, y = s;
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
- }, s = (r) => (typeof r == "function" && (r = r(n.value)), wt(n, r));
35
- return [_t.bind(n), s];
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 s = it(t, e, !1, T);
39
- I(s);
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 s = it(t, e, !1, T);
44
- s.user = !0, S ? S.push(s) : I(s);
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 s = it(t, e, !0, 0);
49
- return s.observers = null, s.observerSlots = null, s.comparator = n.equals || void 0, I(s), _t.bind(s);
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 s = t.value;
79
- return (!t.comparator || !t.comparator(s, e)) && (t.value = e, t.observers && t.observers.length && B(() => {
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 s;
95
+ let i;
96
96
  const r = y, o = b;
97
97
  b = y = t;
98
98
  try {
99
- s = t.fn(e);
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, s) : t.value = s, t.updatedAt = n);
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 it(t, e, n, s = T, r) {
107
+ function st(t, e, n, i = T, r) {
108
108
  const o = {
109
109
  fn: t,
110
- state: s,
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 s = w;
135
- w = null, B(() => X(t, e[0]), !1), w = s;
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 s = t();
144
- return jt(n), s;
145
- } catch (s) {
146
- n || (S = null), w = null, Ct(s);
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 s = t[e];
161
- s.user ? t[n++] = s : G(s);
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 s = t.sources[n];
169
- if (s.sources) {
170
- const r = s.state;
171
- r === T ? s !== e && (!s.updatedAt || s.updatedAt < Q) && G(s) : r === H && X(s, e);
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(), s = t.sourceSlots.pop(), r = n.observers;
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
- s < r.length && (o.sourceSlots[l] = s, r[s] = o, n.observerSlots[s] = l);
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 s = n.length, r = e.length, o = s, l = 0, i = 0, a = e[r - 1].nextSibling, g = null;
219
- for (; l < r || i < o; ) {
220
- if (e[l] === n[i]) {
221
- l++, i++;
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 < s ? i ? n[i - 1].nextSibling : n[o - i] : a;
228
- for (; i < o; ) t.insertBefore(n[i++], f);
229
- } else if (o === i)
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[i] === e[r - 1]) {
232
+ else if (e[l] === n[o - 1] && n[s] === e[r - 1]) {
233
233
  const f = e[--r].nextSibling;
234
- t.insertBefore(n[i++], e[l++].nextSibling), t.insertBefore(n[--o], f), e[r] = n[o];
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 = i;
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 (i < f && f < o) {
244
- let d = l, m = 1, u;
245
- for (; ++d < r && d < o && !((u = g.get(e[d])) == null || u !== f + m); )
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 - i) {
247
+ if (m > f - s) {
248
248
  const P = e[l];
249
- for (; i < f; ) t.insertBefore(n[i++], P);
250
- } else t.replaceChild(n[i++], e[l++]);
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, s) {
256
+ function D(t, e, n, i) {
257
257
  let r;
258
258
  const o = () => {
259
- const i = document.createElement("template");
260
- return i.innerHTML = t, i.content.firstChild;
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 s = t.style;
270
- if (typeof e == "string") return s.cssText = e;
271
- typeof n == "string" && (s.cssText = n = void 0), n || (n = {}), e || (e = {});
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 && s.removeProperty(o), delete n[o];
274
+ e[o] == null && i.removeProperty(o), delete n[o];
275
275
  for (o in e)
276
- r = e[o], r !== n[o] && (s.setProperty(o, r), n[o] = r);
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, s) {
283
- if (n !== void 0 && !s && (s = []), typeof e != "function") return Z(t, e, s, n);
284
- J((r) => Z(t, e(), r, n), s);
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, s, r) {
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 = s !== void 0;
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 i = n[0];
295
- i && i.nodeType === 3 ? i.data !== e && (i.data = e) : i = document.createTextNode(e), n = $(t, n, s, i);
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, s);
299
+ n = $(t, n, i);
300
300
  else {
301
301
  if (o === "function")
302
302
  return J(() => {
303
- let i = e();
304
- for (; typeof i == "function"; ) i = i();
305
- n = Z(t, i, n, s);
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 i = [], a = n && Array.isArray(n);
309
- if (st(i, e, n, r))
310
- return J(() => n = Z(t, i, n, s, !0)), () => n;
311
- if (i.length === 0) {
312
- if (n = $(t, n, s), l) return n;
313
- } else a ? n.length === 0 ? ut(t, i, s) : Dt(t, n, i) : (n && $(t), ut(t, i));
314
- n = i;
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, s, e);
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 st(t, e, n, s) {
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 i = e[o], a = n && n[t.length], g;
329
- if (!(i == null || i === !0 || i === !1)) if ((g = typeof i) == "object" && i.nodeType)
330
- t.push(i);
331
- else if (Array.isArray(i))
332
- r = st(t, i, a) || 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 (s) {
335
- for (; typeof i == "function"; ) i = i();
336
- r = st(t, Array.isArray(i) ? i : [i], Array.isArray(a) ? a : [a]) || 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(i), r = !0;
338
+ t.push(s), r = !0;
339
339
  else {
340
- const f = String(i);
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 s = 0, r = e.length; s < r; s++) t.insertBefore(e[s], n);
347
+ for (let i = 0, r = e.length; i < r; i++) t.insertBefore(e[i], n);
348
348
  }
349
- function $(t, e, n, s) {
349
+ function $(t, e, n, i) {
350
350
  if (n === void 0) return t.textContent = "";
351
- const r = s || document.createTextNode("");
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 i = e[l];
356
- if (r !== i) {
357
- const a = i.parentNode === t;
358
- !o && !l ? a ? t.replaceChild(r, i) : t.insertBefore(r, n) : a && i.remove();
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, s) => {
366
- const r = t[s];
367
- return n[s] = Object.assign({}, r), St(r.value) && !Ht(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;
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, s) => {
372
- const r = t[s];
373
- return n[s] = St(r) && "value" in r ? r : {
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[s].attribute || (n[s].attribute = qt(s)), n[s].parse = "parse" in n[s] ? n[s].parse : typeof n[s].value != "string", 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, s) => (n[s] = t[s].value, 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), i = t[r];
385
- l != null && (o.value = o.parse ? xt(l) : l), i != null && (o.value = Array.isArray(i) ? i.slice(0) : i), o.reflect && ft(t, o.attribute, o.value, !!o.parse), Object.defineProperty(t, r, {
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, s) {
408
+ function ft(t, e, n, i) {
409
409
  if (n == null || n === !1) return t.removeAttribute(e);
410
- let r = s ? JSON.stringify(n) : n;
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: s = HTMLElement,
483
+ BaseElement: i = HTMLElement,
484
484
  extension: r,
485
485
  customElements: o = window.customElements
486
486
  } = n;
487
487
  return (l) => {
488
- let i = o.get(t);
489
- return i ? (i.prototype.Component = l, i) : (i = Gt(s, Wt(e)), i.prototype.Component = l, i.prototype.registeredTag = t, o.define(t, i, r), i);
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 s = 0; s < e.length; s++) {
495
- const [r, o] = yt(t[e[s]]);
496
- Object.defineProperty(n, e[s], {
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: s } = n;
514
+ const { element: i } = n;
515
515
  return Lt((r) => {
516
516
  const o = Zt(e);
517
- s.addPropertyChangedCallback((i, a) => o[i] = a), s.addReleaseCallback(() => {
518
- s.renderRoot.textContent = "", r();
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(s.renderRoot, l);
522
- }, Qt(s));
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">'), se = /* @__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>'), ie = /* @__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.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, s] = yt("idle");
598
- let r = null, o = null, l = null, i = "", a = "", g = -1, f = "", d = null, m = null, u = null, P = null, U = !1, R = 0;
599
- const Et = (c) => c <= rt ? 0 : c >= dt ? 1 : (c - rt) / (dt - rt), At = (c) => {
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 < c.length; C++) {
602
- const p = (c[C] - 128) / 128;
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(_ / c.length);
606
- }, kt = (c) => 20 * Math.log10(Math.max(c, 1e-8)), ot = (c) => {
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 + c * (ae - pt), p = 0 + c * 0.4;
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 c = At(P), _ = kt(c), C = Et(_), p = C > R ? ce : ue;
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), u && (u.disconnect(), u = null), o && (o.getTracks().forEach((c) => c.stop()), o = null), l = null, i = "", a = "", g = -1, f = "", U = !1, d && d.state !== "closed" && d.close(), d = null, m = null, P = null, R = 0, ot(0);
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 (c) => {
621
+ const at = async (u) => {
622
622
  if (n() === "idle") {
623
- l = c, i = "", a = "", g = -1, f = "";
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), u = new AudioWorkletNode(d, "pcm-processor"), C.connect(u);
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, i, f].filter(Boolean).join(" ");
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 ? (i && (a = a ? a + " " + i : i), g = M, i = x) : x.length > i.length && x.startsWith(i.substring(0, Math.min(10, i.length))) ? i = x : i = i ? i + " " + x : x;
670
- const Tt = a ? a + " " + i : i;
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
- }, u.port.onmessage = (E) => {
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(), s("transcribing");
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, s("finalizing"), r && r.readyState === WebSocket.OPEN)
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 c = a ? a + (i ? " " + i : "") : i;
693
- c && A(e, "dictate-end", c), O(), s("idle");
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 c = a ? a + (i ? " " + i : "") : i;
697
- c && A(e, "dictate-end", c), O(), s("idle");
696
+ const u = a ? a + (s ? " " + s : "") : s;
697
+ u && A(e, "dictate-end", u), O(), i("idle");
698
698
  }
699
699
  }, tt = () => {
700
- s("error"), setTimeout(() => s("idle"), 2e3);
700
+ i("error"), setTimeout(() => i("idle"), 2e3);
701
701
  };
702
702
  let z;
703
703
  return Ot(() => {
704
704
  if (!z) return;
705
- const c = be(z, {
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(c);
716
+ Rt(u);
717
717
  }), (() => {
718
- var c = ne(), _ = c.firstChild, C = _.nextSibling, p = C.nextSibling;
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
- }), c;
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 = () => se(), he = () => ie(), ge = () => oe();
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: s,
777
+ onShortTap: i,
778
778
  onLongPressStart: r,
779
779
  onLongPressEnd: o
780
780
  } = {}) {
781
- let l, i = !1;
782
- const a = (u) => u.preventDefault(), g = (u) => {
783
- l && clearTimeout(l), i = !1, u.preventDefault(), t.setPointerCapture(u.pointerId), l = window.setTimeout(() => {
784
- i = !0, r?.(u), t.dispatchEvent(new CustomEvent("longpress", {
785
- detail: u
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 = (u) => {
789
- l && clearTimeout(l), t.releasePointerCapture(u.pointerId), i ? (o?.(u), t.dispatchEvent(new CustomEvent("longpressend", {
790
- detail: u
791
- }))) : (s?.(u), t.dispatchEvent(new CustomEvent("shorttap", {
792
- detail: u
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 = (u) => {
795
- l && clearTimeout(l), t.releasePointerCapture(u.pointerId), i = !1;
796
- }, m = (u) => {
797
- u.preventDefault(), u.stopPropagation();
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dictate-button",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Customizable Web Component that adds speech-to-text dictation capabilities to text fields",
5
5
  "keywords": [
6
6
  "custom-element",