dictate-button 0.2.0 → 1.0.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 +18 -12
- package/dist/dictate-button.d.ts +1 -0
- package/dist/dictate-button.js +709 -0
- package/dist/dictate-button.styles.d.ts +1 -1
- package/dist/inject-exclusive.js +42 -0
- package/dist/inject-inclusive.js +42 -0
- package/package.json +21 -17
- package/.firebaserc +0 -5
- package/.prettierrc.mjs +0 -10
- package/404.html +0 -17
- package/dist/404.html +0 -17
- package/dist/dictate-button.cjs.js +0 -36
- package/dist/dictate-button.es.js +0 -682
- package/dist/inject-exclusive.cjs.js +0 -1
- package/dist/inject-exclusive.es.js +0 -35
- package/dist/inject-inclusive.cjs.js +0 -1
- package/dist/inject-inclusive.es.js +0 -35
- package/dist/inject.cjs.js +0 -1
- package/dist/inject.d.ts +0 -1
- package/dist/inject.es.js +0 -1
- package/firebase.json +0 -42
- package/pnpm-workspace.yaml +0 -2
- package/src/dictate-button.styles.ts +0 -36
- package/src/dictate-button.tsx +0 -240
- package/src/inject-exclusive.js +0 -76
- package/src/inject-inclusive.js +0 -76
- package/src/inject.js +0 -2
- package/tsconfig.json +0 -17
- package/vite-env.d.ts +0 -3
- package/vite.config.ts +0 -37
|
@@ -1,682 +0,0 @@
|
|
|
1
|
-
const st = (t, e) => t === e, T = {
|
|
2
|
-
equals: st
|
|
3
|
-
};
|
|
4
|
-
let rt = Q;
|
|
5
|
-
const w = 1, O = 2, q = {
|
|
6
|
-
owned: null,
|
|
7
|
-
cleanups: null,
|
|
8
|
-
context: null,
|
|
9
|
-
owner: null
|
|
10
|
-
};
|
|
11
|
-
var b = null;
|
|
12
|
-
let R = null, it = null, f = null, p = null, _ = null, B = 0;
|
|
13
|
-
function ot(t, e) {
|
|
14
|
-
const n = f, r = b, s = t.length === 0, i = e === void 0 ? r : e, l = s ? q : {
|
|
15
|
-
owned: null,
|
|
16
|
-
cleanups: null,
|
|
17
|
-
context: i ? i.context : null,
|
|
18
|
-
owner: i
|
|
19
|
-
}, o = s ? t : () => t(() => L(() => E(l)));
|
|
20
|
-
b = l, f = null;
|
|
21
|
-
try {
|
|
22
|
-
return A(o, !0);
|
|
23
|
-
} finally {
|
|
24
|
-
f = n, b = r;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
function z(t, e) {
|
|
28
|
-
e = e ? Object.assign({}, T, e) : T;
|
|
29
|
-
const n = {
|
|
30
|
-
value: t,
|
|
31
|
-
observers: null,
|
|
32
|
-
observerSlots: null,
|
|
33
|
-
comparator: e.equals || void 0
|
|
34
|
-
}, r = (s) => (typeof s == "function" && (s = s(n.value)), H(n, s));
|
|
35
|
-
return [G.bind(n), r];
|
|
36
|
-
}
|
|
37
|
-
function P(t, e, n) {
|
|
38
|
-
const r = Z(t, e, !1, w);
|
|
39
|
-
M(r);
|
|
40
|
-
}
|
|
41
|
-
function lt(t, e, n) {
|
|
42
|
-
n = n ? Object.assign({}, T, n) : T;
|
|
43
|
-
const r = Z(t, e, !0, 0);
|
|
44
|
-
return r.observers = null, r.observerSlots = null, r.comparator = n.equals || void 0, M(r), G.bind(r);
|
|
45
|
-
}
|
|
46
|
-
function L(t) {
|
|
47
|
-
if (f === null) return t();
|
|
48
|
-
const e = f;
|
|
49
|
-
f = null;
|
|
50
|
-
try {
|
|
51
|
-
return t();
|
|
52
|
-
} finally {
|
|
53
|
-
f = e;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function G() {
|
|
57
|
-
if (this.sources && this.state)
|
|
58
|
-
if (this.state === w) M(this);
|
|
59
|
-
else {
|
|
60
|
-
const t = p;
|
|
61
|
-
p = null, A(() => j(this), !1), p = t;
|
|
62
|
-
}
|
|
63
|
-
if (f) {
|
|
64
|
-
const t = this.observers ? this.observers.length : 0;
|
|
65
|
-
f.sources ? (f.sources.push(this), f.sourceSlots.push(t)) : (f.sources = [this], f.sourceSlots = [t]), this.observers ? (this.observers.push(f), this.observerSlots.push(f.sources.length - 1)) : (this.observers = [f], this.observerSlots = [f.sources.length - 1]);
|
|
66
|
-
}
|
|
67
|
-
return this.value;
|
|
68
|
-
}
|
|
69
|
-
function H(t, e, n) {
|
|
70
|
-
let r = t.value;
|
|
71
|
-
return (!t.comparator || !t.comparator(r, e)) && (t.value = e, t.observers && t.observers.length && A(() => {
|
|
72
|
-
for (let s = 0; s < t.observers.length; s += 1) {
|
|
73
|
-
const i = t.observers[s], l = R && R.running;
|
|
74
|
-
l && R.disposed.has(i), (l ? !i.tState : !i.state) && (i.pure ? p.push(i) : _.push(i), i.observers && W(i)), l || (i.state = w);
|
|
75
|
-
}
|
|
76
|
-
if (p.length > 1e6)
|
|
77
|
-
throw p = [], new Error();
|
|
78
|
-
}, !1)), e;
|
|
79
|
-
}
|
|
80
|
-
function M(t) {
|
|
81
|
-
if (!t.fn) return;
|
|
82
|
-
E(t);
|
|
83
|
-
const e = B;
|
|
84
|
-
ct(t, t.value, e);
|
|
85
|
-
}
|
|
86
|
-
function ct(t, e, n) {
|
|
87
|
-
let r;
|
|
88
|
-
const s = b, i = f;
|
|
89
|
-
f = b = t;
|
|
90
|
-
try {
|
|
91
|
-
r = t.fn(e);
|
|
92
|
-
} catch (l) {
|
|
93
|
-
return t.pure && (t.state = w, t.owned && t.owned.forEach(E), t.owned = null), t.updatedAt = n + 1, X(l);
|
|
94
|
-
} finally {
|
|
95
|
-
f = i, b = s;
|
|
96
|
-
}
|
|
97
|
-
(!t.updatedAt || t.updatedAt <= n) && (t.updatedAt != null && "observers" in t ? H(t, r) : t.value = r, t.updatedAt = n);
|
|
98
|
-
}
|
|
99
|
-
function Z(t, e, n, r = w, s) {
|
|
100
|
-
const i = {
|
|
101
|
-
fn: t,
|
|
102
|
-
state: r,
|
|
103
|
-
updatedAt: null,
|
|
104
|
-
owned: null,
|
|
105
|
-
sources: null,
|
|
106
|
-
sourceSlots: null,
|
|
107
|
-
cleanups: null,
|
|
108
|
-
value: e,
|
|
109
|
-
owner: b,
|
|
110
|
-
context: b ? b.context : null,
|
|
111
|
-
pure: n
|
|
112
|
-
};
|
|
113
|
-
return b === null || b !== q && (b.owned ? b.owned.push(i) : b.owned = [i]), i;
|
|
114
|
-
}
|
|
115
|
-
function J(t) {
|
|
116
|
-
if (t.state === 0) return;
|
|
117
|
-
if (t.state === O) return j(t);
|
|
118
|
-
if (t.suspense && L(t.suspense.inFallback)) return t.suspense.effects.push(t);
|
|
119
|
-
const e = [t];
|
|
120
|
-
for (; (t = t.owner) && (!t.updatedAt || t.updatedAt < B); )
|
|
121
|
-
t.state && e.push(t);
|
|
122
|
-
for (let n = e.length - 1; n >= 0; n--)
|
|
123
|
-
if (t = e[n], t.state === w)
|
|
124
|
-
M(t);
|
|
125
|
-
else if (t.state === O) {
|
|
126
|
-
const r = p;
|
|
127
|
-
p = null, A(() => j(t, e[0]), !1), p = r;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
function A(t, e) {
|
|
131
|
-
if (p) return t();
|
|
132
|
-
let n = !1;
|
|
133
|
-
e || (p = []), _ ? n = !0 : _ = [], B++;
|
|
134
|
-
try {
|
|
135
|
-
const r = t();
|
|
136
|
-
return at(n), r;
|
|
137
|
-
} catch (r) {
|
|
138
|
-
n || (_ = null), p = null, X(r);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
function at(t) {
|
|
142
|
-
if (p && (Q(p), p = null), t) return;
|
|
143
|
-
const e = _;
|
|
144
|
-
_ = null, e.length && A(() => rt(e), !1);
|
|
145
|
-
}
|
|
146
|
-
function Q(t) {
|
|
147
|
-
for (let e = 0; e < t.length; e++) J(t[e]);
|
|
148
|
-
}
|
|
149
|
-
function j(t, e) {
|
|
150
|
-
t.state = 0;
|
|
151
|
-
for (let n = 0; n < t.sources.length; n += 1) {
|
|
152
|
-
const r = t.sources[n];
|
|
153
|
-
if (r.sources) {
|
|
154
|
-
const s = r.state;
|
|
155
|
-
s === w ? r !== e && (!r.updatedAt || r.updatedAt < B) && J(r) : s === O && j(r, e);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
function W(t) {
|
|
160
|
-
for (let e = 0; e < t.observers.length; e += 1) {
|
|
161
|
-
const n = t.observers[e];
|
|
162
|
-
n.state || (n.state = O, n.pure ? p.push(n) : _.push(n), n.observers && W(n));
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
function E(t) {
|
|
166
|
-
let e;
|
|
167
|
-
if (t.sources)
|
|
168
|
-
for (; t.sources.length; ) {
|
|
169
|
-
const n = t.sources.pop(), r = t.sourceSlots.pop(), s = n.observers;
|
|
170
|
-
if (s && s.length) {
|
|
171
|
-
const i = s.pop(), l = n.observerSlots.pop();
|
|
172
|
-
r < s.length && (i.sourceSlots[l] = r, s[r] = i, n.observerSlots[r] = l);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
if (t.tOwned) {
|
|
176
|
-
for (e = t.tOwned.length - 1; e >= 0; e--) E(t.tOwned[e]);
|
|
177
|
-
delete t.tOwned;
|
|
178
|
-
}
|
|
179
|
-
if (t.owned) {
|
|
180
|
-
for (e = t.owned.length - 1; e >= 0; e--) E(t.owned[e]);
|
|
181
|
-
t.owned = null;
|
|
182
|
-
}
|
|
183
|
-
if (t.cleanups) {
|
|
184
|
-
for (e = t.cleanups.length - 1; e >= 0; e--) t.cleanups[e]();
|
|
185
|
-
t.cleanups = null;
|
|
186
|
-
}
|
|
187
|
-
t.state = 0;
|
|
188
|
-
}
|
|
189
|
-
function ut(t) {
|
|
190
|
-
return t instanceof Error ? t : new Error(typeof t == "string" ? t : "Unknown error", {
|
|
191
|
-
cause: t
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
function X(t, e = b) {
|
|
195
|
-
throw ut(t);
|
|
196
|
-
}
|
|
197
|
-
function x(t, e) {
|
|
198
|
-
return L(() => t(e || {}));
|
|
199
|
-
}
|
|
200
|
-
const $ = (t) => lt(() => t());
|
|
201
|
-
function ft(t, e, n) {
|
|
202
|
-
let r = n.length, s = e.length, i = r, l = 0, o = 0, c = e[s - 1].nextSibling, a = null;
|
|
203
|
-
for (; l < s || o < i; ) {
|
|
204
|
-
if (e[l] === n[o]) {
|
|
205
|
-
l++, o++;
|
|
206
|
-
continue;
|
|
207
|
-
}
|
|
208
|
-
for (; e[s - 1] === n[i - 1]; )
|
|
209
|
-
s--, i--;
|
|
210
|
-
if (s === l) {
|
|
211
|
-
const u = i < r ? o ? n[o - 1].nextSibling : n[i - o] : c;
|
|
212
|
-
for (; o < i; ) t.insertBefore(n[o++], u);
|
|
213
|
-
} else if (i === o)
|
|
214
|
-
for (; l < s; )
|
|
215
|
-
(!a || !a.has(e[l])) && e[l].remove(), l++;
|
|
216
|
-
else if (e[l] === n[i - 1] && n[o] === e[s - 1]) {
|
|
217
|
-
const u = e[--s].nextSibling;
|
|
218
|
-
t.insertBefore(n[o++], e[l++].nextSibling), t.insertBefore(n[--i], u), e[s] = n[i];
|
|
219
|
-
} else {
|
|
220
|
-
if (!a) {
|
|
221
|
-
a = /* @__PURE__ */ new Map();
|
|
222
|
-
let h = o;
|
|
223
|
-
for (; h < i; ) a.set(n[h], h++);
|
|
224
|
-
}
|
|
225
|
-
const u = a.get(e[l]);
|
|
226
|
-
if (u != null)
|
|
227
|
-
if (o < u && u < i) {
|
|
228
|
-
let h = l, y = 1, g;
|
|
229
|
-
for (; ++h < s && h < i && !((g = a.get(e[h])) == null || g !== u + y); )
|
|
230
|
-
y++;
|
|
231
|
-
if (y > u - o) {
|
|
232
|
-
const d = e[l];
|
|
233
|
-
for (; o < u; ) t.insertBefore(n[o++], d);
|
|
234
|
-
} else t.replaceChild(n[o++], e[l++]);
|
|
235
|
-
} else l++;
|
|
236
|
-
else e[l++].remove();
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
const U = "_$DX_DELEGATE";
|
|
241
|
-
function m(t, e, n, r) {
|
|
242
|
-
let s;
|
|
243
|
-
const i = () => {
|
|
244
|
-
const o = document.createElement("template");
|
|
245
|
-
return o.innerHTML = t, o.content.firstChild;
|
|
246
|
-
}, l = () => (s || (s = i())).cloneNode(!0);
|
|
247
|
-
return l.cloneNode = l, l;
|
|
248
|
-
}
|
|
249
|
-
function dt(t, e = window.document) {
|
|
250
|
-
const n = e[U] || (e[U] = /* @__PURE__ */ new Set());
|
|
251
|
-
for (let r = 0, s = t.length; r < s; r++) {
|
|
252
|
-
const i = t[r];
|
|
253
|
-
n.has(i) || (n.add(i), e.addEventListener(i, pt));
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
function Y(t, e, n) {
|
|
257
|
-
n == null ? t.removeAttribute(e) : t.setAttribute(e, n);
|
|
258
|
-
}
|
|
259
|
-
function ht(t, e, n) {
|
|
260
|
-
if (!e) return n ? Y(t, "style") : e;
|
|
261
|
-
const r = t.style;
|
|
262
|
-
if (typeof e == "string") return r.cssText = e;
|
|
263
|
-
typeof n == "string" && (r.cssText = n = void 0), n || (n = {}), e || (e = {});
|
|
264
|
-
let s, i;
|
|
265
|
-
for (i in n)
|
|
266
|
-
e[i] == null && r.removeProperty(i), delete n[i];
|
|
267
|
-
for (i in e)
|
|
268
|
-
s = e[i], s !== n[i] && (r.setProperty(i, s), n[i] = s);
|
|
269
|
-
return n;
|
|
270
|
-
}
|
|
271
|
-
function S(t, e, n, r) {
|
|
272
|
-
if (n !== void 0 && !r && (r = []), typeof e != "function") return N(t, e, r, n);
|
|
273
|
-
P((s) => N(t, e(), s, n), r);
|
|
274
|
-
}
|
|
275
|
-
function pt(t) {
|
|
276
|
-
let e = t.target;
|
|
277
|
-
const n = `$$${t.type}`, r = t.target, s = t.currentTarget, i = (c) => Object.defineProperty(t, "target", {
|
|
278
|
-
configurable: !0,
|
|
279
|
-
value: c
|
|
280
|
-
}), l = () => {
|
|
281
|
-
const c = e[n];
|
|
282
|
-
if (c && !e.disabled) {
|
|
283
|
-
const a = e[`${n}Data`];
|
|
284
|
-
if (a !== void 0 ? c.call(e, a, t) : c.call(e, t), t.cancelBubble) return;
|
|
285
|
-
}
|
|
286
|
-
return e.host && typeof e.host != "string" && !e.host._$host && e.contains(t.target) && i(e.host), !0;
|
|
287
|
-
}, o = () => {
|
|
288
|
-
for (; l() && (e = e._$host || e.parentNode || e.host); ) ;
|
|
289
|
-
};
|
|
290
|
-
if (Object.defineProperty(t, "currentTarget", {
|
|
291
|
-
configurable: !0,
|
|
292
|
-
get() {
|
|
293
|
-
return e || document;
|
|
294
|
-
}
|
|
295
|
-
}), t.composedPath) {
|
|
296
|
-
const c = t.composedPath();
|
|
297
|
-
i(c[0]);
|
|
298
|
-
for (let a = 0; a < c.length - 2 && (e = c[a], !!l()); a++) {
|
|
299
|
-
if (e._$host) {
|
|
300
|
-
e = e._$host, o();
|
|
301
|
-
break;
|
|
302
|
-
}
|
|
303
|
-
if (e.parentNode === s)
|
|
304
|
-
break;
|
|
305
|
-
}
|
|
306
|
-
} else o();
|
|
307
|
-
i(r);
|
|
308
|
-
}
|
|
309
|
-
function N(t, e, n, r, s) {
|
|
310
|
-
for (; typeof n == "function"; ) n = n();
|
|
311
|
-
if (e === n) return n;
|
|
312
|
-
const i = typeof e, l = r !== 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
|
-
return n;
|
|
316
|
-
if (l) {
|
|
317
|
-
let o = n[0];
|
|
318
|
-
o && o.nodeType === 3 ? o.data !== e && (o.data = e) : o = document.createTextNode(e), n = C(t, n, r, o);
|
|
319
|
-
} else
|
|
320
|
-
n !== "" && typeof n == "string" ? n = t.firstChild.data = e : n = t.textContent = e;
|
|
321
|
-
} else if (e == null || i === "boolean")
|
|
322
|
-
n = C(t, n, r);
|
|
323
|
-
else {
|
|
324
|
-
if (i === "function")
|
|
325
|
-
return P(() => {
|
|
326
|
-
let o = e();
|
|
327
|
-
for (; typeof o == "function"; ) o = o();
|
|
328
|
-
n = N(t, o, n, r);
|
|
329
|
-
}), () => n;
|
|
330
|
-
if (Array.isArray(e)) {
|
|
331
|
-
const o = [], c = n && Array.isArray(n);
|
|
332
|
-
if (F(o, e, n, s))
|
|
333
|
-
return P(() => n = N(t, o, n, r, !0)), () => n;
|
|
334
|
-
if (o.length === 0) {
|
|
335
|
-
if (n = C(t, n, r), l) return n;
|
|
336
|
-
} else c ? n.length === 0 ? V(t, o, r) : ft(t, n, o) : (n && C(t), V(t, o));
|
|
337
|
-
n = o;
|
|
338
|
-
} else if (e.nodeType) {
|
|
339
|
-
if (Array.isArray(n)) {
|
|
340
|
-
if (l) return n = C(t, n, r, e);
|
|
341
|
-
C(t, n, null, e);
|
|
342
|
-
} else n == null || n === "" || !t.firstChild ? t.appendChild(e) : t.replaceChild(e, t.firstChild);
|
|
343
|
-
n = e;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
return n;
|
|
347
|
-
}
|
|
348
|
-
function F(t, e, n, r) {
|
|
349
|
-
let s = !1;
|
|
350
|
-
for (let i = 0, l = e.length; i < l; i++) {
|
|
351
|
-
let o = e[i], c = n && n[t.length], a;
|
|
352
|
-
if (!(o == null || o === !0 || o === !1)) if ((a = typeof o) == "object" && o.nodeType)
|
|
353
|
-
t.push(o);
|
|
354
|
-
else if (Array.isArray(o))
|
|
355
|
-
s = F(t, o, c) || s;
|
|
356
|
-
else if (a === "function")
|
|
357
|
-
if (r) {
|
|
358
|
-
for (; typeof o == "function"; ) o = o();
|
|
359
|
-
s = F(t, Array.isArray(o) ? o : [o], Array.isArray(c) ? c : [c]) || s;
|
|
360
|
-
} else
|
|
361
|
-
t.push(o), s = !0;
|
|
362
|
-
else {
|
|
363
|
-
const u = String(o);
|
|
364
|
-
c && c.nodeType === 3 && c.data === u ? t.push(c) : t.push(document.createTextNode(u));
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
return s;
|
|
368
|
-
}
|
|
369
|
-
function V(t, e, n = null) {
|
|
370
|
-
for (let r = 0, s = e.length; r < s; r++) t.insertBefore(e[r], n);
|
|
371
|
-
}
|
|
372
|
-
function C(t, e, n, r) {
|
|
373
|
-
if (n === void 0) return t.textContent = "";
|
|
374
|
-
const s = r || document.createTextNode("");
|
|
375
|
-
if (e.length) {
|
|
376
|
-
let i = !1;
|
|
377
|
-
for (let l = e.length - 1; l >= 0; l--) {
|
|
378
|
-
const o = e[l];
|
|
379
|
-
if (s !== o) {
|
|
380
|
-
const c = o.parentNode === t;
|
|
381
|
-
!i && !l ? c ? t.replaceChild(s, o) : t.insertBefore(s, n) : c && o.remove();
|
|
382
|
-
} else i = !0;
|
|
383
|
-
}
|
|
384
|
-
} else t.insertBefore(s, n);
|
|
385
|
-
return [s];
|
|
386
|
-
}
|
|
387
|
-
function gt(t) {
|
|
388
|
-
return Object.keys(t).reduce((n, r) => {
|
|
389
|
-
const s = t[r];
|
|
390
|
-
return n[r] = Object.assign({}, s), et(s.value) && !Ct(s.value) && !Array.isArray(s.value) && (n[r].value = Object.assign({}, s.value)), Array.isArray(s.value) && (n[r].value = s.value.slice(0)), n;
|
|
391
|
-
}, {});
|
|
392
|
-
}
|
|
393
|
-
function bt(t) {
|
|
394
|
-
return t ? Object.keys(t).reduce((n, r) => {
|
|
395
|
-
const s = t[r];
|
|
396
|
-
return n[r] = et(s) && "value" in s ? s : {
|
|
397
|
-
value: s
|
|
398
|
-
}, n[r].attribute || (n[r].attribute = wt(r)), n[r].parse = "parse" in n[r] ? n[r].parse : typeof n[r].value != "string", n;
|
|
399
|
-
}, {}) : {};
|
|
400
|
-
}
|
|
401
|
-
function yt(t) {
|
|
402
|
-
return Object.keys(t).reduce((n, r) => (n[r] = t[r].value, n), {});
|
|
403
|
-
}
|
|
404
|
-
function _t(t, e) {
|
|
405
|
-
const n = gt(e);
|
|
406
|
-
return Object.keys(e).forEach((s) => {
|
|
407
|
-
const i = n[s], l = t.getAttribute(i.attribute), o = t[s];
|
|
408
|
-
l != null && (i.value = i.parse ? tt(l) : l), o != null && (i.value = Array.isArray(o) ? o.slice(0) : o), i.reflect && D(t, i.attribute, i.value, !!i.parse), Object.defineProperty(t, s, {
|
|
409
|
-
get() {
|
|
410
|
-
return i.value;
|
|
411
|
-
},
|
|
412
|
-
set(c) {
|
|
413
|
-
const a = i.value;
|
|
414
|
-
i.value = c, i.reflect && D(this, i.attribute, i.value, !!i.parse);
|
|
415
|
-
for (let u = 0, h = this.__propertyChangedCallbacks.length; u < h; u++)
|
|
416
|
-
this.__propertyChangedCallbacks[u](s, c, a);
|
|
417
|
-
},
|
|
418
|
-
enumerable: !0,
|
|
419
|
-
configurable: !0
|
|
420
|
-
});
|
|
421
|
-
}), n;
|
|
422
|
-
}
|
|
423
|
-
function tt(t) {
|
|
424
|
-
if (t)
|
|
425
|
-
try {
|
|
426
|
-
return JSON.parse(t);
|
|
427
|
-
} catch {
|
|
428
|
-
return t;
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
function D(t, e, n, r) {
|
|
432
|
-
if (n == null || n === !1) return t.removeAttribute(e);
|
|
433
|
-
let s = r ? JSON.stringify(n) : n;
|
|
434
|
-
t.__updating[e] = !0, s === "true" && (s = ""), t.setAttribute(e, s), Promise.resolve().then(() => delete t.__updating[e]);
|
|
435
|
-
}
|
|
436
|
-
function wt(t) {
|
|
437
|
-
return t.replace(/\.?([A-Z]+)/g, (e, n) => "-" + n.toLowerCase()).replace("_", "-").replace(/^-/, "");
|
|
438
|
-
}
|
|
439
|
-
function et(t) {
|
|
440
|
-
return t != null && (typeof t == "object" || typeof t == "function");
|
|
441
|
-
}
|
|
442
|
-
function Ct(t) {
|
|
443
|
-
return Object.prototype.toString.call(t) === "[object Function]";
|
|
444
|
-
}
|
|
445
|
-
function vt(t) {
|
|
446
|
-
return typeof t == "function" && t.toString().indexOf("class") === 0;
|
|
447
|
-
}
|
|
448
|
-
let I;
|
|
449
|
-
function St(t, e) {
|
|
450
|
-
const n = Object.keys(e);
|
|
451
|
-
return class extends t {
|
|
452
|
-
static get observedAttributes() {
|
|
453
|
-
return n.map((s) => e[s].attribute);
|
|
454
|
-
}
|
|
455
|
-
constructor() {
|
|
456
|
-
super(), this.__initialized = !1, this.__released = !1, this.__releaseCallbacks = [], this.__propertyChangedCallbacks = [], this.__updating = {}, this.props = {};
|
|
457
|
-
}
|
|
458
|
-
connectedCallback() {
|
|
459
|
-
if (this.__initialized) return;
|
|
460
|
-
this.__releaseCallbacks = [], this.__propertyChangedCallbacks = [], this.__updating = {}, this.props = _t(this, e);
|
|
461
|
-
const s = yt(this.props), i = this.Component, l = I;
|
|
462
|
-
try {
|
|
463
|
-
I = this, this.__initialized = !0, vt(i) ? new i(s, {
|
|
464
|
-
element: this
|
|
465
|
-
}) : i(s, {
|
|
466
|
-
element: this
|
|
467
|
-
});
|
|
468
|
-
} finally {
|
|
469
|
-
I = l;
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
async disconnectedCallback() {
|
|
473
|
-
if (await Promise.resolve(), this.isConnected) return;
|
|
474
|
-
this.__propertyChangedCallbacks.length = 0;
|
|
475
|
-
let s = null;
|
|
476
|
-
for (; s = this.__releaseCallbacks.pop(); ) s(this);
|
|
477
|
-
delete this.__initialized, this.__released = !0;
|
|
478
|
-
}
|
|
479
|
-
attributeChangedCallback(s, i, l) {
|
|
480
|
-
if (this.__initialized && !this.__updating[s] && (s = this.lookupProp(s), s in e)) {
|
|
481
|
-
if (l == null && !this[s]) return;
|
|
482
|
-
this[s] = e[s].parse ? tt(l) : l;
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
lookupProp(s) {
|
|
486
|
-
if (e)
|
|
487
|
-
return n.find((i) => s === i || s === e[i].attribute);
|
|
488
|
-
}
|
|
489
|
-
get renderRoot() {
|
|
490
|
-
return this.shadowRoot || this.attachShadow({
|
|
491
|
-
mode: "open"
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
addReleaseCallback(s) {
|
|
495
|
-
this.__releaseCallbacks.push(s);
|
|
496
|
-
}
|
|
497
|
-
addPropertyChangedCallback(s) {
|
|
498
|
-
this.__propertyChangedCallbacks.push(s);
|
|
499
|
-
}
|
|
500
|
-
};
|
|
501
|
-
}
|
|
502
|
-
function Et(t, e = {}, n = {}) {
|
|
503
|
-
const {
|
|
504
|
-
BaseElement: r = HTMLElement,
|
|
505
|
-
extension: s,
|
|
506
|
-
customElements: i = window.customElements
|
|
507
|
-
} = n;
|
|
508
|
-
return (l) => {
|
|
509
|
-
let o = i.get(t);
|
|
510
|
-
return o ? (o.prototype.Component = l, o) : (o = St(r, bt(e)), o.prototype.Component = l, o.prototype.registeredTag = t, i.define(t, o, s), o);
|
|
511
|
-
};
|
|
512
|
-
}
|
|
513
|
-
function At(t) {
|
|
514
|
-
const e = Object.keys(t), n = {};
|
|
515
|
-
for (let r = 0; r < e.length; r++) {
|
|
516
|
-
const [s, i] = z(t[e[r]]);
|
|
517
|
-
Object.defineProperty(n, e[r], {
|
|
518
|
-
get: s,
|
|
519
|
-
set(l) {
|
|
520
|
-
i(() => l);
|
|
521
|
-
}
|
|
522
|
-
});
|
|
523
|
-
}
|
|
524
|
-
return n;
|
|
525
|
-
}
|
|
526
|
-
function mt(t) {
|
|
527
|
-
if (t.assignedSlot && t.assignedSlot._$owner) return t.assignedSlot._$owner;
|
|
528
|
-
let e = t.parentNode;
|
|
529
|
-
for (; e && !e._$owner && !(e.assignedSlot && e.assignedSlot._$owner); )
|
|
530
|
-
e = e.parentNode;
|
|
531
|
-
return e && e.assignedSlot ? e.assignedSlot._$owner : t._$owner;
|
|
532
|
-
}
|
|
533
|
-
function xt(t) {
|
|
534
|
-
return (e, n) => {
|
|
535
|
-
const { element: r } = n;
|
|
536
|
-
return ot((s) => {
|
|
537
|
-
const i = At(e);
|
|
538
|
-
r.addPropertyChangedCallback((o, c) => i[o] = c), r.addReleaseCallback(() => {
|
|
539
|
-
r.renderRoot.textContent = "", s();
|
|
540
|
-
});
|
|
541
|
-
const l = t(i, n);
|
|
542
|
-
return S(r.renderRoot, l);
|
|
543
|
-
}, mt(r));
|
|
544
|
-
};
|
|
545
|
-
}
|
|
546
|
-
function $t(t, e, n) {
|
|
547
|
-
return arguments.length === 2 && (n = e, e = {}), Et(t, e)(xt(n));
|
|
548
|
-
}
|
|
549
|
-
const kt = `
|
|
550
|
-
:host([theme="dark"]) {
|
|
551
|
-
color-scheme: only dark;
|
|
552
|
-
}
|
|
553
|
-
:host([theme="light"]) {
|
|
554
|
-
color-scheme: only light;
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
:host .dictate-button__container {
|
|
558
|
-
margin: 5px;
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
:host .dictate-button__button {
|
|
562
|
-
cursor: pointer;
|
|
563
|
-
padding: 2px;
|
|
564
|
-
display: inline-flex;
|
|
565
|
-
align-items: center;
|
|
566
|
-
justify-content: center;
|
|
567
|
-
opacity: 0.8;
|
|
568
|
-
transition: opacity 0.2s ease-in-out;
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
:host .dictate-button__button .dictate-button__icon {
|
|
572
|
-
width: 100%;
|
|
573
|
-
height: 100%;
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
:host .dictate-button__button .dictate-button__icon.dictate-button__icon--processing {
|
|
577
|
-
animation: dictate-button-rotate 1s linear infinite;
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
@keyframes dictate-button-rotate {
|
|
581
|
-
0% { transform: rotate(0deg); }
|
|
582
|
-
100% { transform: rotate(360deg); }
|
|
583
|
-
}
|
|
584
|
-
`;
|
|
585
|
-
var Tt = /* @__PURE__ */ m("<div part=container class=dictate-button__container><style></style><button part=button class=dictate-button__button>"), Ot = /* @__PURE__ */ m('<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">'), Pt = /* @__PURE__ */ m('<svg part=icon class="dictate-button__icon dictate-button__icon--recording"viewBox="0 0 24 24"fill=currentColor><path fill-rule=evenodd d="M4.5 7.5a3 3 0 0 1 3-3h9a3 3 0 0 1 3 3v9a3 3 0 0 1-3 3h-9a3 3 0 0 1-3-3v-9Z"clip-rule=evenodd>'), jt = /* @__PURE__ */ m('<svg part=icon class="dictate-button__icon dictate-button__icon--processing"fill=none viewBox="0 0 24 24"stroke-width=1.5 stroke=currentColor><path stroke-linecap=round stroke-linejoin=round d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0 3.181 3.183a8.25 8.25 0 0 0 13.803-3.7M4.031 9.865a8.25 8.25 0 0 1 13.803-3.7l3.181 3.182m0-4.991v4.99">'), Nt = /* @__PURE__ */ m('<svg part=icon class="dictate-button__icon dictate-button__icon--error"fill=none viewBox="0 0 24 24"stroke-width=1.5 stroke=currentColor><path stroke-linecap=round stroke-linejoin=round d="M6 18 18 6M6 6l12 12">');
|
|
586
|
-
console.debug("dictate-button version:", "0.2.0");
|
|
587
|
-
const Bt = "https://api.dictate-button.io/transcribe", k = "dictate-button.io";
|
|
588
|
-
$t("dictate-button", {
|
|
589
|
-
size: 24,
|
|
590
|
-
apiEndpoint: Bt
|
|
591
|
-
}, (t, {
|
|
592
|
-
element: e
|
|
593
|
-
}) => {
|
|
594
|
-
const {
|
|
595
|
-
size: n,
|
|
596
|
-
apiEndpoint: r
|
|
597
|
-
} = t;
|
|
598
|
-
console.debug("api", r);
|
|
599
|
-
const [s, i] = z("idle");
|
|
600
|
-
let l = null, o = [];
|
|
601
|
-
const c = () => {
|
|
602
|
-
l && l.state !== "inactive" && l.stop(), o = [];
|
|
603
|
-
};
|
|
604
|
-
e.addEventListener("disconnected", c);
|
|
605
|
-
const a = async () => {
|
|
606
|
-
if (c(), s() === "idle")
|
|
607
|
-
try {
|
|
608
|
-
const h = await navigator.mediaDevices.getUserMedia({
|
|
609
|
-
audio: !0
|
|
610
|
-
});
|
|
611
|
-
l = new MediaRecorder(h, {
|
|
612
|
-
mimeType: "audio/webm"
|
|
613
|
-
}), o = [], l.ondataavailable = (y) => {
|
|
614
|
-
o.push(y.data);
|
|
615
|
-
}, l.onstop = async () => {
|
|
616
|
-
i("processing"), v(e, "transcribing:started", "Started transcribing");
|
|
617
|
-
const y = new Blob(o, {
|
|
618
|
-
type: "audio/webm"
|
|
619
|
-
});
|
|
620
|
-
try {
|
|
621
|
-
const g = await fetch(r, {
|
|
622
|
-
method: "POST",
|
|
623
|
-
body: y
|
|
624
|
-
});
|
|
625
|
-
if (!g.ok) throw new Error("Failed to transcribe audio");
|
|
626
|
-
const d = await g.json();
|
|
627
|
-
if (s() !== "processing") return;
|
|
628
|
-
v(e, "transcribing:finished", d.text), i("idle");
|
|
629
|
-
} catch (g) {
|
|
630
|
-
console.error("Failed to transcribe audio:", g), v(e, "transcribing:failed", "Failed to transcribe audio"), u();
|
|
631
|
-
}
|
|
632
|
-
}, l.start(), v(e, "recording:started", "Started recording"), i("recording");
|
|
633
|
-
} catch (h) {
|
|
634
|
-
console.error("Failed to start recording:", h), v(e, "recording:failed", "Failed to start recording"), u();
|
|
635
|
-
}
|
|
636
|
-
else
|
|
637
|
-
v(e, "recording:stopped", "Stopped recording"), i("idle");
|
|
638
|
-
}, u = () => {
|
|
639
|
-
i("error"), setTimeout(() => i("idle"), 2e3);
|
|
640
|
-
};
|
|
641
|
-
return (() => {
|
|
642
|
-
var h = Tt(), y = h.firstChild, g = y.nextSibling;
|
|
643
|
-
return S(y, kt), g.$$click = a, S(g, (() => {
|
|
644
|
-
var d = $(() => s() === "idle");
|
|
645
|
-
return () => d() && x(Rt, {});
|
|
646
|
-
})(), null), S(g, (() => {
|
|
647
|
-
var d = $(() => s() === "recording");
|
|
648
|
-
return () => d() && x(It, {});
|
|
649
|
-
})(), null), S(g, (() => {
|
|
650
|
-
var d = $(() => s() === "processing");
|
|
651
|
-
return () => d() && x(Ft, {});
|
|
652
|
-
})(), null), S(g, (() => {
|
|
653
|
-
var d = $(() => s() === "error");
|
|
654
|
-
return () => d() && x(Lt, {});
|
|
655
|
-
})(), null), P((d) => {
|
|
656
|
-
var nt = `width:${n}px;height:${n}px"`, K = Mt(s());
|
|
657
|
-
return d.e = ht(g, nt, d.e), K !== d.t && Y(g, "title", d.t = K), d;
|
|
658
|
-
}, {
|
|
659
|
-
e: void 0,
|
|
660
|
-
t: void 0
|
|
661
|
-
}), h;
|
|
662
|
-
})();
|
|
663
|
-
});
|
|
664
|
-
const Mt = (t) => {
|
|
665
|
-
switch (t) {
|
|
666
|
-
case "idle":
|
|
667
|
-
return `Start dictation (${k})`;
|
|
668
|
-
case "recording":
|
|
669
|
-
return `Stop dictation (${k})`;
|
|
670
|
-
case "processing":
|
|
671
|
-
return `Stop processing (${k})`;
|
|
672
|
-
case "error":
|
|
673
|
-
return `Click to reset (${k})`;
|
|
674
|
-
}
|
|
675
|
-
}, v = (t, e, n) => {
|
|
676
|
-
t.dispatchEvent(new CustomEvent(e, {
|
|
677
|
-
detail: n,
|
|
678
|
-
bubbles: !0,
|
|
679
|
-
composed: !0
|
|
680
|
-
}));
|
|
681
|
-
}, Rt = () => Ot(), It = () => Pt(), Ft = () => jt(), Lt = () => Nt();
|
|
682
|
-
dt(["click"]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function i(){const a=document.querySelectorAll('textarea[data-dictate-button-on]:not([data-dictate-button-enabled]), input[type="text"][data-dictate-button-on]:not([data-dictate-button-enabled]), textarea[data-dictate-button-target]:not([data-dictate-button-enabled]), input[type="text"][data-dictate-button-target]:not([data-dictate-button-enabled])');for(const o of a){const n=document.createElement("div");n.style.position="relative",n.style.display="inline-block",n.style.width="auto",n.style.color="inherit",o.parentNode.insertBefore(n,o),o.setAttribute("data-dictate-button-enabled",""),n.appendChild(o),o.style.boxSizing="border-box";const t=document.createElement("dictate-button");t.size=24,t.style.position="absolute",t.style.right="0",t.style.top="0",t.addEventListener("recording:started",e=>{console.log("recording:started",e)}),t.addEventListener("recording:stopped",e=>{console.log("recording:stopped",e)}),t.addEventListener("recording:failed",e=>{console.log("recording:failed",e)}),t.addEventListener("transcribing:started",e=>{console.log("transcribing:started",e)}),t.addEventListener("transcribing:finished",e=>{console.log("transcribing:finished",e);const d=e.detail;r(o,d)}),t.addEventListener("transcribing:failed",e=>{console.log("transcribing:failed",e)}),n.appendChild(t)}}function r(a,o){const n=a.selectionStart||0,t=a.selectionEnd||0;a.value=a.value.substring(0,n)+o+a.value.substring(t)}document.addEventListener("DOMContentLoaded",()=>{i(),new MutationObserver(i).observe(document.body,{childList:!0,subtree:!0})});
|