dictate-button 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/dictate-button.js +21 -21
- package/dist/inject-exclusive.js +27 -24
- package/dist/inject-inclusive.js +27 -24
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -70,7 +70,7 @@ Import the component and use it directly in your code:
|
|
|
70
70
|
```html
|
|
71
71
|
<script type="module" crossorigin src="https://cdn.dictate-button.io/dictate-button.js"></script>
|
|
72
72
|
|
|
73
|
-
<dictate-button size="
|
|
73
|
+
<dictate-button size="30" api-endpoint="https://api.dictate-button.io/transcribe" language="en"></dictate-button>
|
|
74
74
|
```
|
|
75
75
|
|
|
76
76
|
### From NPM
|
package/dist/dictate-button.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const yt = (t, e) => t === e,
|
|
1
|
+
const yt = (t, e) => t === e, j = {
|
|
2
2
|
equals: yt
|
|
3
3
|
};
|
|
4
4
|
let _t = at;
|
|
@@ -25,7 +25,7 @@ function Ct(t, e) {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
function rt(t, e) {
|
|
28
|
-
e = e ? Object.assign({},
|
|
28
|
+
e = e ? Object.assign({}, j, e) : j;
|
|
29
29
|
const n = {
|
|
30
30
|
value: t,
|
|
31
31
|
observers: null,
|
|
@@ -39,7 +39,7 @@ function R(t, e, n) {
|
|
|
39
39
|
L(s);
|
|
40
40
|
}
|
|
41
41
|
function St(t, e, n) {
|
|
42
|
-
n = n ? Object.assign({},
|
|
42
|
+
n = n ? Object.assign({}, j, n) : j;
|
|
43
43
|
const s = it(t, e, !0, 0);
|
|
44
44
|
return s.observers = null, s.observerSlots = null, s.comparator = n.equals || void 0, L(s), st.bind(s);
|
|
45
45
|
}
|
|
@@ -197,7 +197,7 @@ function ut(t, e = y) {
|
|
|
197
197
|
function P(t, e) {
|
|
198
198
|
return G(() => t(e || {}));
|
|
199
199
|
}
|
|
200
|
-
const
|
|
200
|
+
const M = (t) => St(() => t());
|
|
201
201
|
function xt(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; ) {
|
|
@@ -387,7 +387,7 @@ function A(t, e, n, s) {
|
|
|
387
387
|
function $t(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) && !
|
|
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;
|
|
391
391
|
}, {});
|
|
392
392
|
}
|
|
393
393
|
function Ot(t) {
|
|
@@ -395,13 +395,13 @@ function Ot(t) {
|
|
|
395
395
|
const r = t[s];
|
|
396
396
|
return n[s] = ht(r) && "value" in r ? r : {
|
|
397
397
|
value: r
|
|
398
|
-
}, n[s].attribute || (n[s].attribute =
|
|
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;
|
|
399
399
|
}, {}) : {};
|
|
400
400
|
}
|
|
401
401
|
function Pt(t) {
|
|
402
402
|
return Object.keys(t).reduce((n, s) => (n[s] = t[s].value, n), {});
|
|
403
403
|
}
|
|
404
|
-
function
|
|
404
|
+
function Mt(t, e) {
|
|
405
405
|
const n = $t(e);
|
|
406
406
|
return Object.keys(e).forEach((r) => {
|
|
407
407
|
const o = n[r], l = t.getAttribute(o.attribute), i = t[r];
|
|
@@ -433,13 +433,13 @@ function Y(t, e, n, s) {
|
|
|
433
433
|
let r = s ? JSON.stringify(n) : n;
|
|
434
434
|
t.__updating[e] = !0, r === "true" && (r = ""), t.setAttribute(e, r), Promise.resolve().then(() => delete t.__updating[e]);
|
|
435
435
|
}
|
|
436
|
-
function
|
|
436
|
+
function Nt(t) {
|
|
437
437
|
return t.replace(/\.?([A-Z]+)/g, (e, n) => "-" + n.toLowerCase()).replace("_", "-").replace(/^-/, "");
|
|
438
438
|
}
|
|
439
439
|
function ht(t) {
|
|
440
440
|
return t != null && (typeof t == "object" || typeof t == "function");
|
|
441
441
|
}
|
|
442
|
-
function
|
|
442
|
+
function jt(t) {
|
|
443
443
|
return Object.prototype.toString.call(t) === "[object Function]";
|
|
444
444
|
}
|
|
445
445
|
function Bt(t) {
|
|
@@ -457,7 +457,7 @@ function Rt(t, e) {
|
|
|
457
457
|
}
|
|
458
458
|
connectedCallback() {
|
|
459
459
|
if (this.__initialized) return;
|
|
460
|
-
this.__releaseCallbacks = [], this.__propertyChangedCallbacks = [], this.__updating = {}, this.props =
|
|
460
|
+
this.__releaseCallbacks = [], this.__propertyChangedCallbacks = [], this.__updating = {}, this.props = Mt(this, e);
|
|
461
461
|
const r = Pt(this.props), o = this.Component, l = q;
|
|
462
462
|
try {
|
|
463
463
|
q = this, this.__initialized = !0, Bt(o) ? new o(r, {
|
|
@@ -585,9 +585,9 @@ 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
|
|
589
|
-
console.debug("dictate-button version:", "1.0.
|
|
590
|
-
const Wt = "https://api.dictate-button.io/transcribe",
|
|
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.0.1");
|
|
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
591
|
Kt("dictate-button", {
|
|
592
592
|
size: 30,
|
|
593
593
|
apiEndpoint: Wt,
|
|
@@ -668,16 +668,16 @@ Kt("dictate-button", {
|
|
|
668
668
|
return (() => {
|
|
669
669
|
var d = Vt(), _ = d.firstChild, h = _.nextSibling;
|
|
670
670
|
return x(_, Ut), h.$$click = bt, x(h, (() => {
|
|
671
|
-
var c =
|
|
671
|
+
var c = M(() => o() === "idle");
|
|
672
672
|
return () => c() && P(Yt, {});
|
|
673
673
|
})(), null), x(h, (() => {
|
|
674
|
-
var c =
|
|
674
|
+
var c = M(() => o() === "recording");
|
|
675
675
|
return () => c() && P(te, {});
|
|
676
676
|
})(), null), x(h, (() => {
|
|
677
|
-
var c =
|
|
677
|
+
var c = M(() => o() === "processing");
|
|
678
678
|
return () => c() && P(ee, {});
|
|
679
679
|
})(), null), x(h, (() => {
|
|
680
|
-
var c =
|
|
680
|
+
var c = M(() => o() === "error");
|
|
681
681
|
return () => c() && P(ne, {});
|
|
682
682
|
})(), null), R((c) => {
|
|
683
683
|
var $ = `width:${n}px;height:${n}px"`, O = Qt(o());
|
|
@@ -691,13 +691,13 @@ Kt("dictate-button", {
|
|
|
691
691
|
const Qt = (t) => {
|
|
692
692
|
switch (t) {
|
|
693
693
|
case "idle":
|
|
694
|
-
return `Start dictation (${
|
|
694
|
+
return `Start dictation (${N})`;
|
|
695
695
|
case "recording":
|
|
696
|
-
return `Stop dictation (${
|
|
696
|
+
return `Stop dictation (${N})`;
|
|
697
697
|
case "processing":
|
|
698
|
-
return `Stop processing (${
|
|
698
|
+
return `Stop processing (${N})`;
|
|
699
699
|
case "error":
|
|
700
|
-
return `Click to reset (${
|
|
700
|
+
return `Click to reset (${N})`;
|
|
701
701
|
}
|
|
702
702
|
}, v = (t, e, n) => {
|
|
703
703
|
t.dispatchEvent(new CustomEvent(e, {
|
package/dist/inject-exclusive.js
CHANGED
|
@@ -2,37 +2,40 @@ function r() {
|
|
|
2
2
|
const i = document.querySelectorAll(
|
|
3
3
|
'textarea[data-dictate-button-on]:not([data-dictate-button-enabled]), input[type="text"][data-dictate-button-on]:not([data-dictate-button-enabled])'
|
|
4
4
|
);
|
|
5
|
-
for (const
|
|
6
|
-
const
|
|
7
|
-
|
|
5
|
+
for (const o of i) {
|
|
6
|
+
const e = document.createElement("div");
|
|
7
|
+
e.style.position = "relative", e.style.display = "inline-block", e.style.width = "auto", e.style.color = "inherit", o.parentNode.insertBefore(e, o), o.setAttribute("data-dictate-button-enabled", ""), e.appendChild(o), o.style.boxSizing = "border-box";
|
|
8
8
|
const t = document.createElement("dictate-button");
|
|
9
|
-
t.size = 30, t.style.position = "absolute", t.style.right = "0", t.style.top = d(
|
|
9
|
+
t.size = 30, t.style.position = "absolute", t.style.right = "0", t.style.top = d(e, o) + "px", t.style.margin = "10px";
|
|
10
10
|
const a = document.documentElement.lang;
|
|
11
|
-
a && a.length === 2 && (t.language = a), t.addEventListener("recording:started", (
|
|
12
|
-
console.log("recording:started",
|
|
13
|
-
}), t.addEventListener("recording:stopped", (
|
|
14
|
-
console.log("recording:stopped",
|
|
15
|
-
}), t.addEventListener("recording:failed", (
|
|
16
|
-
console.log("recording:failed",
|
|
17
|
-
}), t.addEventListener("transcribing:started", (
|
|
18
|
-
console.log("transcribing:started",
|
|
19
|
-
}), t.addEventListener("transcribing:finished", (
|
|
20
|
-
console.log("transcribing:finished",
|
|
21
|
-
const s =
|
|
22
|
-
c(
|
|
23
|
-
}), t.addEventListener("transcribing:failed", (
|
|
24
|
-
console.log("transcribing:failed",
|
|
25
|
-
}),
|
|
11
|
+
a && a.length === 2 && (t.language = a), t.addEventListener("recording:started", (n) => {
|
|
12
|
+
console.log("recording:started", n);
|
|
13
|
+
}), t.addEventListener("recording:stopped", (n) => {
|
|
14
|
+
console.log("recording:stopped", n);
|
|
15
|
+
}), t.addEventListener("recording:failed", (n) => {
|
|
16
|
+
console.log("recording:failed", n);
|
|
17
|
+
}), t.addEventListener("transcribing:started", (n) => {
|
|
18
|
+
console.log("transcribing:started", n);
|
|
19
|
+
}), t.addEventListener("transcribing:finished", (n) => {
|
|
20
|
+
console.log("transcribing:finished", n);
|
|
21
|
+
const s = n.detail;
|
|
22
|
+
c(o, s);
|
|
23
|
+
}), t.addEventListener("transcribing:failed", (n) => {
|
|
24
|
+
console.log("transcribing:failed", n);
|
|
25
|
+
}), e.appendChild(t);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
function d(i,
|
|
29
|
-
|
|
28
|
+
function d(i, o) {
|
|
29
|
+
if (o.tagName.toLowerCase() === "textarea")
|
|
30
|
+
return 0;
|
|
31
|
+
const e = Math.round(
|
|
30
32
|
i.clientHeight / 2 - 30 / 2 - 10
|
|
31
33
|
);
|
|
34
|
+
return Math.max(0, e);
|
|
32
35
|
}
|
|
33
|
-
function c(i,
|
|
34
|
-
const
|
|
35
|
-
i.value = i.value.substring(0,
|
|
36
|
+
function c(i, o) {
|
|
37
|
+
const e = i.selectionStart || 0, t = i.selectionEnd || 0;
|
|
38
|
+
i.value = i.value.substring(0, e) + o + i.value.substring(t);
|
|
36
39
|
}
|
|
37
40
|
document.addEventListener("DOMContentLoaded", () => {
|
|
38
41
|
r(), new MutationObserver(r).observe(document.body, {
|
package/dist/inject-inclusive.js
CHANGED
|
@@ -2,37 +2,40 @@ function r() {
|
|
|
2
2
|
const i = document.querySelectorAll(
|
|
3
3
|
'textarea:not([data-dictate-button-off]):not([data-dictate-button-enabled]), input[type="text"]:not([data-dictate-button-off]):not([data-dictate-button-enabled])'
|
|
4
4
|
);
|
|
5
|
-
for (const
|
|
6
|
-
const
|
|
7
|
-
|
|
5
|
+
for (const o of i) {
|
|
6
|
+
const e = document.createElement("div");
|
|
7
|
+
e.style.position = "relative", e.style.display = "inline-block", e.style.width = "auto", e.style.color = "inherit", o.parentNode.insertBefore(e, o), o.setAttribute("data-dictate-button-enabled", ""), e.appendChild(o), o.style.boxSizing = "border-box";
|
|
8
8
|
const t = document.createElement("dictate-button");
|
|
9
|
-
t.size = 30, t.style.position = "absolute", t.style.right = "0", t.style.top = d(
|
|
9
|
+
t.size = 30, t.style.position = "absolute", t.style.right = "0", t.style.top = d(e, o) + "px", t.style.margin = "10px";
|
|
10
10
|
const a = document.documentElement.lang;
|
|
11
|
-
a && a.length === 2 && (t.language = a), t.addEventListener("recording:started", (
|
|
12
|
-
console.log("recording:started",
|
|
13
|
-
}), t.addEventListener("recording:stopped", (
|
|
14
|
-
console.log("recording:stopped",
|
|
15
|
-
}), t.addEventListener("recording:failed", (
|
|
16
|
-
console.log("recording:failed",
|
|
17
|
-
}), t.addEventListener("transcribing:started", (
|
|
18
|
-
console.log("transcribing:started",
|
|
19
|
-
}), t.addEventListener("transcribing:finished", (
|
|
20
|
-
console.log("transcribing:finished",
|
|
21
|
-
const s =
|
|
22
|
-
c(
|
|
23
|
-
}), t.addEventListener("transcribing:failed", (
|
|
24
|
-
console.log("transcribing:failed",
|
|
25
|
-
}),
|
|
11
|
+
a && a.length === 2 && (t.language = a), t.addEventListener("recording:started", (n) => {
|
|
12
|
+
console.log("recording:started", n);
|
|
13
|
+
}), t.addEventListener("recording:stopped", (n) => {
|
|
14
|
+
console.log("recording:stopped", n);
|
|
15
|
+
}), t.addEventListener("recording:failed", (n) => {
|
|
16
|
+
console.log("recording:failed", n);
|
|
17
|
+
}), t.addEventListener("transcribing:started", (n) => {
|
|
18
|
+
console.log("transcribing:started", n);
|
|
19
|
+
}), t.addEventListener("transcribing:finished", (n) => {
|
|
20
|
+
console.log("transcribing:finished", n);
|
|
21
|
+
const s = n.detail;
|
|
22
|
+
c(o, s);
|
|
23
|
+
}), t.addEventListener("transcribing:failed", (n) => {
|
|
24
|
+
console.log("transcribing:failed", n);
|
|
25
|
+
}), e.appendChild(t);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
function d(i,
|
|
29
|
-
|
|
28
|
+
function d(i, o) {
|
|
29
|
+
if (o.tagName.toLowerCase() === "textarea")
|
|
30
|
+
return 0;
|
|
31
|
+
const e = Math.round(
|
|
30
32
|
i.clientHeight / 2 - 30 / 2 - 10
|
|
31
33
|
);
|
|
34
|
+
return Math.max(0, e);
|
|
32
35
|
}
|
|
33
|
-
function c(i,
|
|
34
|
-
const
|
|
35
|
-
i.value = i.value.substring(0,
|
|
36
|
+
function c(i, o) {
|
|
37
|
+
const e = i.selectionStart || 0, t = i.selectionEnd || 0;
|
|
38
|
+
i.value = i.value.substring(0, e) + o + i.value.substring(t);
|
|
36
39
|
}
|
|
37
40
|
document.addEventListener("DOMContentLoaded", () => {
|
|
38
41
|
r(), new MutationObserver(r).observe(document.body, {
|