@burdenoff/fe-libs 2026.1028.3 → 2026.1028.4

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.
@@ -35,72 +35,78 @@ function d(e) {
35
35
  default: return "unknown";
36
36
  }
37
37
  }
38
- function f({ onFinalize: s, language: c }) {
39
- let { locale: f } = e(), [p, m] = i(!1), [h, g] = i(!1), [_, v] = i(""), [y, b] = i(null), x = r(null), S = r(0), C = r(-Infinity), w = r(0), T = r(s);
38
+ function f({ onFinalize: s, onSpeechEnd: c, language: f }) {
39
+ let { locale: p } = e(), [m, h] = i(!1), [g, _] = i(!1), [v, y] = i(""), [b, x] = i(null), S = r(null), C = r(0), w = r(-Infinity), T = r(0), E = r(c);
40
40
  n(() => {
41
- T.current = s;
41
+ E.current = c;
42
+ }, [c]);
43
+ let D = r(s);
44
+ n(() => {
45
+ D.current = s;
42
46
  }, [s]);
43
- let E = o() !== null, D = c ?? a[f] ?? "en-US";
47
+ let O = o() !== null, k = f ?? a[p] ?? "en-US";
44
48
  n(() => () => {
45
- x.current?.abort(), x.current = null;
49
+ S.current?.abort(), S.current = null;
46
50
  }, []);
47
- let O = t((e = "manual") => {
51
+ let A = t((e = "manual") => {
48
52
  let t = o();
49
- if (!t || x.current || e === "auto" && u(C.current, performance.now())) return;
53
+ if (!t || S.current || e === "auto" && u(w.current, performance.now())) return;
50
54
  let n = new t();
51
- n.continuous = !0, n.interimResults = !0, n.lang = D;
52
- let r = S.current;
53
- n.onresult = (e) => {
54
- if (r !== S.current) return;
55
+ n.continuous = !0, n.interimResults = !0, n.lang = k;
56
+ let r = C.current;
57
+ n.onspeechend = () => {
58
+ r === C.current && E.current?.(performance.now());
59
+ }, n.onresult = (e) => {
60
+ if (r !== C.current) return;
55
61
  let t = "", n = "";
56
62
  for (let r = e.resultIndex; r < e.results.length; r += 1) {
57
63
  let i = e.results[r], a = i[0]?.transcript ?? "";
58
64
  i.isFinal ? t += a : n += a;
59
65
  }
60
- t.trim() && T.current(t.trim()), v(n.trim());
66
+ t.trim() && D.current(t.trim()), y(n.trim());
61
67
  }, n.onerror = (e) => {
62
- if (r !== S.current) return;
68
+ if (r !== C.current) return;
63
69
  let t = d(e.error);
64
- t !== "no-speech" && b(t);
70
+ t !== "no-speech" && x(t);
65
71
  }, n.onend = () => {
66
- r === S.current && (x.current = null, g(!1), m(!1), v(""));
72
+ r === C.current && (S.current = null, _(!1), h(!1), y(""));
67
73
  }, n.onstart = () => {
68
- r === S.current && (g(!1), m(!0));
69
- }, g(!0);
74
+ r === C.current && (_(!1), h(!0));
75
+ }, _(!0);
70
76
  try {
71
77
  n.start();
72
78
  } catch {
73
- C.current = performance.now(), w.current += 1, w.current >= l && b("unknown"), x.current = null, g(!1), m(!1);
79
+ w.current = performance.now(), T.current += 1, T.current >= l && x("unknown"), S.current = null, _(!1), h(!1);
74
80
  return;
75
81
  }
76
- x.current = n, w.current = 0, b(null), v("");
77
- }, [D]), k = t(() => {
78
- let e = x.current;
79
- x.current = null, S.current += 1, e?.stop(), g(!1), m(!1), v("");
80
- }, []), A = r(D);
82
+ S.current = n, T.current = 0, x(null), y("");
83
+ }, [k]), j = t(() => {
84
+ let e = S.current;
85
+ S.current = null, C.current += 1, e?.stop(), _(!1), h(!1), y("");
86
+ }, []), M = r(k);
81
87
  n(() => {
82
- A.current !== D && (A.current = D, k(), b(null));
83
- }, [D, k]);
84
- let j = t(() => {
85
- p || h ? k() : O();
88
+ M.current !== k && (M.current = k, j(), x(null));
89
+ }, [k, j]);
90
+ let N = t(() => {
91
+ m || g ? j() : A();
86
92
  }, [
87
- p,
88
- h,
89
- O,
90
- k
91
- ]), M = t(() => b(null), []);
93
+ m,
94
+ g,
95
+ A,
96
+ j
97
+ ]), P = t(() => x(null), []);
92
98
  return {
93
- isSupported: E,
94
- isListening: p,
95
- isStarting: h,
96
- isActive: p || h,
97
- interim: _,
98
- error: y,
99
- language: D,
100
- start: O,
101
- stop: k,
102
- toggle: j,
103
- clearError: M
99
+ isSupported: O,
100
+ isListening: m,
101
+ isStarting: g,
102
+ isActive: m || g,
103
+ interim: v,
104
+ error: b,
105
+ language: k,
106
+ start: A,
107
+ stop: j,
108
+ toggle: N,
109
+ clearError: P
104
110
  };
105
111
  }
106
112
  //#endregion