speakid-build-a-sentence 1.0.29 → 1.0.30
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/dist/Game.d.ts.map +1 -1
- package/dist/Game.styles.d.ts +1 -0
- package/dist/Game.styles.d.ts.map +1 -1
- package/dist/speakid-build-a-sentence.cjs.js +1 -1
- package/dist/speakid-build-a-sentence.cjs.js.map +1 -1
- package/dist/speakid-build-a-sentence.es.js +28 -28
- package/dist/speakid-build-a-sentence.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -174,7 +174,7 @@ const Ce = {
|
|
|
174
174
|
// ===== Анимационные стили =====
|
|
175
175
|
...Ce
|
|
176
176
|
}, ft = () => {
|
|
177
|
-
const [f, s] = l([]), v = ce((k,
|
|
177
|
+
const [f, s] = l([]), v = ce((k, L, h) => {
|
|
178
178
|
const w = [];
|
|
179
179
|
k.trim() || w.push({
|
|
180
180
|
type: "empty",
|
|
@@ -186,7 +186,7 @@ const Ce = {
|
|
|
186
186
|
type: "characters",
|
|
187
187
|
message: "Only Latin characters, numbers, spaces and punctuation are allowed"
|
|
188
188
|
});
|
|
189
|
-
const O = h.findIndex((N, y) => y !==
|
|
189
|
+
const O = h.findIndex((N, y) => y !== L && N.toLowerCase().trim() === k.toLowerCase().trim());
|
|
190
190
|
return O !== -1 && w.push({
|
|
191
191
|
type: "duplicate",
|
|
192
192
|
message: `Duplicate sentence (same as sentence ${O + 1})`
|
|
@@ -195,16 +195,16 @@ const Ce = {
|
|
|
195
195
|
errors: w
|
|
196
196
|
};
|
|
197
197
|
}, []), H = ce((k) => {
|
|
198
|
-
const
|
|
198
|
+
const L = [];
|
|
199
199
|
return k.forEach((h, w) => {
|
|
200
200
|
const K = v(h, w, k);
|
|
201
|
-
|
|
201
|
+
L.push(...K.errors.map((O) => ({
|
|
202
202
|
...O,
|
|
203
203
|
message: `Sentence ${w + 1}: ${O.message}`
|
|
204
204
|
})));
|
|
205
205
|
}), {
|
|
206
|
-
isValid:
|
|
207
|
-
errors:
|
|
206
|
+
isValid: L.length === 0,
|
|
207
|
+
errors: L
|
|
208
208
|
};
|
|
209
209
|
}, [v]), $ = ce(() => {
|
|
210
210
|
s([]);
|
|
@@ -255,7 +255,7 @@ const Ce = {
|
|
|
255
255
|
s && s.remove(), document.head.appendChild(f);
|
|
256
256
|
}, xt = (f) => [...f].sort(() => Math.random() - 0.5);
|
|
257
257
|
function kt(f = {}) {
|
|
258
|
-
const { logoUrl: s, showLogo: v = !0, screenHeight: H, screenWidth: $, gameCubeSize: k } = f,
|
|
258
|
+
const { logoUrl: s, showLogo: v = !0, screenHeight: H, screenWidth: $, gameCubeSize: k } = f, L = re(null), h = () => $ ?? (typeof window < "u" ? window.innerWidth : 1920), w = () => H ?? (typeof window < "u" ? window.innerHeight : 1080), { validateAllSentences: K, errors: O } = ft(), N = () => {
|
|
259
259
|
const e = h();
|
|
260
260
|
return !!(m || e < 768 || e >= 768 && e < 1300);
|
|
261
261
|
}, y = () => {
|
|
@@ -294,13 +294,13 @@ function kt(f = {}) {
|
|
|
294
294
|
const e = document.getElementById("magic-sentence-reset");
|
|
295
295
|
e && e.remove();
|
|
296
296
|
}), []);
|
|
297
|
-
const [S, z] = l("select"), [E, de] = l(null), [pe, ue] = l(null), [T, Z] = l([]), [D, fe] = l(0), [oe, me] = l([]), [I, ie] = l([]), [
|
|
297
|
+
const [S, z] = l("select"), [E, de] = l(null), [pe, ue] = l(null), [T, Z] = l([]), [D, fe] = l(0), [oe, me] = l([]), [I, ie] = l([]), [M, ge] = l(20), [V, G] = l(0), [yt, he] = l(null), [X, P] = l(null), [a, _] = l(!1), [xe, se] = l(!1), [ae, Te] = l(
|
|
298
298
|
Number(localStorage.getItem("magicSentenceBest")) || 0
|
|
299
|
-
), q = re(null), De = re(null), ye = re(0), [x, B] = l({ list: null, id: null, side: null }), [m, Re] = l(!1), [ze, U] = l(1), [be, J] = l(null), [Ee, Pe] = l(!1), [Be,
|
|
299
|
+
), q = re(null), De = re(null), ye = re(0), [x, B] = l({ list: null, id: null, side: null }), [m, Re] = l(!1), [ze, U] = l(1), [be, J] = l(null), [Ee, Pe] = l(!1), [Be, We] = l(!1), [Le, Me] = l(!1), [Ae, He] = l(!1), [$e, Oe] = l(!1), [Ne, Ge] = l(!1), [Xe, je] = l(!1), [Fe, Ve] = l(!1), [qe, Ue] = l(!1), [bt, Je] = l(!1), [wt, Ye] = l(!1);
|
|
300
300
|
j(() => {
|
|
301
301
|
const e = () => {
|
|
302
302
|
const n = h(), t = w(), r = n < 768 || n === 926 && t === 428 || n === 932 && t === 430, o = t < 700, p = n / t > 1.8, g = n === 768 && t === 1024, i = n === 1024 && t === 768, d = n === 820 && t === 1180, R = n === 1180 && t === 820, C = n === 540 && t === 720, ne = n === 720 && t === 540, ve = n === 1024 && t === 1366, ke = n === 1366 && t === 1024, Ie = n >= 1200 && t >= 600 && !r;
|
|
303
|
-
Pe(Ie),
|
|
303
|
+
Pe(Ie), We(g), Me(i), He(d), Oe(R), Ge(C), je(ne), Ve(ve), Ue(ke), Ye(p);
|
|
304
304
|
const ct = r && n > t || r || // ✅ ВСЕ мобильные устройства (включая portrait)
|
|
305
305
|
t < 700 || p || // ✅ Широкие экраны
|
|
306
306
|
n === 1366 && t === 766 || n === 1366 && t === 768 || n === 1280 && t === 720 || n === 1440 && t === 900 || g || i || d || R || C || ne || ve || ke || Ie;
|
|
@@ -383,19 +383,19 @@ function kt(f = {}) {
|
|
|
383
383
|
}));
|
|
384
384
|
me(r), ie([]), fe(e), ye.current = e, ge(pe || 20), P(null), _(!1), se(!1), z("play");
|
|
385
385
|
};
|
|
386
|
-
j(() => (S === "play" && !a && (q.current !== null && window.clearTimeout(q.current),
|
|
386
|
+
j(() => (S === "play" && !a && (q.current !== null && window.clearTimeout(q.current), M > 0 ? q.current = window.setTimeout(() => ge((e) => e - 1), 1e3) : _(!0)), () => {
|
|
387
387
|
q.current !== null && window.clearTimeout(q.current);
|
|
388
|
-
}), [S,
|
|
389
|
-
if (S === "play" && a &&
|
|
388
|
+
}), [S, M, a]), j(() => {
|
|
389
|
+
if (S === "play" && a && M === 0) {
|
|
390
390
|
const e = T[D];
|
|
391
391
|
if (!e) {
|
|
392
392
|
P(null);
|
|
393
393
|
return;
|
|
394
394
|
}
|
|
395
395
|
const n = e.trim().split(/\s+/), t = I.map((i) => i.text), r = n.filter((i) => !t.includes(i)).length, o = t.filter((i) => !n.includes(i)).length, p = n.filter((i, d) => t.includes(i) ? t[d] !== i : !1).length, g = r + o + p;
|
|
396
|
-
g === 0 ? (P("correct"), xe || (se(!0), G((i) => i + 1)),
|
|
396
|
+
g === 0 ? (P("correct"), xe || (se(!0), G((i) => i + 1)), W("correct"), A("Correct! Well done!")) : g === 1 ? (P("almost"), G((i) => i + 0.5), W("half"), A("Almost correct! Just one mistake.")) : (P("wrong"), W("wrong"), A("Not quite right. Keep trying!"));
|
|
397
397
|
}
|
|
398
|
-
}, [S, a,
|
|
398
|
+
}, [S, a, M, T, D, I, xe]);
|
|
399
399
|
const tt = (e = !0) => {
|
|
400
400
|
if (e) {
|
|
401
401
|
if (a) {
|
|
@@ -408,7 +408,7 @@ function kt(f = {}) {
|
|
|
408
408
|
return;
|
|
409
409
|
}
|
|
410
410
|
const t = n.trim().split(/\s+/), r = I.map((d) => d.text), o = t.filter((d) => !r.includes(d)).length, p = r.filter((d) => !t.includes(d)).length, g = t.filter((d, R) => r.includes(d) ? r[R] !== d : !1).length, i = o + p + g;
|
|
411
|
-
i === 0 ? (G((d) => d + 1), P("correct"), se(!0),
|
|
411
|
+
i === 0 ? (G((d) => d + 1), P("correct"), se(!0), W("correct"), A("Correct! Well done!")) : i === 1 ? (G((d) => d + 0.5), P("almost"), W("half"), A("Almost correct! Just one mistake.")) : (P("wrong"), W("wrong"), A("Not quite right. Keep trying!")), D + 1 < (E || 0) ? setTimeout(() => ee(D + 1), 800) : setTimeout(() => {
|
|
412
412
|
z("results"), setTimeout(() => te(), 600);
|
|
413
413
|
}, 800);
|
|
414
414
|
}
|
|
@@ -416,7 +416,7 @@ function kt(f = {}) {
|
|
|
416
416
|
j(() => {
|
|
417
417
|
S === "results" && V > ae && (Te(V), localStorage.setItem("magicSentenceBest", String(V)));
|
|
418
418
|
}, [S, V, ae]);
|
|
419
|
-
const
|
|
419
|
+
const W = (e) => {
|
|
420
420
|
const n = new (window.AudioContext || window.webkitAudioContext)(), t = n.createOscillator(), r = n.createGain();
|
|
421
421
|
switch (t.connect(r), r.connect(n.destination), e) {
|
|
422
422
|
case "start":
|
|
@@ -564,7 +564,7 @@ function kt(f = {}) {
|
|
|
564
564
|
"/",
|
|
565
565
|
E,
|
|
566
566
|
" — ",
|
|
567
|
-
a ? "TIME'S UP!" : `Time: ${
|
|
567
|
+
a ? "TIME'S UP!" : `Time: ${M}s`
|
|
568
568
|
] }),
|
|
569
569
|
/* @__PURE__ */ c(
|
|
570
570
|
"div",
|
|
@@ -582,8 +582,8 @@ function kt(f = {}) {
|
|
|
582
582
|
{
|
|
583
583
|
style: {
|
|
584
584
|
height: "100%",
|
|
585
|
-
width: `${
|
|
586
|
-
background:
|
|
585
|
+
width: `${M / (pe || 20) * 100}%`,
|
|
586
|
+
background: M <= 5 ? "#ec4c44" : "#4caf50",
|
|
587
587
|
transition: "width 1s linear"
|
|
588
588
|
}
|
|
589
589
|
}
|
|
@@ -779,7 +779,7 @@ function kt(f = {}) {
|
|
|
779
779
|
}
|
|
780
780
|
)
|
|
781
781
|
] }), at = () => {
|
|
782
|
-
const e = h(), n = w(), t = m && e > n || e === 896 && n === 414 || e === 844 && n === 390 || e === 926 && n === 428 || e === 932 && n === 430 || Be ||
|
|
782
|
+
const e = h(), n = w(), t = m && e > n || e === 896 && n === 414 || e === 844 && n === 390 || e === 926 && n === 428 || e === 932 && n === 430 || Be || Le || Ae || $e || Ne || Xe || Fe || qe, r = m && e <= 375 && n <= 667 || e === 896 && n === 414 || e === 844 && n === 390 || e === 926 && n === 428 || e === 932 && n === 430, o = e === 1366 && n === 766 || e === 1366 && n === 768 || e === 1280 && n === 720 || e === 1440 && n === 900;
|
|
783
783
|
return /* @__PURE__ */ b("div", { style: u.gmCenterScreen, children: [
|
|
784
784
|
/* @__PURE__ */ c("h1", { style: {
|
|
785
785
|
...u.gmHeadline1,
|
|
@@ -817,7 +817,7 @@ function kt(f = {}) {
|
|
|
817
817
|
"button",
|
|
818
818
|
{
|
|
819
819
|
onClick: () => {
|
|
820
|
-
te(),
|
|
820
|
+
te(), W("start"), setTimeout(() => {
|
|
821
821
|
z("getready"), he(null), _(!1);
|
|
822
822
|
}, 800);
|
|
823
823
|
},
|
|
@@ -832,7 +832,7 @@ function kt(f = {}) {
|
|
|
832
832
|
"button",
|
|
833
833
|
{
|
|
834
834
|
onClick: () => {
|
|
835
|
-
|
|
835
|
+
W("click"), z("select"), de(null), ue(null), Z([]), G(0), ie([]), _(!1);
|
|
836
836
|
},
|
|
837
837
|
style: {
|
|
838
838
|
...u.gmButton,
|
|
@@ -845,14 +845,14 @@ function kt(f = {}) {
|
|
|
845
845
|
] });
|
|
846
846
|
}, Se = !m && v, lt = dt(
|
|
847
847
|
() => {
|
|
848
|
-
const e = h(), n = w();
|
|
849
|
-
if (m && e > n || n < 700 || !Se)
|
|
848
|
+
const e = h(), n = w(), t = e >= 1200 && e <= 1400;
|
|
849
|
+
if (m && e > n || n < 700 && !t || !Se)
|
|
850
850
|
return null;
|
|
851
|
-
const
|
|
851
|
+
const r = s || (typeof window < "u" && window.origin ? `${window.origin}/cloud/speakid/games/magic%20sentence/logo` : "/cloud/speakid/games/magic%20sentence/logo");
|
|
852
852
|
return /* @__PURE__ */ c("div", { style: u.gmLogoFixed, children: /* @__PURE__ */ c(
|
|
853
853
|
"img",
|
|
854
854
|
{
|
|
855
|
-
src: `${
|
|
855
|
+
src: `${r}.svg`,
|
|
856
856
|
alt: "SPEAKID Logo",
|
|
857
857
|
style: u.gmLogoImg,
|
|
858
858
|
loading: "lazy"
|
|
@@ -864,7 +864,7 @@ function kt(f = {}) {
|
|
|
864
864
|
return /* @__PURE__ */ c(
|
|
865
865
|
"div",
|
|
866
866
|
{
|
|
867
|
-
ref:
|
|
867
|
+
ref: L,
|
|
868
868
|
style: {
|
|
869
869
|
width: "100%",
|
|
870
870
|
height: "100%",
|