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.
@@ -1,47 +1,47 @@
1
- const yt = (t, e) => t === e, j = {
2
- equals: yt
1
+ const pt = (t, e) => t === e, B = {
2
+ equals: pt
3
3
  };
4
- let _t = at;
5
- const m = 1, B = 2, nt = {
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 y = null;
12
- let V = null, wt = null, p = null, g = null, S = null, F = 0;
13
- function Ct(t, e) {
14
- const n = p, s = y, r = t.length === 0, o = e === void 0 ? s : e, l = r ? nt : {
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
- y = l, p = null;
20
+ b = l, p = null;
21
21
  try {
22
- return k(i, !0);
22
+ return x(i, !0);
23
23
  } finally {
24
- p = n, y = s;
24
+ p = n, b = s;
25
25
  }
26
26
  }
27
- function rt(t, e) {
28
- e = e ? Object.assign({}, j, e) : j;
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)), ot(n, r));
35
- return [st.bind(n), s];
34
+ }, s = (r) => (typeof r == "function" && (r = r(n.value)), st(n, r));
35
+ return [rt.bind(n), s];
36
36
  }
37
- function R(t, e, n) {
38
- const s = it(t, e, !1, m);
39
- L(s);
37
+ function I(t, e, n) {
38
+ const s = ot(t, e, !1, C);
39
+ K(s);
40
40
  }
41
- function St(t, e, n) {
42
- n = n ? Object.assign({}, j, n) : j;
43
- const s = it(t, e, !0, 0);
44
- return s.observers = null, s.observerSlots = null, s.comparator = n.equals || void 0, L(s), st.bind(s);
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 st() {
56
+ function rt() {
57
57
  if (this.sources && this.state)
58
- if (this.state === m) L(this);
58
+ if (this.state === C) K(this);
59
59
  else {
60
60
  const t = g;
61
- g = null, k(() => I(this), !1), g = t;
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 ot(t, e, n) {
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 && k(() => {
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 = V && V.running;
74
- l && V.disposed.has(o), (l ? !o.tState : !o.state) && (o.pure ? g.push(o) : S.push(o), o.observers && ct(o)), l || (o.state = m);
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 L(t) {
80
+ function K(t) {
81
81
  if (!t.fn) return;
82
82
  E(t);
83
- const e = F;
84
- mt(t, t.value, e);
83
+ const e = L;
84
+ wt(t, t.value, e);
85
85
  }
86
- function mt(t, e, n) {
86
+ function wt(t, e, n) {
87
87
  let s;
88
- const r = y, o = p;
89
- p = y = t;
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 = m, t.owned && t.owned.forEach(E), t.owned = null), t.updatedAt = n + 1, ut(l);
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, y = r;
95
+ p = o, b = r;
96
96
  }
97
- (!t.updatedAt || t.updatedAt <= n) && (t.updatedAt != null && "observers" in t ? ot(t, s) : t.value = s, t.updatedAt = n);
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 it(t, e, n, s = m, r) {
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: y,
110
- context: y ? y.context : null,
109
+ owner: b,
110
+ context: b ? b.context : null,
111
111
  pure: n
112
112
  };
113
- return y === null || y !== nt && (y.owned ? y.owned.push(o) : y.owned = [o]), o;
113
+ return b === null || b !== et && (b.owned ? b.owned.push(o) : b.owned = [o]), o;
114
114
  }
115
- function lt(t) {
115
+ function it(t) {
116
116
  if (t.state === 0) return;
117
- if (t.state === B) return I(t);
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 < F); )
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 === m)
124
- L(t);
125
- else if (t.state === B) {
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, k(() => I(t, e[0]), !1), g = s;
127
+ g = null, x(() => D(t, e[0]), !1), g = s;
128
128
  }
129
129
  }
130
- function k(t, e) {
130
+ function x(t, e) {
131
131
  if (g) return t();
132
132
  let n = !1;
133
- e || (g = []), S ? n = !0 : S = [], F++;
133
+ e || (g = []), w ? n = !0 : w = [], L++;
134
134
  try {
135
135
  const s = t();
136
- return At(n), s;
136
+ return Ct(n), s;
137
137
  } catch (s) {
138
- n || (S = null), g = null, ut(s);
138
+ n || (w = null), g = null, ct(s);
139
139
  }
140
140
  }
141
- function At(t) {
142
- if (g && (at(g), g = null), t) return;
143
- const e = S;
144
- S = null, e.length && k(() => _t(e), !1);
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 at(t) {
147
- for (let e = 0; e < t.length; e++) lt(t[e]);
146
+ function lt(t) {
147
+ for (let e = 0; e < t.length; e++) it(t[e]);
148
148
  }
149
- function I(t, e) {
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 === m ? s !== e && (!s.updatedAt || s.updatedAt < F) && lt(s) : r === B && I(s, e);
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 ct(t) {
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 = B, n.pure ? g.push(n) : S.push(n), n.observers && ct(n));
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 vt(t) {
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 ut(t, e = y) {
195
- throw vt(t);
194
+ function ct(t, e = b) {
195
+ throw St(t);
196
196
  }
197
- function P(t, e) {
197
+ function M(t, e) {
198
198
  return G(() => t(e || {}));
199
199
  }
200
- const M = (t) => St(() => t());
201
- function xt(t, e, n) {
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 b = i;
223
- for (; b < o; ) u.set(n[b], b++);
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 b = l, w = 1, C;
229
- for (; ++b < r && b < o && !((C = u.get(e[b])) == null || C !== f + w); )
230
- w++;
231
- if (w > f - i) {
232
- const K = e[l];
233
- for (; i < f; ) t.insertBefore(n[i++], K);
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 Z = "_$DX_DELEGATE";
241
- function T(t, e, n, s) {
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 Et(t, e = window.document) {
250
- const n = e[Z] || (e[Z] = /* @__PURE__ */ new Set());
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, Tt));
253
+ n.has(o) || (n.add(o), e.addEventListener(o, Et));
254
254
  }
255
255
  }
256
- function ft(t, e, n) {
256
+ function ut(t, e, n) {
257
257
  n == null ? t.removeAttribute(e) : t.setAttribute(e, n);
258
258
  }
259
- function kt(t, e, n) {
260
- if (!e) return n ? ft(t, "style") : e;
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 x(t, e, n, s) {
272
- if (n !== void 0 && !s && (s = []), typeof e != "function") return D(t, e, s, n);
273
- R((r) => D(t, e(), r, n), s);
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 Tt(t) {
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 D(t, e, n, s, r) {
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 = A(t, n, s, i);
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 = A(t, n, s);
322
+ n = S(t, n, s);
323
323
  else {
324
324
  if (o === "function")
325
- return R(() => {
325
+ return I(() => {
326
326
  let i = e();
327
327
  for (; typeof i == "function"; ) i = i();
328
- n = D(t, i, n, s);
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 R(() => n = D(t, i, n, s, !0)), () => n;
333
+ return I(() => n = F(t, i, n, s, !0)), () => n;
334
334
  if (i.length === 0) {
335
- if (n = A(t, n, s), l) return n;
336
- } else a ? n.length === 0 ? Q(t, i, s) : xt(t, n, i) : (n && A(t), Q(t, i));
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 = A(t, n, s, e);
341
- A(t, n, null, e);
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 Q(t, e, n = null) {
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 A(t, e, n, s) {
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 $t(t) {
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), ht(r.value) && !jt(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;
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 Ot(t) {
393
+ function kt(t) {
394
394
  return t ? Object.keys(t).reduce((n, s) => {
395
395
  const r = t[s];
396
- return n[s] = ht(r) && "value" in r ? r : {
396
+ return n[s] = dt(r) && "value" in r ? r : {
397
397
  value: r
398
- }, n[s].attribute || (n[s].attribute = Nt(s)), n[s].parse = "parse" in n[s] ? n[s].parse : typeof n[s].value != "string", n;
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 Pt(t) {
401
+ function Tt(t) {
402
402
  return Object.keys(t).reduce((n, s) => (n[s] = t[s].value, n), {});
403
403
  }
404
- function Mt(t, e) {
405
- const n = $t(e);
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 ? dt(l) : l), i != null && (o.value = Array.isArray(i) ? i.slice(0) : i), o.reflect && Y(t, o.attribute, o.value, !!o.parse), Object.defineProperty(t, r, {
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 && Y(this, o.attribute, o.value, !!o.parse);
415
- for (let f = 0, b = this.__propertyChangedCallbacks.length; f < b; f++)
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 dt(t) {
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 Y(t, e, n, s) {
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 Nt(t) {
436
+ function Ot(t) {
437
437
  return t.replace(/\.?([A-Z]+)/g, (e, n) => "-" + n.toLowerCase()).replace("_", "-").replace(/^-/, "");
438
438
  }
439
- function ht(t) {
439
+ function dt(t) {
440
440
  return t != null && (typeof t == "object" || typeof t == "function");
441
441
  }
442
- function jt(t) {
442
+ function Pt(t) {
443
443
  return Object.prototype.toString.call(t) === "[object Function]";
444
444
  }
445
- function Bt(t) {
445
+ function Mt(t) {
446
446
  return typeof t == "function" && t.toString().indexOf("class") === 0;
447
447
  }
448
- let q;
449
- function Rt(t, e) {
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 = Mt(this, e);
461
- const r = Pt(this.props), o = this.Component, l = q;
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
- q = this, this.__initialized = !0, Bt(o) ? new o(r, {
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
- q = l;
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 ? dt(l) : l;
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 It(t, e = {}, n = {}) {
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 = Rt(s, Ot(e)), i.prototype.Component = l, i.prototype.registeredTag = t, o.define(t, i, r), 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 Dt(t) {
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] = rt(t[e[s]]);
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 Ft(t) {
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 Lt(t) {
533
+ function It(t) {
534
534
  return (e, n) => {
535
535
  const { element: s } = n;
536
- return Ct((r) => {
537
- const o = Dt(e);
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 x(s.renderRoot, l);
543
- }, Ft(s));
542
+ return A(s.renderRoot, l);
543
+ }, Rt(s));
544
544
  };
545
545
  }
546
- function Kt(t, e, n) {
547
- return arguments.length === 2 && (n = e, e = {}), It(t, e)(Lt(n));
546
+ function Dt(t, e, n) {
547
+ return arguments.length === 2 && (n = e, e = {}), jt(t, e)(It(n));
548
548
  }
549
- const Ut = `
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 Vt = /* @__PURE__ */ T("<div part=container class=dictate-button__container><style></style><button part=button class=dictate-button__button>"), qt = /* @__PURE__ */ T('<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">'), zt = /* @__PURE__ */ T('<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>'), Ht = /* @__PURE__ */ T('<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">'), Gt = /* @__PURE__ */ T('<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.0");
590
- const Wt = "https://api.dictate-button.io/transcribe", N = "dictate-button.io", z = -70, tt = -10, et = 0, Xt = 4, Jt = 0.25, Zt = 0.05;
591
- Kt("dictate-button", {
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: Wt,
593
+ apiEndpoint: qt,
594
594
  language: void 0
595
595
  }, (t, {
596
596
  element: e
597
597
  }) => {
598
- const {
599
- size: n,
600
- apiEndpoint: s,
601
- language: r
602
- } = t;
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
- _ += c * c;
605
+ y += c * c;
611
606
  }
612
- return Math.sqrt(_ / d.length);
613
- }, gt = (d) => 20 * Math.log10(Math.max(d, 1e-8)), W = (d) => {
614
- const _ = e.shadowRoot.querySelector(".dictate-button__button");
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 = et + d * (Xt - et), c = 0 + d * 0.4;
618
- _.style.boxShadow = `0 0 0 ${h}px light-dark(rgba(0, 0, 0, ${c}), rgba(255, 255, 255, ${c}))`;
619
- }, X = () => {
620
- if (!w || !f || !b) return;
621
- f.getByteTimeDomainData(b);
622
- const d = pt(b), _ = gt(d), h = K(_), c = h > C ? Jt : Zt;
623
- C = c * h + (1 - c) * C, W(C), requestAnimationFrame(X);
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
- i && i.state !== "inactive" && i.stop(), a = [], w = !1, u && u.state !== "closed" && u.close(), u = null, f = null, b = null, C = 0, W(0);
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 bt = async () => {
629
- if (U(), o() === "idle")
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
- u = new (window.AudioContext || window.webkitAudioContext)();
635
- const _ = u.createMediaStreamSource(d);
636
- f = u.createAnalyser(), f.fftSize = 2048, _.connect(f), b = new Uint8Array(f.fftSize), i = new MediaRecorder(d, {
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
- }), a = [], i.ondataavailable = (h) => {
639
- a.push(h.data);
640
- }, i.onstop = async () => {
641
- w = !1, l("processing"), v(e, "transcribing:started", "Started transcribing");
642
- const h = new Blob(a, {
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), r && c.append("language", r);
648
- const $ = await fetch(s, {
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 (!$.ok) throw new Error("Failed to transcribe audio");
653
- const O = await $.json();
654
- if (o() !== "processing") return;
655
- v(e, "transcribing:finished", O.text), l("idle");
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), v(e, "transcribing:failed", "Failed to transcribe audio"), J();
652
+ console.error("Failed to transcribe audio:", c), m(e, "transcribing:failed", "Failed to transcribe audio"), X();
658
653
  }
659
- }, i.start(), v(e, "recording:started", "Started recording"), w = !0, X(), l("recording");
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), v(e, "recording:failed", "Failed to start recording"), J();
656
+ console.error("Failed to start recording:", d), m(e, "recording:failed", "Failed to start recording"), X();
662
657
  }
663
658
  else
664
- v(e, "recording:stopped", "Stopped recording"), l("idle"), U();
665
- }, J = () => {
666
- l("error"), setTimeout(() => l("idle"), 2e3);
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 = Vt(), _ = d.firstChild, h = _.nextSibling;
670
- return x(_, Ut), h.$$click = bt, x(h, (() => {
671
- var c = M(() => o() === "idle");
672
- return () => c() && P(Yt, {});
673
- })(), null), x(h, (() => {
674
- var c = M(() => o() === "recording");
675
- return () => c() && P(te, {});
676
- })(), null), x(h, (() => {
677
- var c = M(() => o() === "processing");
678
- return () => c() && P(ee, {});
679
- })(), null), x(h, (() => {
680
- var c = M(() => o() === "error");
681
- return () => c() && P(ne, {});
682
- })(), null), R((c) => {
683
- var $ = `width:${n}px;height:${n}px"`, O = Qt(o());
684
- return c.e = kt(h, $, c.e), O !== c.t && ft(h, "title", c.t = O), c;
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 Qt = (t) => {
686
+ const Xt = (t) => {
692
687
  switch (t) {
693
688
  case "idle":
694
- return `Start dictation (${N})`;
689
+ return `Start dictation (${j})`;
695
690
  case "recording":
696
- return `Stop dictation (${N})`;
691
+ return `Stop dictation (${j})`;
697
692
  case "processing":
698
- return `Stop processing (${N})`;
693
+ return `Stop processing (${j})`;
699
694
  case "error":
700
- return `Click to reset (${N})`;
695
+ return `Click to reset (${j})`;
701
696
  }
702
- }, v = (t, e, n) => {
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
- }, Yt = () => qt(), te = () => zt(), ee = () => Ht(), ne = () => Gt();
709
- Et(["click"]);
703
+ }, Jt = () => Kt(), Zt = () => Ut(), Qt = () => zt(), Yt = () => Vt();
704
+ At(["click"]);
@@ -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 === 2 && (e.language = s), e.addEventListener("recording:started", (o) => {
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);
@@ -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 === 2 && (e.language = s), e.addEventListener("recording:started", (o) => {
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dictate-button",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Dictate Button (Web Component)",
5
5
  "keywords": [
6
6
  "custom-element",