@puzzmo/sdk 1.0.55 → 1.0.57
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 +28 -1
- package/dist/{createSimulator-CoVR6n2p.js → createSimulator-5inYnxKU.js} +228 -197
- package/dist/createSimulator-5inYnxKU.js.map +1 -0
- package/dist/{createSimulator-CiUXlL22.cjs → createSimulator-BCzgWYMQ.cjs} +24 -24
- package/dist/createSimulator-BCzgWYMQ.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.global.js +1 -1
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +17 -2
- package/dist/index.js.map +1 -1
- package/dist/keyboard.d.ts +12 -1
- package/dist/keyboard.d.ts.map +1 -1
- package/dist/keyboard.spec.d.ts +2 -0
- package/dist/keyboard.spec.d.ts.map +1 -0
- package/dist/sdk.d.ts +29 -2
- package/dist/sdk.d.ts.map +1 -1
- package/dist/simulator/dockedKeyboard.d.ts +2 -0
- package/dist/simulator/dockedKeyboard.d.ts.map +1 -1
- package/dist/simulator/index.cjs +1 -1
- package/dist/simulator/index.js +1 -1
- package/dist/simulator/standalone.cjs +1 -1
- package/dist/simulator/standalone.js +1 -1
- package/dist/simulator/views/KeyboardView.d.ts.map +1 -1
- package/dist/simulator/views/SoundView.d.ts.map +1 -1
- package/dist/types.d.ts +58 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/createSimulator-CiUXlL22.cjs.map +0 -1
- package/dist/createSimulator-CoVR6n2p.js.map +0 -1
|
@@ -420,7 +420,7 @@ function x() {
|
|
|
420
420
|
"timeline"
|
|
421
421
|
].includes(e)) return e;
|
|
422
422
|
}
|
|
423
|
-
function
|
|
423
|
+
function S(e, t, n) {
|
|
424
424
|
var i, a, s;
|
|
425
425
|
let c = localStorage.getItem(r.fixtureCategory), l = localStorage.getItem(r.fixturePuzzle), d = u(), f = o("puzzle"), m = o("input");
|
|
426
426
|
return {
|
|
@@ -451,16 +451,16 @@ function ee(e, t, n) {
|
|
|
451
451
|
settingsComponents: null
|
|
452
452
|
};
|
|
453
453
|
}
|
|
454
|
-
function
|
|
454
|
+
function C(e) {
|
|
455
455
|
localStorage.setItem(r.gameSettings, JSON.stringify(e));
|
|
456
456
|
}
|
|
457
|
-
function
|
|
457
|
+
function w() {
|
|
458
458
|
localStorage.removeItem(r.gameSettings);
|
|
459
459
|
}
|
|
460
|
-
function
|
|
460
|
+
function ee(e) {
|
|
461
461
|
localStorage.setItem(r.collapsed, String(e));
|
|
462
462
|
}
|
|
463
|
-
function
|
|
463
|
+
function te(e) {
|
|
464
464
|
localStorage.setItem(r.tab, e);
|
|
465
465
|
}
|
|
466
466
|
function T(e) {
|
|
@@ -681,7 +681,7 @@ function R() {
|
|
|
681
681
|
return null;
|
|
682
682
|
}
|
|
683
683
|
/** Generate a small thumbnail SVG for a given input string */
|
|
684
|
-
function
|
|
684
|
+
function z(e, t) {
|
|
685
685
|
let n = R();
|
|
686
686
|
if (!n) return "";
|
|
687
687
|
try {
|
|
@@ -697,14 +697,14 @@ function ce(e, t) {
|
|
|
697
697
|
return "";
|
|
698
698
|
}
|
|
699
699
|
}
|
|
700
|
-
var
|
|
701
|
-
function
|
|
700
|
+
var B = [];
|
|
701
|
+
function V(e, t = 8) {
|
|
702
702
|
let n = 14 * t + 8 + 4;
|
|
703
703
|
e.style.height = "auto";
|
|
704
704
|
let r = Math.min(Math.max(e.scrollHeight, 40), n);
|
|
705
705
|
e.style.height = `${r}px`;
|
|
706
706
|
}
|
|
707
|
-
function
|
|
707
|
+
function ce() {
|
|
708
708
|
let e = "", t = "";
|
|
709
709
|
return {
|
|
710
710
|
id: "data",
|
|
@@ -727,13 +727,13 @@ function le() {
|
|
|
727
727
|
});
|
|
728
728
|
let i = n.getElement("#simulator-puzzle"), a = n.getElement("#simulator-input"), o = n.getElement("#simulator-puzzle-reset"), l = n.getElement("#simulator-puzzle-apply"), u = n.getElement("#simulator-input-reset"), d = n.getElement("#simulator-input-apply");
|
|
729
729
|
setTimeout(() => {
|
|
730
|
-
i && n.state.originalPuzzle && document.activeElement !== i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle,
|
|
730
|
+
i && n.state.originalPuzzle && document.activeElement !== i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle, V(i)), a && n.state.currentInputStr && document.activeElement !== a && (a.value = n.state.currentInputStr, t = n.state.currentInputStr, V(a)), fe(n);
|
|
731
731
|
}, 0), i == null || i.addEventListener("input", () => {
|
|
732
|
-
|
|
732
|
+
V(i);
|
|
733
733
|
let t = i.value !== e;
|
|
734
734
|
l && (l.disabled = !t);
|
|
735
735
|
}), a == null || a.addEventListener("input", () => {
|
|
736
|
-
|
|
736
|
+
V(a);
|
|
737
737
|
let e = a.value !== t;
|
|
738
738
|
d && (d.disabled = !e);
|
|
739
739
|
}), o == null || o.addEventListener("click", () => {
|
|
@@ -741,7 +741,7 @@ function le() {
|
|
|
741
741
|
c("puzzle"), n.updateStatus("Restoring fixture puzzle...", "waiting"), window.location.reload();
|
|
742
742
|
return;
|
|
743
743
|
}
|
|
744
|
-
i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle,
|
|
744
|
+
i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle, V(i), l && (l.disabled = !0));
|
|
745
745
|
}), l == null || l.addEventListener("click", () => {
|
|
746
746
|
if (i) {
|
|
747
747
|
if (!s("puzzle", i.value)) {
|
|
@@ -755,7 +755,7 @@ function le() {
|
|
|
755
755
|
c("input"), n.updateStatus("Clearing input...", "waiting"), window.location.reload();
|
|
756
756
|
return;
|
|
757
757
|
}
|
|
758
|
-
a && (a.value = t,
|
|
758
|
+
a && (a.value = t, V(a), d && (d.disabled = !0));
|
|
759
759
|
}), d == null || d.addEventListener("click", () => {
|
|
760
760
|
if (a) {
|
|
761
761
|
if (!s("input", a.value)) {
|
|
@@ -767,12 +767,12 @@ function le() {
|
|
|
767
767
|
});
|
|
768
768
|
let f = n.getElement("#simulator-history-clear");
|
|
769
769
|
f == null || f.addEventListener("click", () => {
|
|
770
|
-
|
|
770
|
+
B = [], H(n);
|
|
771
771
|
});
|
|
772
772
|
let p = n.getElement("#simulator-save-name"), m = n.getElement("#simulator-save-btn");
|
|
773
773
|
m == null || m.addEventListener("click", () => {
|
|
774
774
|
if (!p || !p.value.trim()) return;
|
|
775
|
-
let e =
|
|
775
|
+
let e = le(), t = {
|
|
776
776
|
name: p.value.trim(),
|
|
777
777
|
puzzleStr: n.state.originalPuzzle,
|
|
778
778
|
inputStr: n.state.currentInputStr,
|
|
@@ -788,20 +788,20 @@ function le() {
|
|
|
788
788
|
var i, a;
|
|
789
789
|
let o = r.getElement("#simulator-input"), s = r.getElement("#simulator-input-apply"), c = (i = n == null || (a = n.input) == null ? void 0 : a.boardState) == null ? n == null ? void 0 : n.boardState : i;
|
|
790
790
|
if (e === "UPLOAD_NEW_GAME_STATE" && c) {
|
|
791
|
-
if (r.state.currentInputStr = c,
|
|
792
|
-
|
|
791
|
+
if (r.state.currentInputStr = c, B.length === 0 || B[B.length - 1].value !== c) {
|
|
792
|
+
B.push({
|
|
793
793
|
value: c,
|
|
794
794
|
timestamp: Date.now()
|
|
795
|
-
}),
|
|
795
|
+
}), B.length > 100 && (B = B.slice(-100));
|
|
796
796
|
let e = r.getElement("#data-subtab-history");
|
|
797
797
|
e != null && e.classList.contains("active") && H(r);
|
|
798
798
|
}
|
|
799
|
-
o && document.activeElement !== o && (o.value !== c && (o.value = c,
|
|
799
|
+
o && document.activeElement !== o && (o.value !== c && (o.value = c, V(o)), t = c, s && (s.disabled = !0));
|
|
800
800
|
}
|
|
801
801
|
}
|
|
802
802
|
};
|
|
803
803
|
}
|
|
804
|
-
function
|
|
804
|
+
function le() {
|
|
805
805
|
try {
|
|
806
806
|
let e = localStorage.getItem(L);
|
|
807
807
|
return e ? JSON.parse(e) : [];
|
|
@@ -812,15 +812,15 @@ function V() {
|
|
|
812
812
|
function H(e) {
|
|
813
813
|
let t = e.getElement("#simulator-history-list");
|
|
814
814
|
if (t) {
|
|
815
|
-
if (t.style.setProperty("--history-thumb-bg", e.state.selectedTheme.a_bg),
|
|
815
|
+
if (t.style.setProperty("--history-thumb-bg", e.state.selectedTheme.a_bg), B.length === 0) {
|
|
816
816
|
t.innerHTML = "<div class=\"simulator-empty\">No history yet</div>";
|
|
817
817
|
return;
|
|
818
818
|
}
|
|
819
|
-
t.innerHTML = [...
|
|
820
|
-
let r =
|
|
819
|
+
t.innerHTML = [...B].reverse().map((t, n) => {
|
|
820
|
+
let r = B.length - 1 - n, i = new Date(t.timestamp).toLocaleTimeString(), a = t.value.length > 60 ? t.value.slice(0, 60) + "..." : t.value;
|
|
821
821
|
return `
|
|
822
822
|
<div class="history-item" data-history-idx="${r}">
|
|
823
|
-
<div class="history-item-thumb">${
|
|
823
|
+
<div class="history-item-thumb">${z(e, t.value)}</div>
|
|
824
824
|
<div class="history-item-content">
|
|
825
825
|
<div class="history-item-header">
|
|
826
826
|
<span class="history-item-num">#${r + 1}</span>
|
|
@@ -833,12 +833,12 @@ function H(e) {
|
|
|
833
833
|
`;
|
|
834
834
|
}).join(""), t.querySelectorAll(".history-restore-btn").forEach((t) => {
|
|
835
835
|
t.addEventListener("click", (t) => {
|
|
836
|
-
let n = parseInt(t.target.getAttribute("data-history-idx") || "0"), r =
|
|
836
|
+
let n = parseInt(t.target.getAttribute("data-history-idx") || "0"), r = B[n];
|
|
837
837
|
if (r) {
|
|
838
838
|
let t = e.getElement(".data-subtab[data-subtab=\"edit\"]");
|
|
839
839
|
t == null || t.click();
|
|
840
840
|
let n = e.getElement("#simulator-input"), i = e.getElement("#simulator-input-apply");
|
|
841
|
-
n && (n.value = r.value,
|
|
841
|
+
n && (n.value = r.value, V(n)), i && (i.disabled = !1), e.updateStatus("Input restored — press Apply to load it", "ready");
|
|
842
842
|
}
|
|
843
843
|
});
|
|
844
844
|
});
|
|
@@ -847,7 +847,7 @@ function H(e) {
|
|
|
847
847
|
function U(e) {
|
|
848
848
|
let t = e.getElement("#simulator-saves-list");
|
|
849
849
|
if (!t) return;
|
|
850
|
-
let n =
|
|
850
|
+
let n = le();
|
|
851
851
|
if (n.length === 0) {
|
|
852
852
|
t.innerHTML = "<div class=\"simulator-empty\">No saved states</div>";
|
|
853
853
|
return;
|
|
@@ -889,7 +889,7 @@ function ue(e) {
|
|
|
889
889
|
}
|
|
890
890
|
function de(e) {
|
|
891
891
|
let t = e.getElement("#simulator-puzzle"), n = e.getElement("#simulator-input"), r = e.getElement("#simulator-puzzle-apply"), i = e.getElement("#simulator-input-apply");
|
|
892
|
-
t && e.state.originalPuzzle && (t.value = e.state.originalPuzzle,
|
|
892
|
+
t && e.state.originalPuzzle && (t.value = e.state.originalPuzzle, V(t), r && (r.disabled = !0)), n && (n.value = e.state.currentInputStr, V(n), i && (i.disabled = !0)), fe(e);
|
|
893
893
|
}
|
|
894
894
|
function fe(e) {
|
|
895
895
|
let t = e.getElement("#simulator-puzzle-override-tag"), n = e.getElement("#simulator-input-override-tag");
|
|
@@ -1287,17 +1287,17 @@ var ke = "puzzmo_sim_api_mode", W = "http://localhost:8911", Ae = "https://api.p
|
|
|
1287
1287
|
}), Ne = () => {
|
|
1288
1288
|
let e = new Uint8Array(32);
|
|
1289
1289
|
return crypto.getRandomValues(e), Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
1290
|
-
},
|
|
1291
|
-
let e = localStorage.getItem(
|
|
1290
|
+
}, Pe = "puzzmo_sim_oauth_token", Fe = "puzzmo_sim_oauth_refresh_token", Ie = (e) => localStorage.setItem(Pe, e), Le = (e) => localStorage.setItem(Fe, e), Re = () => {
|
|
1291
|
+
let e = localStorage.getItem(Pe);
|
|
1292
1292
|
return e && `${e.substring(0, 20)}`, e;
|
|
1293
|
-
},
|
|
1294
|
-
localStorage.removeItem(
|
|
1295
|
-
},
|
|
1293
|
+
}, ze = () => localStorage.getItem(Fe), Be = () => {
|
|
1294
|
+
localStorage.removeItem(Pe), localStorage.removeItem(Fe);
|
|
1295
|
+
}, Ve = () => {
|
|
1296
1296
|
let e = q(), t = Ne();
|
|
1297
1297
|
sessionStorage.setItem("oauth_state", t), sessionStorage.setItem("oauth_return_url", window.location.href);
|
|
1298
1298
|
let n = new URL(`${e.apiURL}/oauth/auth`);
|
|
1299
1299
|
n.searchParams.set("client_id", e.clientID), n.searchParams.set("response_type", "code"), n.searchParams.set("redirect_uri", e.redirectUri), n.searchParams.set("state", t), window.location.href = n.toString();
|
|
1300
|
-
},
|
|
1300
|
+
}, He = (e) => {
|
|
1301
1301
|
try {
|
|
1302
1302
|
let t = e.split(".");
|
|
1303
1303
|
if (t.length !== 3) return !0;
|
|
@@ -1306,9 +1306,9 @@ var ke = "puzzmo_sim_api_mode", W = "http://localhost:8911", Ae = "https://api.p
|
|
|
1306
1306
|
} catch (e) {
|
|
1307
1307
|
return !0;
|
|
1308
1308
|
}
|
|
1309
|
-
},
|
|
1309
|
+
}, Ue = function() {
|
|
1310
1310
|
var e = t(function* () {
|
|
1311
|
-
let e =
|
|
1311
|
+
let e = ze();
|
|
1312
1312
|
if (!e) return !1;
|
|
1313
1313
|
let t = q();
|
|
1314
1314
|
try {
|
|
@@ -1324,9 +1324,9 @@ var ke = "puzzmo_sim_api_mode", W = "http://localhost:8911", Ae = "https://api.p
|
|
|
1324
1324
|
if (!r.ok) return r.statusText, !1;
|
|
1325
1325
|
let i = yield r.json(), a = i.access_token || i.accessToken;
|
|
1326
1326
|
if (!a) return !1;
|
|
1327
|
-
|
|
1327
|
+
Ie(a);
|
|
1328
1328
|
let o = i.refresh_token || i.refreshToken;
|
|
1329
|
-
return o &&
|
|
1329
|
+
return o && Le(o), !0;
|
|
1330
1330
|
} catch (e) {
|
|
1331
1331
|
return !1;
|
|
1332
1332
|
}
|
|
@@ -1334,7 +1334,7 @@ var ke = "puzzmo_sim_api_mode", W = "http://localhost:8911", Ae = "https://api.p
|
|
|
1334
1334
|
return function() {
|
|
1335
1335
|
return e.apply(this, arguments);
|
|
1336
1336
|
};
|
|
1337
|
-
}(),
|
|
1337
|
+
}(), We = function() {
|
|
1338
1338
|
var e = t(function* (e, t) {
|
|
1339
1339
|
let n = q(), r = sessionStorage.getItem("oauth_state");
|
|
1340
1340
|
if (!r || r !== t) return null;
|
|
@@ -1358,13 +1358,13 @@ var ke = "puzzmo_sim_api_mode", W = "http://localhost:8911", Ae = "https://api.p
|
|
|
1358
1358
|
return function(t, n) {
|
|
1359
1359
|
return e.apply(this, arguments);
|
|
1360
1360
|
};
|
|
1361
|
-
}(),
|
|
1361
|
+
}(), Ge = function() {
|
|
1362
1362
|
var e = t(function* (e, t = {}) {
|
|
1363
|
-
let n = q(), r =
|
|
1363
|
+
let n = q(), r = Re();
|
|
1364
1364
|
if (!r) throw Error("Not authenticated");
|
|
1365
|
-
if (
|
|
1366
|
-
if (r =
|
|
1367
|
-
} else throw
|
|
1365
|
+
if (He(r)) if (yield Ue()) {
|
|
1366
|
+
if (r = Re(), !r) throw Error("Token refresh succeeded but no token available");
|
|
1367
|
+
} else throw Be(), Error("Session expired. Please log in again.");
|
|
1368
1368
|
let i = yield fetch(`${n.apiURL}/graphql`, {
|
|
1369
1369
|
method: "POST",
|
|
1370
1370
|
headers: {
|
|
@@ -1383,7 +1383,7 @@ var ke = "puzzmo_sim_api_mode", W = "http://localhost:8911", Ae = "https://api.p
|
|
|
1383
1383
|
return function(t) {
|
|
1384
1384
|
return e.apply(this, arguments);
|
|
1385
1385
|
};
|
|
1386
|
-
}(),
|
|
1386
|
+
}(), Ke = (e) => {
|
|
1387
1387
|
try {
|
|
1388
1388
|
let t = e.split(".");
|
|
1389
1389
|
return t.length, t.length === 3 ? JSON.parse(atob(t[1])) : null;
|
|
@@ -1391,15 +1391,15 @@ var ke = "puzzmo_sim_api_mode", W = "http://localhost:8911", Ae = "https://api.p
|
|
|
1391
1391
|
return null;
|
|
1392
1392
|
}
|
|
1393
1393
|
};
|
|
1394
|
-
function
|
|
1394
|
+
function qe() {
|
|
1395
1395
|
let e = !1;
|
|
1396
1396
|
return {
|
|
1397
1397
|
id: "auth",
|
|
1398
1398
|
label: "Auth",
|
|
1399
1399
|
render() {
|
|
1400
|
-
let e =
|
|
1400
|
+
let e = Re(), t = !!e, n = G(), r = n === "dev" ? W : Ae, i = `<button class="simulator-btn tiny" id="auth-dev-toggle" style="display: none;">${n === "dev" ? "Using Dev" : "Dev"}</button>`;
|
|
1401
1401
|
if (t) {
|
|
1402
|
-
let t =
|
|
1402
|
+
let t = Ke(e), n = t != null && t.exp ? (/* @__PURE__ */ new Date(t.exp * 1e3)).toLocaleString() : "Unknown", a = !!ze(), o = a ? Ke(ze()) : null, s = o != null && o.exp ? (/* @__PURE__ */ new Date(o.exp * 1e3)).toLocaleString() : null;
|
|
1403
1403
|
return `
|
|
1404
1404
|
<div class="simulator-section">
|
|
1405
1405
|
<div class="simulator-section-title auth-title-row">
|
|
@@ -1454,18 +1454,18 @@ function Ke() {
|
|
|
1454
1454
|
e ? K && c && (c.style.display = "", G() === "dev" && c.classList.add("active")) : (e = !0, Me().then((e) => {
|
|
1455
1455
|
e && c && (c.style.display = "", G() === "dev" && c.classList.add("active"));
|
|
1456
1456
|
})), c == null || c.addEventListener("click", () => {
|
|
1457
|
-
je(G() === "dev" ? "prod" : "dev"),
|
|
1457
|
+
je(G() === "dev" ? "prod" : "dev"), Be(), window.location.reload();
|
|
1458
1458
|
}), r == null || r.addEventListener("click", () => {
|
|
1459
|
-
|
|
1459
|
+
Ve();
|
|
1460
1460
|
}), i == null || i.addEventListener("click", () => {
|
|
1461
|
-
|
|
1461
|
+
Be(), window.location.reload();
|
|
1462
1462
|
}), a == null || a.addEventListener("click", t(function* () {
|
|
1463
|
-
a.disabled = !0, a.textContent = "Refreshing...", (yield
|
|
1463
|
+
a.disabled = !0, a.textContent = "Refreshing...", (yield Ue()) ? window.location.reload() : (a.textContent = "Refresh Failed", a.disabled = !1);
|
|
1464
1464
|
})), o == null || o.addEventListener("click", t(function* () {
|
|
1465
1465
|
if (s) {
|
|
1466
1466
|
s.innerHTML = "<div class=\"loading\">Loading...</div>";
|
|
1467
1467
|
try {
|
|
1468
|
-
let t = yield
|
|
1468
|
+
let t = yield Ge("\n query {\n currentUser {\n id\n username\n usernameID\n name\n }\n }\n ");
|
|
1469
1469
|
if (t.errors) {
|
|
1470
1470
|
var e;
|
|
1471
1471
|
s.innerHTML = `<div class="error">Error: ${((e = t.errors[0]) == null ? void 0 : e.message) || "Unknown error"}</div>`;
|
|
@@ -1487,13 +1487,13 @@ function Ke() {
|
|
|
1487
1487
|
if (n && r) {
|
|
1488
1488
|
let t = e.getElement("#auth-status");
|
|
1489
1489
|
t && (t.innerHTML = "<span class=\"indicator waiting\"></span><span>Exchanging code...</span>");
|
|
1490
|
-
let i = yield
|
|
1490
|
+
let i = yield We(n, r);
|
|
1491
1491
|
if (window.history.replaceState({}, "", window.location.pathname), i) {
|
|
1492
1492
|
let e = i.access_token || i.accessToken;
|
|
1493
1493
|
if (e) {
|
|
1494
|
-
|
|
1494
|
+
Ie(e);
|
|
1495
1495
|
let t = i.refresh_token || i.refreshToken;
|
|
1496
|
-
t &&
|
|
1496
|
+
t && Le(t);
|
|
1497
1497
|
}
|
|
1498
1498
|
window.location.reload();
|
|
1499
1499
|
} else {
|
|
@@ -1505,9 +1505,9 @@ function Ke() {
|
|
|
1505
1505
|
}
|
|
1506
1506
|
};
|
|
1507
1507
|
}
|
|
1508
|
-
var
|
|
1509
|
-
localStorage.removeItem(
|
|
1510
|
-
},
|
|
1508
|
+
var Je = "puzzmo_sim_api_mode", Ye = "http://localhost:8911", Xe = "https://api.puzzmo.com", Ze = "puzzmo_sim_oauth_token", Qe = "puzzmo_sim_oauth_refresh_token", $e = () => localStorage.getItem(Je) === "dev" ? "dev" : "prod", et = () => localStorage.getItem(Ze), tt = () => localStorage.getItem(Qe), nt = (e) => localStorage.setItem(Ze, e), rt = (e) => localStorage.setItem(Qe, e), it = () => {
|
|
1509
|
+
localStorage.removeItem(Ze), localStorage.removeItem(Qe);
|
|
1510
|
+
}, at = (e) => {
|
|
1511
1511
|
try {
|
|
1512
1512
|
let t = e.split(".");
|
|
1513
1513
|
if (t.length !== 3) return !0;
|
|
@@ -1516,11 +1516,11 @@ var qe = "puzzmo_sim_api_mode", Je = "http://localhost:8911", Ye = "https://api.
|
|
|
1516
1516
|
} catch (e) {
|
|
1517
1517
|
return !0;
|
|
1518
1518
|
}
|
|
1519
|
-
},
|
|
1519
|
+
}, ot = function() {
|
|
1520
1520
|
var e = t(function* () {
|
|
1521
|
-
let e =
|
|
1521
|
+
let e = tt();
|
|
1522
1522
|
if (!e) return !1;
|
|
1523
|
-
let t =
|
|
1523
|
+
let t = $e() === "dev" ? Ye : Xe;
|
|
1524
1524
|
try {
|
|
1525
1525
|
let n = new URLSearchParams({
|
|
1526
1526
|
grant_type: "refresh_token",
|
|
@@ -1534,9 +1534,9 @@ var qe = "puzzmo_sim_api_mode", Je = "http://localhost:8911", Ye = "https://api.
|
|
|
1534
1534
|
if (!r.ok) return !1;
|
|
1535
1535
|
let i = yield r.json(), a = i.access_token || i.accessToken;
|
|
1536
1536
|
if (!a) return !1;
|
|
1537
|
-
|
|
1537
|
+
nt(a);
|
|
1538
1538
|
let o = i.refresh_token || i.refreshToken;
|
|
1539
|
-
return o &&
|
|
1539
|
+
return o && rt(o), !0;
|
|
1540
1540
|
} catch (e) {
|
|
1541
1541
|
return !1;
|
|
1542
1542
|
}
|
|
@@ -1544,13 +1544,13 @@ var qe = "puzzmo_sim_api_mode", Je = "http://localhost:8911", Ye = "https://api.
|
|
|
1544
1544
|
return function() {
|
|
1545
1545
|
return e.apply(this, arguments);
|
|
1546
1546
|
};
|
|
1547
|
-
}(),
|
|
1547
|
+
}(), st = function() {
|
|
1548
1548
|
var e = t(function* (e, t = {}) {
|
|
1549
|
-
let n =
|
|
1549
|
+
let n = $e() === "dev" ? Ye : Xe, r = et();
|
|
1550
1550
|
if (!r) throw Error("Not authenticated");
|
|
1551
|
-
if (
|
|
1552
|
-
if (r =
|
|
1553
|
-
} else throw
|
|
1551
|
+
if (at(r)) if (yield ot()) {
|
|
1552
|
+
if (r = et(), !r) throw Error("Token refresh succeeded but no token available");
|
|
1553
|
+
} else throw it(), Error("Session expired. Please log in again.");
|
|
1554
1554
|
let i = yield fetch(`${n}/graphql`, {
|
|
1555
1555
|
method: "POST",
|
|
1556
1556
|
headers: {
|
|
@@ -1569,19 +1569,19 @@ var qe = "puzzmo_sim_api_mode", Je = "http://localhost:8911", Ye = "https://api.
|
|
|
1569
1569
|
return function(t) {
|
|
1570
1570
|
return e.apply(this, arguments);
|
|
1571
1571
|
};
|
|
1572
|
-
}(),
|
|
1572
|
+
}(), ct = "\n query GameFeaturesQuery($slug: ID!) {\n game(id: $slug) {\n id\n slug\n displayName\n featuresArr\n gameFeatures {\n slug\n title\n features {\n featureID\n title\n isEnabled\n }\n }\n }\n }\n", lt = "\n mutation ToggleFeatureMutation($gameSlug: ID!, $input: UpdateGameInput!) {\n updateGame(id: $gameSlug, input: $input) {\n id\n featuresArr\n gameFeatures {\n slug\n title\n features {\n featureID\n title\n isEnabled\n }\n }\n }\n }\n", ut = (e, t) => {
|
|
1573
1573
|
let n = t - 1, r = Math.floor(n / 31), i = n % 31, a = [...e];
|
|
1574
1574
|
for (; a.length <= r;) a.push(0);
|
|
1575
1575
|
return a[r] = a[r] ^ 1 << i, a;
|
|
1576
1576
|
};
|
|
1577
|
-
const
|
|
1578
|
-
function
|
|
1577
|
+
const dt = () => !!et();
|
|
1578
|
+
function ft() {
|
|
1579
1579
|
let n = null, r = !1, i = null, a = function() {
|
|
1580
1580
|
var e = t(function* (e) {
|
|
1581
1581
|
r = !0, i = null;
|
|
1582
1582
|
try {
|
|
1583
1583
|
var t;
|
|
1584
|
-
let r = yield
|
|
1584
|
+
let r = yield st(ct, { slug: e });
|
|
1585
1585
|
if (r.errors) {
|
|
1586
1586
|
var a;
|
|
1587
1587
|
i = ((a = r.errors[0]) == null ? void 0 : a.message) || "Unknown error", n = null;
|
|
@@ -1598,10 +1598,10 @@ function dt() {
|
|
|
1598
1598
|
}(), o = function() {
|
|
1599
1599
|
var r = t(function* (t) {
|
|
1600
1600
|
if (!n) return;
|
|
1601
|
-
let r =
|
|
1601
|
+
let r = ut(n.featuresArr, t);
|
|
1602
1602
|
try {
|
|
1603
1603
|
var i;
|
|
1604
|
-
let t = yield
|
|
1604
|
+
let t = yield st(lt, {
|
|
1605
1605
|
gameSlug: n.slug,
|
|
1606
1606
|
input: { featuresArr: r }
|
|
1607
1607
|
});
|
|
@@ -1649,7 +1649,7 @@ function dt() {
|
|
|
1649
1649
|
id: "features",
|
|
1650
1650
|
label: "Features",
|
|
1651
1651
|
render() {
|
|
1652
|
-
return
|
|
1652
|
+
return dt() ? `
|
|
1653
1653
|
<div class="features-view-container">
|
|
1654
1654
|
<div class="simulator-section">
|
|
1655
1655
|
<div class="simulator-section-title">Game Features</div>
|
|
@@ -1690,7 +1690,7 @@ function dt() {
|
|
|
1690
1690
|
e && (yield d(e));
|
|
1691
1691
|
})), i == null || i.addEventListener("keypress", (e) => {
|
|
1692
1692
|
e.key === "Enter" && (r == null || r.click());
|
|
1693
|
-
}), console.log("[FeaturesView] bind called, ctx.gameSlug:", e.gameSlug, "slugInput:", i), e.gameSlug && i && (i.value = e.gameSlug,
|
|
1693
|
+
}), console.log("[FeaturesView] bind called, ctx.gameSlug:", e.gameSlug, "slugInput:", i), e.gameSlug && i && (i.value = e.gameSlug, dt() && !n && d(e.gameSlug)), u();
|
|
1694
1694
|
},
|
|
1695
1695
|
onActivate(e) {
|
|
1696
1696
|
let t = e.getElement("#simulator-tab-features");
|
|
@@ -1708,23 +1708,25 @@ function dt() {
|
|
|
1708
1708
|
* dependency, so it cannot be imported. The numbers have to be kept in step by hand.
|
|
1709
1709
|
*
|
|
1710
1710
|
* The wireframe styling is deliberate: only the box model is faithful, so only the box model is
|
|
1711
|
-
* drawn. Key icons, press animation, key repeat, haptics and
|
|
1712
|
-
*
|
|
1711
|
+
* drawn. Key icons, press animation, key repeat, haptics and `kbdStyles` are all dropped rather
|
|
1712
|
+
* than approximated. CSS the game sets on the keys themselves is the exception, both the config's
|
|
1713
|
+
* blanket `keyStyles` and its per-key `individualKeyStyles`: it is applied as sent, because a game
|
|
1714
|
+
* tuning it needs to see it.
|
|
1713
1715
|
*/
|
|
1714
1716
|
/** Space the keys occupy. */
|
|
1715
|
-
var
|
|
1717
|
+
var pt = 200, mt = 24;
|
|
1716
1718
|
/** What the keyboard takes off the bottom of the game, and what the game must lay out without. */
|
|
1717
|
-
const
|
|
1719
|
+
const J = pt + mt;
|
|
1718
1720
|
/** Drag-cursor thresholds, from useKeyboardCursor in @puzzmo-com/keyboard. */
|
|
1719
|
-
var
|
|
1721
|
+
var ht = 6, gt = 2.5, _t = 100, vt = (e, t) => e ? "14.7%" : t ? "17.85%" : "9.75%", Y = (e, t) => {
|
|
1720
1722
|
let n = e.replace("#", ""), r = n.length === 3 ? [...n].map((e) => e + e).join("") : n, i = parseInt(r, 16);
|
|
1721
1723
|
return r.length !== 6 || Number.isNaN(i) ? e : `rgba(${i >> 16 & 255}, ${i >> 8 & 255}, ${i & 255}, ${t})`;
|
|
1722
|
-
},
|
|
1723
|
-
function
|
|
1724
|
+
}, yt = (e) => e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<"), bt = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
1725
|
+
function xt(e) {
|
|
1724
1726
|
let { theme: t, sendToGame: n } = e, r = !1, i = null, a = null, o = document.createElement("style");
|
|
1725
1727
|
o.id = "sim-docked-kbd-page-style", o.textContent = `
|
|
1726
1728
|
html.sim-kbd-docked #simulator {
|
|
1727
|
-
bottom: ${
|
|
1729
|
+
bottom: ${J + 4}px;
|
|
1728
1730
|
}
|
|
1729
1731
|
`;
|
|
1730
1732
|
/** The element the game mounted into: `#root` per the SDK's page template, else the page's first element. */
|
|
@@ -1737,20 +1739,11 @@ function bt(e) {
|
|
|
1737
1739
|
let { height: t, maxHeight: n, position: r } = e.style;
|
|
1738
1740
|
c = () => {
|
|
1739
1741
|
e.style.height = t, e.style.maxHeight = n, e.style.position = r, c = null;
|
|
1740
|
-
}, e.style.height = `calc(100% - ${
|
|
1742
|
+
}, e.style.height = `calc(100% - ${J}px)`, e.style.maxHeight = `calc(100% - ${J}px)`, getComputedStyle(e).position === "static" && (e.style.position = "relative");
|
|
1741
1743
|
}, u = (e, n) => {
|
|
1742
|
-
var r
|
|
1743
|
-
let
|
|
1744
|
-
|
|
1745
|
-
`flex:${c ? "1 0 auto" : "0 1 auto"}`,
|
|
1746
|
-
"height:100%",
|
|
1747
|
-
"display:flex",
|
|
1748
|
-
"align-items:center",
|
|
1749
|
-
"justify-content:center",
|
|
1750
|
-
"padding:0 3px 12px",
|
|
1751
|
-
"position:relative",
|
|
1752
|
-
o ? "pointer-events:none" : ""
|
|
1753
|
-
].filter(Boolean).join(";"), u = [
|
|
1744
|
+
var r;
|
|
1745
|
+
let i = n.disabled.includes(e), a = n.highlight.includes(e);
|
|
1746
|
+
return [
|
|
1754
1747
|
"display:flex",
|
|
1755
1748
|
"align-items:center",
|
|
1756
1749
|
"justify-content:center",
|
|
@@ -1761,51 +1754,70 @@ function bt(e) {
|
|
|
1761
1754
|
"overflow:hidden",
|
|
1762
1755
|
"background:transparent",
|
|
1763
1756
|
"pointer-events:none",
|
|
1764
|
-
`border:${
|
|
1765
|
-
|
|
1757
|
+
`border:${i ? `1px dashed ${Y(t.fg, .25)}` : a ? `2px solid ${Y(t.fg, .75)}` : `1px solid ${Y(t.fg, .4)}`}`,
|
|
1758
|
+
X((r = n.individualKeyStyles) == null || (r = r[e]) == null ? void 0 : r.background)
|
|
1759
|
+
].filter(Boolean).join(";");
|
|
1760
|
+
}, d = (e, n) => {
|
|
1761
|
+
var r;
|
|
1762
|
+
return [
|
|
1766
1763
|
"font:11px/1 Menlo, Monaco, Consolas, monospace",
|
|
1767
1764
|
"letter-spacing:0.5px",
|
|
1768
1765
|
"text-transform:uppercase",
|
|
1769
1766
|
"white-space:nowrap",
|
|
1770
|
-
`color:${
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1767
|
+
`color:${Y(t.fg, n.disabled.includes(e) ? .3 : .65)}`,
|
|
1768
|
+
n.highlight.includes(e) ? "" : X(n.keyStyles),
|
|
1769
|
+
X((r = n.individualKeyStyles) == null || (r = r[e]) == null ? void 0 : r.text)
|
|
1770
|
+
].filter(Boolean).join(";");
|
|
1771
|
+
}, f = (e, t) => {
|
|
1772
|
+
var n, r;
|
|
1773
|
+
let i = (n = t.symbols[e]) == null ? e : n, a = t.disabled.includes(e), o = (r = t.flexGrowSymbols) == null ? void 0 : r.includes(e), s = [
|
|
1774
|
+
`width:${vt(t.l.includes(e), t.xl.includes(e))}`,
|
|
1775
|
+
`flex:${o ? "1 0 auto" : "0 1 auto"}`,
|
|
1776
|
+
"height:100%",
|
|
1777
|
+
"display:flex",
|
|
1778
|
+
"align-items:center",
|
|
1779
|
+
"justify-content:center",
|
|
1780
|
+
"padding:0 3px 12px",
|
|
1781
|
+
"position:relative",
|
|
1782
|
+
a ? "pointer-events:none" : ""
|
|
1783
|
+
].filter(Boolean).join(";"), c = u(e, t), l = d(e, t);
|
|
1784
|
+
return `<div class="sim-docked-kbd-key" data-key="${yt(e)}" style="${s}">
|
|
1785
|
+
<div class="sim-docked-kbd-key-inner" style="${c}"><div style="${l}">${bt(i)}</div></div>
|
|
1774
1786
|
</div>`;
|
|
1775
|
-
},
|
|
1787
|
+
}, p = (e) => {
|
|
1776
1788
|
let n = e.layout.filter((e) => !!e), r = `calc(100% / ${n.length})`;
|
|
1777
1789
|
return `${n.map((t, n) => {
|
|
1778
1790
|
var i, a;
|
|
1779
|
-
return `<div style="${`height:${r};display:flex;flex-direction:row;align-items:center;justify-content:${(i = (a = e.rowPositioning) == null ? void 0 : a[n]) == null ? "center" : i}`}">${[...t].map((t) =>
|
|
1780
|
-
}).join("")}${`<div id="sim-docked-kbd-cursor" style="position:absolute;inset:0;z-index:1;background:${
|
|
1781
|
-
},
|
|
1791
|
+
return `<div style="${`height:${r};display:flex;flex-direction:row;align-items:center;justify-content:${(i = (a = e.rowPositioning) == null ? void 0 : a[n]) == null ? "center" : i}`}">${[...t].map((t) => f(t, e)).join("")}</div>`;
|
|
1792
|
+
}).join("")}${`<div id="sim-docked-kbd-cursor" style="position:absolute;inset:0;z-index:1;background:${Y(t.fg, .12)};opacity:0;transition:opacity 0.1s ease-in-out;pointer-events:none"></div>`}`;
|
|
1793
|
+
}, m = !1, h = [0, 0], g = null, _ = 0, v = null, y = null, b = (e) => {
|
|
1782
1794
|
let t = a == null ? void 0 : a.querySelector("#sim-docked-kbd-cursor");
|
|
1783
1795
|
t && (t.style.opacity = e ? "0.5" : "0");
|
|
1784
|
-
},
|
|
1785
|
-
|
|
1786
|
-
},
|
|
1796
|
+
}, x = () => {
|
|
1797
|
+
m = !1, h = [0, 0], g = null, _ = 0, v = null, y = null, b(!1);
|
|
1798
|
+
}, S = (e) => {
|
|
1787
1799
|
var t, n;
|
|
1788
1800
|
return (t = (n = document.elementFromPoint(e.clientX, e.clientY)) == null || (n = n.closest(".sim-docked-kbd-key")) == null ? void 0 : n.getAttribute("data-key")) == null ? null : t;
|
|
1789
|
-
},
|
|
1790
|
-
|
|
1791
|
-
},
|
|
1792
|
-
!(i != null && i.supportsDragCursor) || !
|
|
1801
|
+
}, C = (e) => {
|
|
1802
|
+
y = S(e), a == null || a.setPointerCapture(e.pointerId);
|
|
1803
|
+
}, w = (e) => {
|
|
1804
|
+
!(i != null && i.supportsDragCursor) || !y || g && g.clientX === e.clientX && g.clientY === e.clientY || (g && g.pointerId !== e.pointerId && (_ = 0, v = null), v || (v = Date.now()), m || (_ += 1, _ >= ht && Date.now() - v >= _t && (m = !0, b(!0))), m && g && (h = [h[0] + (e.clientX - g.clientX) * gt, h[1] + (e.clientY - g.clientY) * gt]), g = {
|
|
1793
1805
|
clientX: e.clientX,
|
|
1794
1806
|
clientY: e.clientY,
|
|
1795
1807
|
pointerId: e.pointerId
|
|
1796
|
-
},
|
|
1797
|
-
},
|
|
1798
|
-
|
|
1799
|
-
},
|
|
1808
|
+
}, m && n("KEYBOARD_CURSOR_CHANGE", { position: h }));
|
|
1809
|
+
}, ee = (e) => {
|
|
1810
|
+
m ? n("KEYBOARD_CURSOR_END", {}) : y && S(e) === y && n("KEYBOARD_KEY_PRESS", { key: y }), x();
|
|
1811
|
+
}, te = () => {
|
|
1800
1812
|
a || !i || (a = document.createElement("div"), a.id = "sim-docked-kbd", a.style.cssText = [
|
|
1801
1813
|
"position:fixed",
|
|
1802
1814
|
"left:0",
|
|
1803
1815
|
"right:0",
|
|
1804
1816
|
"bottom:0",
|
|
1805
|
-
`height:${
|
|
1817
|
+
`height:${J}px`,
|
|
1806
1818
|
"box-sizing:border-box",
|
|
1807
1819
|
"padding-top:8px",
|
|
1808
|
-
`padding-bottom:${
|
|
1820
|
+
`padding-bottom:${mt}px`,
|
|
1809
1821
|
"display:flex",
|
|
1810
1822
|
"flex-direction:column",
|
|
1811
1823
|
"z-index:999998",
|
|
@@ -1813,39 +1825,60 @@ function bt(e) {
|
|
|
1813
1825
|
"user-select:none",
|
|
1814
1826
|
"-webkit-user-select:none",
|
|
1815
1827
|
`background:${t.a_bg}`,
|
|
1816
|
-
`border-top:1px solid ${
|
|
1817
|
-
].join(";"), a.innerHTML =
|
|
1818
|
-
},
|
|
1819
|
-
a && (a.remove(), a = null, document.documentElement.classList.remove("sim-kbd-docked"), c == null || c(),
|
|
1820
|
-
},
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1828
|
+
`border-top:1px solid ${Y(t.fg, .2)}`
|
|
1829
|
+
].join(";"), a.innerHTML = p(i), a.addEventListener("pointerdown", C), a.addEventListener("pointermove", w), a.addEventListener("pointerup", ee), a.addEventListener("pointercancel", () => x()), a.addEventListener("contextmenu", (e) => e.preventDefault()), document.body.appendChild(a), o.isConnected || document.head.appendChild(o), document.documentElement.classList.add("sim-kbd-docked"), l());
|
|
1830
|
+
}, T = () => {
|
|
1831
|
+
a && (a.remove(), a = null, document.documentElement.classList.remove("sim-kbd-docked"), c == null || c(), x());
|
|
1832
|
+
}, E = () => {
|
|
1833
|
+
let e = i;
|
|
1834
|
+
!a || !e || a.querySelectorAll(".sim-docked-kbd-key").forEach((t) => {
|
|
1835
|
+
let n = t.getAttribute("data-key"), r = t.firstElementChild, i = r == null ? void 0 : r.firstElementChild;
|
|
1836
|
+
!n || !r || !i || (r.style.cssText = u(n, e), i.style.cssText = d(n, e));
|
|
1837
|
+
});
|
|
1838
|
+
}, D = () => {
|
|
1839
|
+
if (!r || !i) return T();
|
|
1840
|
+
if (!a) return te();
|
|
1841
|
+
a.innerHTML = p(i), b(m);
|
|
1824
1842
|
};
|
|
1825
1843
|
return {
|
|
1826
1844
|
setEnabled(e) {
|
|
1827
|
-
r = e,
|
|
1845
|
+
r = e, D();
|
|
1828
1846
|
},
|
|
1829
1847
|
setConfig(e) {
|
|
1830
|
-
|
|
1848
|
+
let t = a && e && i && St(e) === St(i);
|
|
1849
|
+
i = e, t ? E() : D();
|
|
1831
1850
|
}
|
|
1832
1851
|
};
|
|
1833
1852
|
}
|
|
1853
|
+
/** Everything about a config except its per-key styling, so a styling-only update can be spotted. */
|
|
1854
|
+
var St = (e) => JSON.stringify([
|
|
1855
|
+
e.layout,
|
|
1856
|
+
e.symbols,
|
|
1857
|
+
e.highlight,
|
|
1858
|
+
e.disabled,
|
|
1859
|
+
e.xl,
|
|
1860
|
+
e.l,
|
|
1861
|
+
e.flexGrowSymbols,
|
|
1862
|
+
e.rowPositioning,
|
|
1863
|
+
e.keyStyles
|
|
1864
|
+
]);
|
|
1865
|
+
/** Serializes a style object into inline CSS, so `{ backgroundColor: "red" }` becomes `background-color:red`. */
|
|
1866
|
+
const X = (e) => Object.entries(e == null ? {} : e).map(([e, t]) => `${e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`)}:${yt(String(t))}`).join(";");
|
|
1834
1867
|
/** Renders a single keyboard key as an HTML button string */
|
|
1835
|
-
var
|
|
1836
|
-
var n, r;
|
|
1837
|
-
let
|
|
1838
|
-
return `<button class="${[
|
|
1868
|
+
var Ct = (e, t) => {
|
|
1869
|
+
var n, r, i, a;
|
|
1870
|
+
let o = (n = t.symbols[e]) == null ? e : n, s = t.disabled.includes(e), c = t.highlight.includes(e), l = t.xl.includes(e), u = t.l.includes(e), d = (r = t.flexGrowSymbols) == null ? void 0 : r.includes(e), f = [
|
|
1839
1871
|
"sim-kb-key",
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
].filter(Boolean).join(" ")
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1872
|
+
s ? "disabled" : "",
|
|
1873
|
+
c ? "highlight" : "",
|
|
1874
|
+
l ? "xl" : "",
|
|
1875
|
+
u ? "l" : "",
|
|
1876
|
+
d ? "grow" : ""
|
|
1877
|
+
].filter(Boolean).join(" "), p = X((i = t.individualKeyStyles) == null || (i = i[e]) == null ? void 0 : i.background), m = X((a = t.individualKeyStyles) == null || (a = a[e]) == null ? void 0 : a.text);
|
|
1878
|
+
return `<button class="${f}" data-key="${e}" style="${p}" ${s ? "disabled" : ""}><span style="${m}">${o}</span></button>`;
|
|
1879
|
+
}, wt = (e) => `<div class="sim-kb">${e.layout.filter((e) => e != null).map((t) => `<div class="sim-kb-row">${[...t].map((t) => Ct(t, e)).join("")}</div>`).join("")}</div>`;
|
|
1880
|
+
function Tt() {
|
|
1881
|
+
let e = null, t = null, n = (t) => e ? t ? `<div class="sim-kb-empty">Shown under the game at production size, taking ${J}px off the bottom.<br>Uncheck to preview the layout here instead.</div>` : wt(e) : "<div class=\"sim-kb-empty\">No keyboard config received from game yet.<br>The game calls <code>sdk.keyboard.show(config)</code> to display a keyboard.</div>";
|
|
1849
1882
|
return {
|
|
1850
1883
|
id: "kbd",
|
|
1851
1884
|
label: "Kbd",
|
|
@@ -1865,14 +1898,14 @@ function Ct() {
|
|
|
1865
1898
|
`;
|
|
1866
1899
|
},
|
|
1867
1900
|
bind(e) {
|
|
1868
|
-
t != null || (t =
|
|
1901
|
+
t != null || (t = xt({
|
|
1869
1902
|
theme: e.state.selectedTheme,
|
|
1870
1903
|
sendToGame: e.sendToGame
|
|
1871
1904
|
})), t.setEnabled(e.state.keyboardDocked);
|
|
1872
1905
|
let n = e.getElement("#sim-kb-dock");
|
|
1873
1906
|
n && (n.checked = e.state.keyboardDocked, n.addEventListener("change", () => {
|
|
1874
1907
|
e.state.keyboardDocked = n.checked, m(n.checked), t == null || t.setEnabled(n.checked), r(e);
|
|
1875
|
-
})),
|
|
1908
|
+
})), Et(e);
|
|
1876
1909
|
},
|
|
1877
1910
|
onMessage(n, i, a) {
|
|
1878
1911
|
var o;
|
|
@@ -1882,11 +1915,11 @@ function Ct() {
|
|
|
1882
1915
|
/** Re-render the tab's own content (not the dock) and rebind its keys. */
|
|
1883
1916
|
function r(e) {
|
|
1884
1917
|
let t = e.getElement("#sim-kb-content");
|
|
1885
|
-
t && (t.innerHTML = n(e.state.keyboardDocked),
|
|
1918
|
+
t && (t.innerHTML = n(e.state.keyboardDocked), Et(e));
|
|
1886
1919
|
}
|
|
1887
1920
|
}
|
|
1888
1921
|
/** Attach click handlers to all rendered keys */
|
|
1889
|
-
function
|
|
1922
|
+
function Et(e) {
|
|
1890
1923
|
var t;
|
|
1891
1924
|
let n = (t = e.getElement("#sim-kb-content")) == null ? void 0 : t.querySelectorAll(".sim-kb-key");
|
|
1892
1925
|
n == null || n.forEach((t) => {
|
|
@@ -1901,15 +1934,15 @@ function wt(e) {
|
|
|
1901
1934
|
* change values (persisted to localStorage and pushed to the game as SETTINGS_UPDATE, matching the
|
|
1902
1935
|
* production host) and reflects UPDATE_SETTINGS_FROM_EMBED writes coming from the game.
|
|
1903
1936
|
*/
|
|
1904
|
-
function
|
|
1937
|
+
function Dt() {
|
|
1905
1938
|
let t = (e) => {
|
|
1906
1939
|
let t = e.state.settingsComponents;
|
|
1907
|
-
return !t || t.length === 0 ? "<div class=\"sim-settings-empty\">No settings registered by the game yet.<br>The game calls <code>sdk.settings.initialize(components)</code> to describe its settings UI.</div>" : `<div class="sim-settings-form">${t.map((t) =>
|
|
1940
|
+
return !t || t.length === 0 ? "<div class=\"sim-settings-empty\">No settings registered by the game yet.<br>The game calls <code>sdk.settings.initialize(components)</code> to describe its settings UI.</div>" : `<div class="sim-settings-form">${t.map((t) => Ot(t, e.state.gameSettings)).join("")}</div><div class="sim-settings-actions"><button class="simulator-btn tiny" id="sim-settings-reset">Reset to defaults</button></div>`;
|
|
1908
1941
|
}, n = (e) => {
|
|
1909
1942
|
let n = e.getElement("#sim-settings-content");
|
|
1910
1943
|
n && (n.innerHTML = t(e), i(e));
|
|
1911
1944
|
}, r = (e) => {
|
|
1912
|
-
|
|
1945
|
+
C(e.state.gameSettings), e.sendToGame("SETTINGS_UPDATE", e.state.gameSettings);
|
|
1913
1946
|
}, i = (t) => {
|
|
1914
1947
|
var i;
|
|
1915
1948
|
let a = t.getElement("#sim-settings-content");
|
|
@@ -1925,7 +1958,7 @@ function Tt() {
|
|
|
1925
1958
|
});
|
|
1926
1959
|
}), (i = a.querySelector("#sim-settings-reset")) == null || i.addEventListener("click", () => {
|
|
1927
1960
|
var e;
|
|
1928
|
-
|
|
1961
|
+
w(), t.state.gameSettings = kt((e = t.state.settingsComponents) == null ? [] : e), r(t), n(t);
|
|
1929
1962
|
}));
|
|
1930
1963
|
};
|
|
1931
1964
|
return {
|
|
@@ -1940,21 +1973,21 @@ function Tt() {
|
|
|
1940
1973
|
onMessage(t, r, i) {
|
|
1941
1974
|
if (t === "INITIALIZE_SETTINGS") {
|
|
1942
1975
|
var a;
|
|
1943
|
-
i.state.settingsComponents = (a = r == null ? void 0 : r.components) == null ? [] : a, i.state.gameSettings = e(e({}, r == null ? void 0 : r.settings), i.state.gameSettings),
|
|
1976
|
+
i.state.settingsComponents = (a = r == null ? void 0 : r.components) == null ? [] : a, i.state.gameSettings = e(e({}, r == null ? void 0 : r.settings), i.state.gameSettings), C(i.state.gameSettings), n(i);
|
|
1944
1977
|
return;
|
|
1945
1978
|
}
|
|
1946
|
-
t === "UPDATE_SETTINGS_FROM_EMBED" && (i.state.gameSettings = e(e({}, i.state.gameSettings), r == null ? void 0 : r.settings),
|
|
1979
|
+
t === "UPDATE_SETTINGS_FROM_EMBED" && (i.state.gameSettings = e(e({}, i.state.gameSettings), r == null ? void 0 : r.settings), C(i.state.gameSettings), n(i));
|
|
1947
1980
|
}
|
|
1948
1981
|
};
|
|
1949
1982
|
}
|
|
1950
1983
|
/** Renders a single settings UI component as HTML, reading its current value from `settings` */
|
|
1951
|
-
function
|
|
1984
|
+
function Ot(e, t) {
|
|
1952
1985
|
switch (e.type) {
|
|
1953
1986
|
case "title": return `<div class="sim-settings-heading">${Q(e.value)}</div>`;
|
|
1954
1987
|
case "subtitle": return `<div class="sim-settings-subheading">${Q(e.value)}</div>`;
|
|
1955
1988
|
case "paragraph": return `<p class="sim-settings-paragraph">${Q(e.value)}</p>`;
|
|
1956
1989
|
case "separator": return "<div class=\"simulator-divider\"></div>";
|
|
1957
|
-
case "split": return `<div class="sim-settings-split">${e.content.map((e) =>
|
|
1990
|
+
case "split": return `<div class="sim-settings-split">${e.content.map((e) => Ot(e, t)).join("")}</div>`;
|
|
1958
1991
|
case "boolean": {
|
|
1959
1992
|
var n;
|
|
1960
1993
|
let r = ((n = t[e.name]) == null ? e.defaultValue : n) ? "checked" : "", i = e.subtitle ? `<div class="sim-settings-subtitle">${Q(e.subtitle)}</div>` : "";
|
|
@@ -2022,9 +2055,9 @@ function Z(e) {
|
|
|
2022
2055
|
return `<span class="simulator-label">${Q(e.title)}</span>${t}`;
|
|
2023
2056
|
}
|
|
2024
2057
|
/** Collects name → defaultValue pairs from components, recursing into split groups */
|
|
2025
|
-
function
|
|
2058
|
+
function kt(e) {
|
|
2026
2059
|
let t = {};
|
|
2027
|
-
for (let n of e) n.type === "split" ? Object.assign(t,
|
|
2060
|
+
for (let n of e) n.type === "split" ? Object.assign(t, kt(n.content)) : "name" in n && (t[n.name] = n.defaultValue);
|
|
2028
2061
|
return t;
|
|
2029
2062
|
}
|
|
2030
2063
|
function Q(e) {
|
|
@@ -2035,8 +2068,8 @@ function Q(e) {
|
|
|
2035
2068
|
* parts the host owns: the sound-enabled gate (games boot muted, so this is what lets you hear
|
|
2036
2069
|
* anything) and a log of the cues the game asked us for, with any haptic it wanted.
|
|
2037
2070
|
*/
|
|
2038
|
-
function
|
|
2039
|
-
let e = [], t = !0, n = () => e.length === 0 ? "<div class=\"sound-empty\">No
|
|
2071
|
+
function At() {
|
|
2072
|
+
let e = [], t = !0, n = () => e.length === 0 ? "<div class=\"sound-empty\">No cues yet. Play the game to hear from it.</div>" : e.map((e) => `<div class="sound-row"><span class="sound-id">${Mt(e.id)}</span>${e.haptic ? `<span class="sound-haptic">${Mt(e.haptic)}</span>` : ""}<span class="sound-time">${e.time}</span></div>`).join(""), r = (t) => {
|
|
2040
2073
|
let r = t.getElement("#sound-events");
|
|
2041
2074
|
r && (r.innerHTML = n()), t.updateBadge("sound", e.length);
|
|
2042
2075
|
};
|
|
@@ -2055,7 +2088,7 @@ function Ot() {
|
|
|
2055
2088
|
#simulator-tab-sound .sound-toggle { font-size: 11px; display: flex; align-items: center; gap: 4px; }
|
|
2056
2089
|
</style>
|
|
2057
2090
|
<div class="simulator-section">
|
|
2058
|
-
<div class="simulator-section-title">
|
|
2091
|
+
<div class="simulator-section-title">Cues</div>
|
|
2059
2092
|
<div class="sound-controls">
|
|
2060
2093
|
<label class="sound-toggle"><input type="checkbox" id="sound-enabled" ${t ? "checked" : ""} /> Sound enabled</label>
|
|
2061
2094
|
<button class="simulator-btn" id="sound-clear">Clear</button>
|
|
@@ -2080,18 +2113,16 @@ function Ot() {
|
|
|
2080
2113
|
a.sendToGame("SOUND_ENABLED", { enabled: t });
|
|
2081
2114
|
return;
|
|
2082
2115
|
}
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
time: kt()
|
|
2089
|
-
}), e.length > 100 && e.pop(), r(a);
|
|
2116
|
+
n === "SENSORY_EVENT" && (e.unshift({
|
|
2117
|
+
id: (o = i == null ? void 0 : i.id) == null ? JSON.stringify(i) : o,
|
|
2118
|
+
haptic: i == null ? void 0 : i.haptic,
|
|
2119
|
+
time: jt()
|
|
2120
|
+
}), e.length > 100 && e.pop(), r(a));
|
|
2090
2121
|
}
|
|
2091
2122
|
};
|
|
2092
2123
|
}
|
|
2093
2124
|
/** Current wall-clock time as HH:MM:SS, matching the simulator's message log formatting. */
|
|
2094
|
-
function
|
|
2125
|
+
function jt() {
|
|
2095
2126
|
return (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
|
|
2096
2127
|
hour12: !1,
|
|
2097
2128
|
hour: "2-digit",
|
|
@@ -2100,16 +2131,16 @@ function kt() {
|
|
|
2100
2131
|
});
|
|
2101
2132
|
}
|
|
2102
2133
|
/** Minimal HTML-escape so event ids can't break the simulator markup. */
|
|
2103
|
-
function
|
|
2134
|
+
function Mt(e) {
|
|
2104
2135
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
2105
2136
|
}
|
|
2106
2137
|
var $ = null;
|
|
2107
2138
|
/** True when the game is embedded in the real Puzzmo app, which sets `?developer=true` on the iframe. */
|
|
2108
|
-
function
|
|
2139
|
+
function Nt() {
|
|
2109
2140
|
return typeof window > "u" ? !1 : new URLSearchParams(window.location.search).has("developer");
|
|
2110
2141
|
}
|
|
2111
2142
|
/** Inert instance returned when the simulator declines to boot (the app is the host). */
|
|
2112
|
-
var
|
|
2143
|
+
var Pt = {
|
|
2113
2144
|
updateFixtures: () => {},
|
|
2114
2145
|
sendToGame: () => {},
|
|
2115
2146
|
loadPuzzle: function() {
|
|
@@ -2158,29 +2189,29 @@ var Mt = {
|
|
|
2158
2189
|
* Fixtures are loaded as raw strings and passed to the game verbatim (any text format works; the game parses it).
|
|
2159
2190
|
* This will show dropdowns in the Ctrl tab to select category and puzzle.
|
|
2160
2191
|
*/
|
|
2161
|
-
function
|
|
2192
|
+
function Ft(e = {}) {
|
|
2162
2193
|
var n, r, i;
|
|
2163
|
-
if (
|
|
2194
|
+
if (Nt()) return console.log("[Simulator] developer=true in URL — running inside the Puzzmo app, skipping simulator boot"), Pt;
|
|
2164
2195
|
if (console.log("[Simulator] createSimulator called with config:", {
|
|
2165
2196
|
slug: e.slug,
|
|
2166
2197
|
hasFixtures: !!e.fixtures
|
|
2167
2198
|
}), $) return e.fixtures && (console.log("[Simulator] Instance already exists, updating fixtures"), $.updateFixtures(e.fixtures)), $;
|
|
2168
2199
|
let a = (n = e.autoStart) == null ? !0 : n, o = e.fixtures ? ae(e.fixtures) : null, s = o ? Array.from(o.keys()).sort() : [], c = me(), l = Ce(), u = [
|
|
2169
2200
|
se(),
|
|
2170
|
-
|
|
2201
|
+
ce(),
|
|
2171
2202
|
c,
|
|
2172
2203
|
he(),
|
|
2173
2204
|
ge(),
|
|
2174
2205
|
l,
|
|
2175
2206
|
Te(),
|
|
2176
2207
|
De(e.hostContextPresets),
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
Ct(),
|
|
2208
|
+
qe(),
|
|
2209
|
+
ft(),
|
|
2180
2210
|
Tt(),
|
|
2181
|
-
|
|
2211
|
+
Dt(),
|
|
2212
|
+
At(),
|
|
2182
2213
|
...(r = e.views) == null ? [] : r
|
|
2183
|
-
], d = u.map((e) => e.id), f =
|
|
2214
|
+
], d = u.map((e) => e.id), f = S(e, s, d), p = {
|
|
2184
2215
|
pause: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><rect x=\"1\" y=\"1\" width=\"3\" height=\"8\"/><rect x=\"6\" y=\"1\" width=\"3\" height=\"8\"/></svg>",
|
|
2185
2216
|
play: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><polygon points=\"2,1 9,5 2,9\"/></svg>",
|
|
2186
2217
|
retry: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><path d=\"M5 1C2.8 1 1 2.8 1 5s1.8 4 4 4c1.8 0 3.3-1.2 3.8-2.8H7.5c-.4.9-1.3 1.5-2.5 1.5-1.5 0-2.7-1.2-2.7-2.7S3.5 2.3 5 2.3c.7 0 1.4.3 1.9.8L5.5 4.5H9V1L7.6 2.4C6.9 1.5 5.9 1 5 1z\"/></svg>",
|
|
@@ -3535,16 +3566,16 @@ function Nt(e = {}) {
|
|
|
3535
3566
|
</div>
|
|
3536
3567
|
</div>
|
|
3537
3568
|
`, document.body.appendChild(m);
|
|
3538
|
-
let h = m.querySelector("#simulator-panel"), g = m.querySelector("#simulator-header"), _ = m.querySelector("#simulator-header-indicator"), v = m.querySelector("#simulator-header-status-text"), y = m.querySelector("#simulator-header-pause"), b = m.querySelector("#simulator-header-retry"), x = m.querySelector("#simulator-header-settings"),
|
|
3569
|
+
let h = m.querySelector("#simulator-panel"), g = m.querySelector("#simulator-header"), _ = m.querySelector("#simulator-header-indicator"), v = m.querySelector("#simulator-header-status-text"), y = m.querySelector("#simulator-header-pause"), b = m.querySelector("#simulator-header-retry"), x = m.querySelector("#simulator-header-settings"), C = m.querySelector("#simulator-toggle"), w = m.querySelector("#simulator-timer"), T = m.querySelector("#simulator-tabs"), E = m.querySelector("#simulator-content"), D = (e) => m.querySelector(e), O = (e) => {
|
|
3539
3570
|
y.innerHTML = e ? p.play : p.pause, y.title = e ? "Resume" : "Pause";
|
|
3540
3571
|
}, k = (e, t) => {
|
|
3541
3572
|
let n = D("#simulator-status .text"), r = D("#simulator-status .indicator"), i = t === "complete" ? "✓" : "";
|
|
3542
3573
|
n && (n.textContent = e), r && (r.className = `indicator ${t}`, r.textContent = i), _.className = t, _.textContent = i, v.textContent = e;
|
|
3543
3574
|
}, A = (e, t) => {
|
|
3544
|
-
t && t !== "0" ?
|
|
3575
|
+
t && t !== "0" ? w.innerHTML = `${e}<span class="penalty">+${t}</span>` : w.textContent = e;
|
|
3545
3576
|
}, j = (e) => {
|
|
3546
3577
|
var t;
|
|
3547
|
-
f.activeTab = e, E.classList.remove("hidden"),
|
|
3578
|
+
f.activeTab = e, E.classList.remove("hidden"), te(e), T.querySelectorAll(".simulator-tab").forEach((t) => {
|
|
3548
3579
|
t.classList.toggle("active", t.getAttribute("data-tab") === e);
|
|
3549
3580
|
}), m.querySelectorAll(".simulator-tab-content").forEach((t) => {
|
|
3550
3581
|
t.classList.toggle("active", t.id === `simulator-tab-${e}`);
|
|
@@ -3552,7 +3583,7 @@ function Nt(e = {}) {
|
|
|
3552
3583
|
let n = u.find((t) => t.id === e);
|
|
3553
3584
|
n == null || (t = n.onActivate) == null || t.call(n, R);
|
|
3554
3585
|
}, M = (e) => {
|
|
3555
|
-
f.isCollapsed = e, h.classList.toggle("collapsed", e),
|
|
3586
|
+
f.isCollapsed = e, h.classList.toggle("collapsed", e), ee(e), e ? (E.classList.add("hidden"), T.querySelectorAll(".simulator-tab").forEach((e) => e.classList.remove("active"))) : j(f.activeTab);
|
|
3556
3587
|
}, N = () => {
|
|
3557
3588
|
l.updatePreview(R);
|
|
3558
3589
|
}, P = function() {
|
|
@@ -3603,7 +3634,7 @@ function Nt(e = {}) {
|
|
|
3603
3634
|
let t = e.getAttribute("data-tab");
|
|
3604
3635
|
j(t), L(t, 0);
|
|
3605
3636
|
});
|
|
3606
|
-
}),
|
|
3637
|
+
}), C.addEventListener("click", (e) => {
|
|
3607
3638
|
e.stopPropagation(), M(!0);
|
|
3608
3639
|
}), y.addEventListener("click", (e) => {
|
|
3609
3640
|
e.stopPropagation(), f.isPaused ? (I("RESUME_GAME", {}), f.isPaused = !1, O(!1), k("Running", "ready")) : (I("PAUSE_GAME", {}), f.isPaused = !0, O(!0), k("Paused", "paused"));
|
|
@@ -3616,11 +3647,11 @@ function Nt(e = {}) {
|
|
|
3616
3647
|
}), x.addEventListener("click", (e) => {
|
|
3617
3648
|
e.stopPropagation(), f.isCollapsed && M(!1), j("auth");
|
|
3618
3649
|
}), g.addEventListener("click", (e) => {
|
|
3619
|
-
f.isCollapsed && e.target !==
|
|
3650
|
+
f.isCollapsed && e.target !== C && M(!1);
|
|
3620
3651
|
}), f.isCollapsed || j(f.activeTab);
|
|
3621
|
-
let
|
|
3622
|
-
(
|
|
3623
|
-
let
|
|
3652
|
+
let z = new URLSearchParams(window.location.search);
|
|
3653
|
+
(z.has("code") || z.has("error")) && (M(!1), j("auth"));
|
|
3654
|
+
let B = (e) => ({
|
|
3624
3655
|
userState: {
|
|
3625
3656
|
gameSettings: { "proto-game": f.gameSettings },
|
|
3626
3657
|
id: "simulator-user",
|
|
@@ -3661,11 +3692,11 @@ function Nt(e = {}) {
|
|
|
3661
3692
|
theme: f.selectedTheme,
|
|
3662
3693
|
hostContext: f.hostContext,
|
|
3663
3694
|
appRuntimeContract: "1.0"
|
|
3664
|
-
}),
|
|
3695
|
+
}), V = function() {
|
|
3665
3696
|
var e = t(function* () {
|
|
3666
3697
|
k("Loading puzzle...", "waiting");
|
|
3667
3698
|
try {
|
|
3668
|
-
let e =
|
|
3699
|
+
let e = B(yield P());
|
|
3669
3700
|
k("Sending READY_DATA...", "waiting"), I("READY_DATA", e), k("Waiting for game to load...", "waiting");
|
|
3670
3701
|
} catch (e) {
|
|
3671
3702
|
k(`Error: ${e}`, "paused");
|
|
@@ -3674,7 +3705,7 @@ function Nt(e = {}) {
|
|
|
3674
3705
|
return function() {
|
|
3675
3706
|
return e.apply(this, arguments);
|
|
3676
3707
|
};
|
|
3677
|
-
}(),
|
|
3708
|
+
}(), le = () => {
|
|
3678
3709
|
console.log("Simulator: Game loaded, ready to start"), b.disabled = !1, u.forEach((e) => {
|
|
3679
3710
|
var t;
|
|
3680
3711
|
return (t = e.onMessage) == null ? void 0 : t.call(e, "READY_GAME_LOADED", void 0, R);
|
|
@@ -3686,11 +3717,11 @@ function Nt(e = {}) {
|
|
|
3686
3717
|
return ie((e, t) => {
|
|
3687
3718
|
var n, r;
|
|
3688
3719
|
if (e === "READY") {
|
|
3689
|
-
console.log("Simulator: Received READY from game"),
|
|
3720
|
+
console.log("Simulator: Received READY from game"), V();
|
|
3690
3721
|
return;
|
|
3691
3722
|
}
|
|
3692
3723
|
if (e === "READY_GAME_LOADED") {
|
|
3693
|
-
|
|
3724
|
+
le();
|
|
3694
3725
|
return;
|
|
3695
3726
|
}
|
|
3696
3727
|
if (e === "TIMER_TICK") {
|
|
@@ -3729,6 +3760,6 @@ function Nt(e = {}) {
|
|
|
3729
3760
|
loadPuzzle: P
|
|
3730
3761
|
}, $;
|
|
3731
3762
|
}
|
|
3732
|
-
export {
|
|
3763
|
+
export { At as n, oe as r, Ft as t };
|
|
3733
3764
|
|
|
3734
|
-
//# sourceMappingURL=createSimulator-
|
|
3765
|
+
//# sourceMappingURL=createSimulator-5inYnxKU.js.map
|