speakid-build-a-sentence 1.0.25 → 1.0.26
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.
|
@@ -173,7 +173,7 @@ const Te = {
|
|
|
173
173
|
// ===== Анимационные стили =====
|
|
174
174
|
...Te
|
|
175
175
|
}, ln = () => {
|
|
176
|
-
const [u, s] = c([]),
|
|
176
|
+
const [u, s] = c([]), S = ge((H, I, f) => {
|
|
177
177
|
const b = [];
|
|
178
178
|
H.trim() || b.push({
|
|
179
179
|
type: "empty",
|
|
@@ -185,10 +185,10 @@ const Te = {
|
|
|
185
185
|
type: "characters",
|
|
186
186
|
message: "Only Latin characters, numbers, spaces and punctuation are allowed"
|
|
187
187
|
});
|
|
188
|
-
const
|
|
189
|
-
return
|
|
188
|
+
const W = f.findIndex((C, K) => K !== I && C.toLowerCase().trim() === H.toLowerCase().trim());
|
|
189
|
+
return W !== -1 && b.push({
|
|
190
190
|
type: "duplicate",
|
|
191
|
-
message: `Duplicate sentence (same as sentence ${
|
|
191
|
+
message: `Duplicate sentence (same as sentence ${W + 1})`
|
|
192
192
|
}), s(b), {
|
|
193
193
|
isValid: b.length === 0,
|
|
194
194
|
errors: b
|
|
@@ -196,26 +196,26 @@ const Te = {
|
|
|
196
196
|
}, []), se = ge((H) => {
|
|
197
197
|
const I = [];
|
|
198
198
|
return H.forEach((f, b) => {
|
|
199
|
-
const y =
|
|
200
|
-
I.push(...y.errors.map((
|
|
201
|
-
...
|
|
202
|
-
message: `Sentence ${b + 1}: ${
|
|
199
|
+
const y = S(f, b, H);
|
|
200
|
+
I.push(...y.errors.map((W) => ({
|
|
201
|
+
...W,
|
|
202
|
+
message: `Sentence ${b + 1}: ${W.message}`
|
|
203
203
|
})));
|
|
204
204
|
}), {
|
|
205
205
|
isValid: I.length === 0,
|
|
206
206
|
errors: I
|
|
207
207
|
};
|
|
208
|
-
}, [
|
|
208
|
+
}, [S]), de = ge(() => {
|
|
209
209
|
s([]);
|
|
210
210
|
}, []);
|
|
211
211
|
return {
|
|
212
212
|
errors: u,
|
|
213
|
-
validateSentence:
|
|
213
|
+
validateSentence: S,
|
|
214
214
|
validateAllSentences: se,
|
|
215
215
|
clearErrors: de
|
|
216
216
|
};
|
|
217
|
-
}, cn = (u, s,
|
|
218
|
-
|
|
217
|
+
}, cn = (u, s, S) => s && S ? `${u} word "${s}" ${S}` : s ? `${u} word "${s}"` : u, hn = (u, s, S = ["Enter", " "]) => {
|
|
218
|
+
S.includes(u.key) && (u.preventDefault(), s());
|
|
219
219
|
}, L = (u) => {
|
|
220
220
|
const s = document.createElement("div");
|
|
221
221
|
s.setAttribute("aria-live", "polite"), s.setAttribute("aria-atomic", "true"), s.style.position = "absolute", s.style.left = "-10000px", s.style.width = "1px", s.style.height = "1px", s.style.overflow = "hidden", document.body.appendChild(s), s.textContent = u, setTimeout(() => {
|
|
@@ -254,7 +254,7 @@ const Te = {
|
|
|
254
254
|
s && s.remove(), document.head.appendChild(u);
|
|
255
255
|
}, gn = (u) => [...u].sort(() => Math.random() - 0.5);
|
|
256
256
|
function yn(u = {}) {
|
|
257
|
-
const { logoUrl: s, showLogo:
|
|
257
|
+
const { logoUrl: s, showLogo: S = !0 } = u, se = oe(null), { validateAllSentences: de, errors: H } = ln(), I = () => !!(d || window.innerWidth < 768 || window.innerWidth >= 768 && window.innerWidth < 1300), f = () => d || window.innerWidth < 768 || window.innerWidth >= 320 && window.innerWidth <= 932 && window.innerHeight >= 390 && window.innerHeight <= 932, b = (e = "medium") => {
|
|
258
258
|
if (!f())
|
|
259
259
|
return {
|
|
260
260
|
padding: "12px 24px",
|
|
@@ -287,9 +287,9 @@ function yn(u = {}) {
|
|
|
287
287
|
const e = document.getElementById("magic-sentence-reset");
|
|
288
288
|
e && e.remove();
|
|
289
289
|
}), []);
|
|
290
|
-
const [y,
|
|
290
|
+
const [y, W] = c("select"), [C, K] = c(null), [ue, we] = c(null), [T, Z] = c([]), [D, fe] = c(0), [ae, me] = c([]), [k, le] = c([]), [B, xe] = c(20), [U, M] = c(0), [un, ye] = c(null), [A, z] = c(null), [l, _] = c(!1), [be, ce] = c(!1), [he, De] = c(
|
|
291
291
|
Number(localStorage.getItem("magicSentenceBest")) || 0
|
|
292
|
-
), J = oe(null), Re = oe(null),
|
|
292
|
+
), J = oe(null), Re = oe(null), We = oe(0), [m, E] = c({ list: null, id: null, side: null }), [d, ze] = c(!1), [Ee, Q] = c(1), [Se, ee] = c(null), [Pe, Be] = c(!1), [$, Le] = c(!1), [O, Me] = c(!1), [N, Ae] = c(!1), [G, $e] = c(!1), [X, Oe] = c(!1), [j, Ne] = c(!1), [F, Ge] = c(!1), [q, Xe] = c(!1), [wn, je] = c(!1), [fn, Fe] = c(!1);
|
|
293
293
|
V(() => {
|
|
294
294
|
const e = () => {
|
|
295
295
|
const t = window.innerWidth, n = window.innerHeight, i = t < 768 || t === 926 && n === 428 || t === 932 && n === 430, r = n < 700, p = t / n > 1.8, w = t === 768 && n === 1024, o = t === 1024 && n === 768, h = t === 820 && n === 1180, R = t === 1180 && n === 820, v = t === 540 && n === 720, re = t === 720 && n === 540, He = t === 1024 && n === 1366, Ie = t === 1366 && n === 1024, Ce = t >= 1200 && n >= 600 && !i;
|
|
@@ -340,9 +340,9 @@ function yn(u = {}) {
|
|
|
340
340
|
E({ list: null, id: null, side: null });
|
|
341
341
|
}
|
|
342
342
|
}, qe = (e) => {
|
|
343
|
-
K(e), Re.current = e, Z(Array(e).fill("")),
|
|
343
|
+
K(e), Re.current = e, Z(Array(e).fill("")), W("time");
|
|
344
344
|
}, Ve = (e) => {
|
|
345
|
-
we(e),
|
|
345
|
+
we(e), W("type");
|
|
346
346
|
}, Ue = (e, t) => {
|
|
347
347
|
if (t.length > 41 || t && !/^[a-zA-Z0-9\s.,!?;:'"-]*$/.test(t))
|
|
348
348
|
return;
|
|
@@ -350,8 +350,11 @@ function yn(u = {}) {
|
|
|
350
350
|
i[e] = t, Z(i);
|
|
351
351
|
const r = de(i);
|
|
352
352
|
r.isValid || console.warn("Validation errors:", r.errors);
|
|
353
|
-
}, Je = (e) => e.trim().replace(/\s+/g, " "), ke = (e) =>
|
|
354
|
-
|
|
353
|
+
}, Je = (e) => e.trim().replace(/\s+/g, " "), ke = (e) => {
|
|
354
|
+
const t = window.innerWidth >= 768 && window.innerWidth < 1300;
|
|
355
|
+
return e <= 3 ? t ? 18 : 20 : e <= 5 ? t ? 16 : 18 : e <= 7 ? t ? 14 : 16 : e <= 9 ? t ? 12 : 14 : e <= 12 ? t ? 10 : 12 : t ? 9 : 10;
|
|
356
|
+
}, Ye = () => {
|
|
357
|
+
T.some((t) => t.trim().length === 0) || (Z((t) => t.map((n) => Je(n))), M(0), fe(0), We.current = 0, ye(null), W("getready"));
|
|
355
358
|
};
|
|
356
359
|
V(() => {
|
|
357
360
|
if (y === "getready") {
|
|
@@ -368,7 +371,7 @@ function yn(u = {}) {
|
|
|
368
371
|
id: `${Date.now()}-${e}-${p}-${Math.random().toString(36).slice(2)}`,
|
|
369
372
|
text: r
|
|
370
373
|
}));
|
|
371
|
-
me(i), le([]), fe(e),
|
|
374
|
+
me(i), le([]), fe(e), We.current = e, xe(ue || 20), z(null), _(!1), ce(!1), W("play");
|
|
372
375
|
};
|
|
373
376
|
V(() => (y === "play" && !l && (J.current !== null && window.clearTimeout(J.current), B > 0 ? J.current = window.setTimeout(() => xe((e) => e - 1), 1e3) : _(!0)), () => {
|
|
374
377
|
J.current !== null && window.clearTimeout(J.current);
|
|
@@ -386,17 +389,17 @@ function yn(u = {}) {
|
|
|
386
389
|
const Ke = (e = !0) => {
|
|
387
390
|
if (e) {
|
|
388
391
|
if (l) {
|
|
389
|
-
D + 1 < (C || 0) ? te(D + 1) : (
|
|
392
|
+
D + 1 < (C || 0) ? te(D + 1) : (W("results"), setTimeout(() => ie(), 600));
|
|
390
393
|
return;
|
|
391
394
|
}
|
|
392
395
|
const t = T[D];
|
|
393
396
|
if (!t) {
|
|
394
|
-
D + 1 < (C || 0) ? te(D + 1) : (
|
|
397
|
+
D + 1 < (C || 0) ? te(D + 1) : (W("results"), setTimeout(() => ie(), 600));
|
|
395
398
|
return;
|
|
396
399
|
}
|
|
397
400
|
const n = t.trim().split(/\s+/), i = k.map((h) => h.text), r = n.filter((h) => !i.includes(h)).length, p = i.filter((h) => !n.includes(h)).length, w = n.filter((h, R) => i.includes(h) ? i[R] !== h : !1).length, o = r + p + w;
|
|
398
401
|
o === 0 ? (M((h) => h + 1), z("correct"), ce(!0), P("correct"), L("Correct! Well done!")) : o === 1 ? (M((h) => h + 0.5), z("almost"), P("half"), L("Almost correct! Just one mistake.")) : (z("wrong"), P("wrong"), L("Not quite right. Keep trying!")), D + 1 < (C || 0) ? setTimeout(() => te(D + 1), 800) : setTimeout(() => {
|
|
399
|
-
|
|
402
|
+
W("results"), setTimeout(() => ie(), 600);
|
|
400
403
|
}, 800);
|
|
401
404
|
}
|
|
402
405
|
};
|
|
@@ -632,7 +635,8 @@ function yn(u = {}) {
|
|
|
632
635
|
border: "1px solid #ccc",
|
|
633
636
|
background: l ? "#f0f0f0" : "#f9f9f9",
|
|
634
637
|
cursor: l ? "not-allowed" : m.list === "bank" && m.id === e.id ? "grabbing" : "grab",
|
|
635
|
-
fontSize: d || window.innerWidth < 768 ? "12px" : "18px",
|
|
638
|
+
fontSize: d || window.innerWidth < 768 ? "12px" : window.innerWidth >= 768 && window.innerWidth < 1300 ? "14px" : "18px",
|
|
639
|
+
// Полный размер только для Pro и больших экранов
|
|
636
640
|
...m.list === "bank" && m.id === e.id && m.side === "left" ? { borderLeft: "3px solid #3b82f6" } : {},
|
|
637
641
|
...m.list === "bank" && m.id === e.id && m.side === "right" ? { borderRight: "3px solid #3b82f6" } : {},
|
|
638
642
|
flexShrink: 0,
|
|
@@ -800,7 +804,7 @@ function yn(u = {}) {
|
|
|
800
804
|
{
|
|
801
805
|
onClick: () => {
|
|
802
806
|
ie(), P("start"), setTimeout(() => {
|
|
803
|
-
|
|
807
|
+
W("getready"), ye(null), _(!1);
|
|
804
808
|
}, 800);
|
|
805
809
|
},
|
|
806
810
|
style: {
|
|
@@ -814,7 +818,7 @@ function yn(u = {}) {
|
|
|
814
818
|
"button",
|
|
815
819
|
{
|
|
816
820
|
onClick: () => {
|
|
817
|
-
P("click"),
|
|
821
|
+
P("click"), W("select"), K(null), we(null), Z([]), M(0), le([]), _(!1);
|
|
818
822
|
},
|
|
819
823
|
style: {
|
|
820
824
|
...g.gmButton,
|
|
@@ -824,7 +828,7 @@ function yn(u = {}) {
|
|
|
824
828
|
}
|
|
825
829
|
)
|
|
826
830
|
] })
|
|
827
|
-
] }), ve = !d &&
|
|
831
|
+
] }), ve = !d && S, rn = sn(
|
|
828
832
|
() => {
|
|
829
833
|
if (d && window.innerWidth > window.innerHeight || window.innerHeight < 700 || !ve)
|
|
830
834
|
return null;
|
|
@@ -876,8 +880,8 @@ function yn(u = {}) {
|
|
|
876
880
|
"div",
|
|
877
881
|
{
|
|
878
882
|
style: {
|
|
879
|
-
width: d ? "100%" :
|
|
880
|
-
height: d ? "100%" :
|
|
883
|
+
width: d ? "100%" : Se || 1e3,
|
|
884
|
+
height: d ? "100%" : Se || 1e3,
|
|
881
885
|
display: "flex",
|
|
882
886
|
justifyContent: "center",
|
|
883
887
|
alignItems: "center",
|
|
@@ -928,10 +932,10 @@ class bn extends dn {
|
|
|
928
932
|
error: s
|
|
929
933
|
};
|
|
930
934
|
}
|
|
931
|
-
componentDidCatch(s,
|
|
932
|
-
console.error("Game Error:", s,
|
|
935
|
+
componentDidCatch(s, S) {
|
|
936
|
+
console.error("Game Error:", s, S), this.setState({
|
|
933
937
|
error: s,
|
|
934
|
-
errorInfo:
|
|
938
|
+
errorInfo: S
|
|
935
939
|
});
|
|
936
940
|
}
|
|
937
941
|
handleReset = () => {
|