@puzzmo/sdk 1.0.30 → 1.0.32
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/contracts.cjs +0 -0
- package/dist/contracts.d.ts +95 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +0 -0
- package/dist/{createSimulator-DqF2fN_0.js → createSimulator-COj3lAeu.js} +225 -204
- package/dist/{createSimulator-DqF2fN_0.js.map → createSimulator-COj3lAeu.js.map} +1 -1
- package/dist/{createSimulator-B7x0QRdO.cjs → createSimulator-DIT36V1k.cjs} +31 -23
- package/dist/{createSimulator-B7x0QRdO.cjs.map → createSimulator-DIT36V1k.cjs.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +100 -90
- package/dist/index.js.map +1 -1
- package/dist/plugins.d.ts +2 -0
- package/dist/plugins.d.ts.map +1 -0
- package/dist/plugins.spec.d.ts +2 -0
- package/dist/plugins.spec.d.ts.map +1 -0
- package/dist/sdk.d.ts +7 -2
- package/dist/sdk.d.ts.map +1 -1
- package/dist/simulator/createSimulator.d.ts.map +1 -1
- package/dist/simulator/index.cjs +1 -1
- package/dist/simulator/index.d.ts +1 -1
- package/dist/simulator/index.d.ts.map +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/types.d.ts +6 -0
- package/dist/simulator/types.d.ts.map +1 -1
- package/dist/simulator/views/SettingsView.d.ts.map +1 -1
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -1
|
@@ -401,16 +401,16 @@ function g(e) {
|
|
|
401
401
|
function _(e) {
|
|
402
402
|
localStorage.setItem(r.fixturePuzzle, e);
|
|
403
403
|
}
|
|
404
|
-
function
|
|
404
|
+
function v() {
|
|
405
405
|
localStorage.removeItem(r.fixturePuzzle);
|
|
406
406
|
}
|
|
407
|
-
function
|
|
407
|
+
function y(e) {
|
|
408
408
|
e ? localStorage.setItem(r.renderHost, e) : localStorage.removeItem(r.renderHost);
|
|
409
409
|
}
|
|
410
|
-
function
|
|
410
|
+
function b(e) {
|
|
411
411
|
e ? localStorage.setItem(r.renderContext, e) : localStorage.removeItem(r.renderContext);
|
|
412
412
|
}
|
|
413
|
-
function
|
|
413
|
+
function ee(e) {
|
|
414
414
|
let t = [];
|
|
415
415
|
return {
|
|
416
416
|
log(n, r, i) {
|
|
@@ -435,13 +435,13 @@ function te(e) {
|
|
|
435
435
|
}
|
|
436
436
|
};
|
|
437
437
|
}
|
|
438
|
-
function
|
|
438
|
+
function te(e, t, n) {
|
|
439
439
|
console.log("Simulator sending:", e, t), n == null || n.log(e, t, "out"), window.postMessage({
|
|
440
440
|
type: e,
|
|
441
441
|
data: t
|
|
442
442
|
}, "*");
|
|
443
443
|
}
|
|
444
|
-
function
|
|
444
|
+
function ne(e, t) {
|
|
445
445
|
let n = (n) => {
|
|
446
446
|
var r, i, a;
|
|
447
447
|
if (!(!(n == null || (r = n.data) == null) && r.type)) return;
|
|
@@ -451,7 +451,7 @@ function re(e, t) {
|
|
|
451
451
|
return window.addEventListener("message", n), () => window.removeEventListener("message", n);
|
|
452
452
|
}
|
|
453
453
|
/** Parse fixture imports into a structured format: { category: { filename: data } } */
|
|
454
|
-
function
|
|
454
|
+
function re(e) {
|
|
455
455
|
let t = /* @__PURE__ */ new Map();
|
|
456
456
|
console.log("Simulator: Parsing fixtures", Object.keys(e));
|
|
457
457
|
for (let [o, s] of Object.entries(e)) {
|
|
@@ -470,7 +470,7 @@ function ie(e) {
|
|
|
470
470
|
}), t;
|
|
471
471
|
}
|
|
472
472
|
/** Render fixture selector HTML */
|
|
473
|
-
function
|
|
473
|
+
function ie(e, t) {
|
|
474
474
|
return e.length === 0 ? "" : `
|
|
475
475
|
<div class="simulator-fixtures">
|
|
476
476
|
<div class="simulator-field">
|
|
@@ -517,7 +517,7 @@ function ae() {
|
|
|
517
517
|
selectedCategory: e.state.selectedCategory,
|
|
518
518
|
selectedPuzzle: e.state.selectedPuzzle
|
|
519
519
|
}), e.fixtures && e.fixtureCategories.length > 0 && i) {
|
|
520
|
-
i.innerHTML =
|
|
520
|
+
i.innerHTML = ie(e.fixtureCategories, e.state.selectedCategory);
|
|
521
521
|
let t = e.getElement("#simulator-fixture-category"), n = e.getElement("#simulator-fixture-puzzle");
|
|
522
522
|
if (t && n && e.state.selectedCategory) {
|
|
523
523
|
e.state.selectedPuzzle = x(n, e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
|
|
@@ -527,7 +527,7 @@ function ae() {
|
|
|
527
527
|
puzzle: e.state.selectedPuzzle,
|
|
528
528
|
hasPuzzleData: !!r
|
|
529
529
|
}), r && (e.state.puzzleData = r, e.state.originalPuzzle = r, e.state.selectedCategory && g(e.state.selectedCategory), e.state.selectedPuzzle && _(e.state.selectedPuzzle)), t.addEventListener("change", () => {
|
|
530
|
-
console.log("Simulator: Category changed, reloading...", t.value), g(t.value),
|
|
530
|
+
console.log("Simulator: Category changed, reloading...", t.value), g(t.value), v(), window.location.reload();
|
|
531
531
|
}), n.addEventListener("change", () => {
|
|
532
532
|
console.log("Simulator: Puzzle changed, reloading...", n.value), _(n.value), window.location.reload();
|
|
533
533
|
});
|
|
@@ -899,10 +899,10 @@ function ue() {
|
|
|
899
899
|
let n = e.getElement("#simulator-render-host-select"), r = e.getElement("#simulator-render-context-select"), i = e.getElement("#simulator-render-context-field"), a = () => {
|
|
900
900
|
i && (i.style.display = e.state.renderHost === "opengraph" ? "block" : "none");
|
|
901
901
|
};
|
|
902
|
-
n && (e.state.renderHost || (e.state.renderHost = "game",
|
|
903
|
-
e.state.renderHost = n.value,
|
|
904
|
-
})), r && (e.state.renderContext || (e.state.renderContext = "preview",
|
|
905
|
-
e.state.renderContext = r.value,
|
|
902
|
+
n && (e.state.renderHost || (e.state.renderHost = "game", y(e.state.renderHost)), n.value = e.state.renderHost || "game", n.addEventListener("change", () => {
|
|
903
|
+
e.state.renderHost = n.value, y(e.state.renderHost), a(), e.updateThumbnail();
|
|
904
|
+
})), r && (e.state.renderContext || (e.state.renderContext = "preview", b(e.state.renderContext)), r.value = e.state.renderContext || "preview", r.addEventListener("change", () => {
|
|
905
|
+
e.state.renderContext = r.value, b(e.state.renderContext), e.updateThumbnail();
|
|
906
906
|
})), a();
|
|
907
907
|
},
|
|
908
908
|
onActivate(e) {
|
|
@@ -967,39 +967,39 @@ function de() {
|
|
|
967
967
|
}
|
|
968
968
|
};
|
|
969
969
|
}
|
|
970
|
-
var I = "puzzmo_sim_api_mode", L = "http://localhost:8911", R = "https://api.puzzmo.com", z = () => localStorage.getItem(I) === "dev" ? "dev" : "prod",
|
|
970
|
+
var I = "puzzmo_sim_api_mode", L = "http://localhost:8911", R = "https://api.puzzmo.com", z = () => localStorage.getItem(I) === "dev" ? "dev" : "prod", B = (e) => {
|
|
971
971
|
localStorage.setItem(I, e);
|
|
972
|
-
},
|
|
972
|
+
}, V = null, fe = function() {
|
|
973
973
|
var e = t(function* () {
|
|
974
|
-
if (
|
|
974
|
+
if (V !== null) return V;
|
|
975
975
|
try {
|
|
976
976
|
let e = new AbortController(), t = setTimeout(() => e.abort(), 1e3), n = yield fetch(`${L}/healthz`, { signal: e.signal });
|
|
977
|
-
return clearTimeout(t),
|
|
977
|
+
return clearTimeout(t), V = n.ok, V;
|
|
978
978
|
} catch (e) {
|
|
979
|
-
return
|
|
979
|
+
return V = !1, !1;
|
|
980
980
|
}
|
|
981
981
|
});
|
|
982
982
|
return function() {
|
|
983
983
|
return e.apply(this, arguments);
|
|
984
984
|
};
|
|
985
|
-
}(),
|
|
985
|
+
}(), H = () => ({
|
|
986
986
|
apiURL: z() === "dev" ? L : R,
|
|
987
987
|
clientID: "protosdk:oauthclient",
|
|
988
988
|
redirectUri: `${window.location.origin}/oauth/callback`
|
|
989
|
-
}),
|
|
989
|
+
}), pe = () => {
|
|
990
990
|
let e = new Uint8Array(32);
|
|
991
991
|
return crypto.getRandomValues(e), Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
992
|
-
},
|
|
993
|
-
let e = localStorage.getItem(
|
|
992
|
+
}, U = "puzzmo_sim_oauth_token", W = "puzzmo_sim_oauth_refresh_token", me = (e) => localStorage.setItem(U, e), he = (e) => localStorage.setItem(W, e), G = () => {
|
|
993
|
+
let e = localStorage.getItem(U);
|
|
994
994
|
return e && `${e.substring(0, 20)}`, e;
|
|
995
|
-
},
|
|
996
|
-
localStorage.removeItem(
|
|
997
|
-
},
|
|
998
|
-
let e =
|
|
995
|
+
}, K = () => localStorage.getItem(W), q = () => {
|
|
996
|
+
localStorage.removeItem(U), localStorage.removeItem(W);
|
|
997
|
+
}, ge = () => {
|
|
998
|
+
let e = H(), t = pe();
|
|
999
999
|
sessionStorage.setItem("oauth_state", t), sessionStorage.setItem("oauth_return_url", window.location.href);
|
|
1000
1000
|
let n = new URL(`${e.apiURL}/oauth/auth`);
|
|
1001
1001
|
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();
|
|
1002
|
-
},
|
|
1002
|
+
}, _e = (e) => {
|
|
1003
1003
|
try {
|
|
1004
1004
|
let t = e.split(".");
|
|
1005
1005
|
if (t.length !== 3) return !0;
|
|
@@ -1008,11 +1008,11 @@ var I = "puzzmo_sim_api_mode", L = "http://localhost:8911", R = "https://api.puz
|
|
|
1008
1008
|
} catch (e) {
|
|
1009
1009
|
return !0;
|
|
1010
1010
|
}
|
|
1011
|
-
},
|
|
1011
|
+
}, ve = function() {
|
|
1012
1012
|
var e = t(function* () {
|
|
1013
|
-
let e =
|
|
1013
|
+
let e = K();
|
|
1014
1014
|
if (!e) return !1;
|
|
1015
|
-
let t =
|
|
1015
|
+
let t = H();
|
|
1016
1016
|
try {
|
|
1017
1017
|
let n = new URLSearchParams({
|
|
1018
1018
|
grant_type: "refresh_token",
|
|
@@ -1026,9 +1026,9 @@ var I = "puzzmo_sim_api_mode", L = "http://localhost:8911", R = "https://api.puz
|
|
|
1026
1026
|
if (!r.ok) return r.statusText, !1;
|
|
1027
1027
|
let i = yield r.json(), a = i.access_token || i.accessToken;
|
|
1028
1028
|
if (!a) return !1;
|
|
1029
|
-
|
|
1029
|
+
me(a);
|
|
1030
1030
|
let o = i.refresh_token || i.refreshToken;
|
|
1031
|
-
return o &&
|
|
1031
|
+
return o && he(o), !0;
|
|
1032
1032
|
} catch (e) {
|
|
1033
1033
|
return !1;
|
|
1034
1034
|
}
|
|
@@ -1036,9 +1036,9 @@ var I = "puzzmo_sim_api_mode", L = "http://localhost:8911", R = "https://api.puz
|
|
|
1036
1036
|
return function() {
|
|
1037
1037
|
return e.apply(this, arguments);
|
|
1038
1038
|
};
|
|
1039
|
-
}(),
|
|
1039
|
+
}(), ye = function() {
|
|
1040
1040
|
var e = t(function* (e, t) {
|
|
1041
|
-
let n =
|
|
1041
|
+
let n = H(), r = sessionStorage.getItem("oauth_state");
|
|
1042
1042
|
if (!r || r !== t) return null;
|
|
1043
1043
|
sessionStorage.removeItem("oauth_state");
|
|
1044
1044
|
try {
|
|
@@ -1060,13 +1060,13 @@ var I = "puzzmo_sim_api_mode", L = "http://localhost:8911", R = "https://api.puz
|
|
|
1060
1060
|
return function(t, n) {
|
|
1061
1061
|
return e.apply(this, arguments);
|
|
1062
1062
|
};
|
|
1063
|
-
}(),
|
|
1063
|
+
}(), be = function() {
|
|
1064
1064
|
var e = t(function* (e, t = {}) {
|
|
1065
|
-
let n =
|
|
1065
|
+
let n = H(), r = G();
|
|
1066
1066
|
if (!r) throw Error("Not authenticated");
|
|
1067
|
-
if (
|
|
1068
|
-
if (r =
|
|
1069
|
-
} else throw
|
|
1067
|
+
if (_e(r)) if (yield ve()) {
|
|
1068
|
+
if (r = G(), !r) throw Error("Token refresh succeeded but no token available");
|
|
1069
|
+
} else throw q(), Error("Session expired. Please log in again.");
|
|
1070
1070
|
let i = yield fetch(`${n.apiURL}/graphql`, {
|
|
1071
1071
|
method: "POST",
|
|
1072
1072
|
headers: {
|
|
@@ -1085,7 +1085,7 @@ var I = "puzzmo_sim_api_mode", L = "http://localhost:8911", R = "https://api.puz
|
|
|
1085
1085
|
return function(t) {
|
|
1086
1086
|
return e.apply(this, arguments);
|
|
1087
1087
|
};
|
|
1088
|
-
}(),
|
|
1088
|
+
}(), xe = (e) => {
|
|
1089
1089
|
try {
|
|
1090
1090
|
let t = e.split(".");
|
|
1091
1091
|
return t.length, t.length === 3 ? JSON.parse(atob(t[1])) : null;
|
|
@@ -1093,15 +1093,15 @@ var I = "puzzmo_sim_api_mode", L = "http://localhost:8911", R = "https://api.puz
|
|
|
1093
1093
|
return null;
|
|
1094
1094
|
}
|
|
1095
1095
|
};
|
|
1096
|
-
function
|
|
1096
|
+
function Se() {
|
|
1097
1097
|
let e = !1;
|
|
1098
1098
|
return {
|
|
1099
1099
|
id: "auth",
|
|
1100
1100
|
label: "Auth",
|
|
1101
1101
|
render() {
|
|
1102
|
-
let e =
|
|
1102
|
+
let e = G(), t = !!e, n = z(), r = n === "dev" ? L : R, i = `<button class="simulator-btn tiny" id="auth-dev-toggle" style="display: none;">${n === "dev" ? "Using Dev" : "Dev"}</button>`;
|
|
1103
1103
|
if (t) {
|
|
1104
|
-
let t =
|
|
1104
|
+
let t = xe(e), n = t != null && t.exp ? (/* @__PURE__ */ new Date(t.exp * 1e3)).toLocaleString() : "Unknown", a = !!K(), o = a ? xe(K()) : null, s = o != null && o.exp ? (/* @__PURE__ */ new Date(o.exp * 1e3)).toLocaleString() : null;
|
|
1105
1105
|
return `
|
|
1106
1106
|
<div class="simulator-section">
|
|
1107
1107
|
<div class="simulator-section-title auth-title-row">
|
|
@@ -1153,21 +1153,21 @@ function Ce() {
|
|
|
1153
1153
|
},
|
|
1154
1154
|
bind(n) {
|
|
1155
1155
|
let r = n.getElement("#auth-login"), i = n.getElement("#auth-logout"), a = n.getElement("#auth-refresh"), o = n.getElement("#auth-test-api"), s = n.getElement("#auth-api-result"), c = n.getElement("#auth-dev-toggle");
|
|
1156
|
-
e ?
|
|
1156
|
+
e ? V && c && (c.style.display = "", z() === "dev" && c.classList.add("active")) : (e = !0, fe().then((e) => {
|
|
1157
1157
|
e && c && (c.style.display = "", z() === "dev" && c.classList.add("active"));
|
|
1158
1158
|
})), c == null || c.addEventListener("click", () => {
|
|
1159
|
-
|
|
1159
|
+
B(z() === "dev" ? "prod" : "dev"), q(), window.location.reload();
|
|
1160
1160
|
}), r == null || r.addEventListener("click", () => {
|
|
1161
|
-
|
|
1161
|
+
ge();
|
|
1162
1162
|
}), i == null || i.addEventListener("click", () => {
|
|
1163
|
-
|
|
1163
|
+
q(), window.location.reload();
|
|
1164
1164
|
}), a == null || a.addEventListener("click", t(function* () {
|
|
1165
|
-
a.disabled = !0, a.textContent = "Refreshing...", (yield
|
|
1165
|
+
a.disabled = !0, a.textContent = "Refreshing...", (yield ve()) ? window.location.reload() : (a.textContent = "Refresh Failed", a.disabled = !1);
|
|
1166
1166
|
})), o == null || o.addEventListener("click", t(function* () {
|
|
1167
1167
|
if (s) {
|
|
1168
1168
|
s.innerHTML = "<div class=\"loading\">Loading...</div>";
|
|
1169
1169
|
try {
|
|
1170
|
-
let t = yield
|
|
1170
|
+
let t = yield be("\n query {\n currentUser {\n id\n username\n usernameID\n name\n }\n }\n ");
|
|
1171
1171
|
if (t.errors) {
|
|
1172
1172
|
var e;
|
|
1173
1173
|
s.innerHTML = `<div class="error">Error: ${((e = t.errors[0]) == null ? void 0 : e.message) || "Unknown error"}</div>`;
|
|
@@ -1189,13 +1189,13 @@ function Ce() {
|
|
|
1189
1189
|
if (n && r) {
|
|
1190
1190
|
let t = e.getElement("#auth-status");
|
|
1191
1191
|
t && (t.innerHTML = "<span class=\"indicator waiting\"></span><span>Exchanging code...</span>");
|
|
1192
|
-
let i = yield
|
|
1192
|
+
let i = yield ye(n, r);
|
|
1193
1193
|
if (window.history.replaceState({}, "", window.location.pathname), i) {
|
|
1194
1194
|
let e = i.access_token || i.accessToken;
|
|
1195
1195
|
if (e) {
|
|
1196
|
-
|
|
1196
|
+
me(e);
|
|
1197
1197
|
let t = i.refresh_token || i.refreshToken;
|
|
1198
|
-
t &&
|
|
1198
|
+
t && he(t);
|
|
1199
1199
|
}
|
|
1200
1200
|
window.location.reload();
|
|
1201
1201
|
} else {
|
|
@@ -1207,9 +1207,9 @@ function Ce() {
|
|
|
1207
1207
|
}
|
|
1208
1208
|
};
|
|
1209
1209
|
}
|
|
1210
|
-
var
|
|
1211
|
-
localStorage.removeItem(
|
|
1212
|
-
},
|
|
1210
|
+
var Ce = "puzzmo_sim_api_mode", we = "http://localhost:8911", Te = "https://api.puzzmo.com", J = "puzzmo_sim_oauth_token", Y = "puzzmo_sim_oauth_refresh_token", Ee = () => localStorage.getItem(Ce) === "dev" ? "dev" : "prod", X = () => localStorage.getItem(J), De = () => localStorage.getItem(Y), Oe = (e) => localStorage.setItem(J, e), ke = (e) => localStorage.setItem(Y, e), Ae = () => {
|
|
1211
|
+
localStorage.removeItem(J), localStorage.removeItem(Y);
|
|
1212
|
+
}, je = (e) => {
|
|
1213
1213
|
try {
|
|
1214
1214
|
let t = e.split(".");
|
|
1215
1215
|
if (t.length !== 3) return !0;
|
|
@@ -1218,11 +1218,11 @@ var we = "puzzmo_sim_api_mode", Te = "http://localhost:8911", Ee = "https://api.
|
|
|
1218
1218
|
} catch (e) {
|
|
1219
1219
|
return !0;
|
|
1220
1220
|
}
|
|
1221
|
-
},
|
|
1221
|
+
}, Me = function() {
|
|
1222
1222
|
var e = t(function* () {
|
|
1223
|
-
let e =
|
|
1223
|
+
let e = De();
|
|
1224
1224
|
if (!e) return !1;
|
|
1225
|
-
let t =
|
|
1225
|
+
let t = Ee() === "dev" ? we : Te;
|
|
1226
1226
|
try {
|
|
1227
1227
|
let n = new URLSearchParams({
|
|
1228
1228
|
grant_type: "refresh_token",
|
|
@@ -1236,9 +1236,9 @@ var we = "puzzmo_sim_api_mode", Te = "http://localhost:8911", Ee = "https://api.
|
|
|
1236
1236
|
if (!r.ok) return !1;
|
|
1237
1237
|
let i = yield r.json(), a = i.access_token || i.accessToken;
|
|
1238
1238
|
if (!a) return !1;
|
|
1239
|
-
|
|
1239
|
+
Oe(a);
|
|
1240
1240
|
let o = i.refresh_token || i.refreshToken;
|
|
1241
|
-
return o &&
|
|
1241
|
+
return o && ke(o), !0;
|
|
1242
1242
|
} catch (e) {
|
|
1243
1243
|
return !1;
|
|
1244
1244
|
}
|
|
@@ -1246,13 +1246,13 @@ var we = "puzzmo_sim_api_mode", Te = "http://localhost:8911", Ee = "https://api.
|
|
|
1246
1246
|
return function() {
|
|
1247
1247
|
return e.apply(this, arguments);
|
|
1248
1248
|
};
|
|
1249
|
-
}(),
|
|
1249
|
+
}(), Ne = function() {
|
|
1250
1250
|
var e = t(function* (e, t = {}) {
|
|
1251
|
-
let n =
|
|
1251
|
+
let n = Ee() === "dev" ? we : Te, r = X();
|
|
1252
1252
|
if (!r) throw Error("Not authenticated");
|
|
1253
|
-
if (
|
|
1254
|
-
if (r =
|
|
1255
|
-
} else throw
|
|
1253
|
+
if (je(r)) if (yield Me()) {
|
|
1254
|
+
if (r = X(), !r) throw Error("Token refresh succeeded but no token available");
|
|
1255
|
+
} else throw Ae(), Error("Session expired. Please log in again.");
|
|
1256
1256
|
let i = yield fetch(`${n}/graphql`, {
|
|
1257
1257
|
method: "POST",
|
|
1258
1258
|
headers: {
|
|
@@ -1271,19 +1271,19 @@ var we = "puzzmo_sim_api_mode", Te = "http://localhost:8911", Ee = "https://api.
|
|
|
1271
1271
|
return function(t) {
|
|
1272
1272
|
return e.apply(this, arguments);
|
|
1273
1273
|
};
|
|
1274
|
-
}(),
|
|
1274
|
+
}(), Pe = "\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", Fe = "\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", Ie = (e, t) => {
|
|
1275
1275
|
let n = t - 1, r = Math.floor(n / 31), i = n % 31, a = [...e];
|
|
1276
1276
|
for (; a.length <= r;) a.push(0);
|
|
1277
1277
|
return a[r] = a[r] ^ 1 << i, a;
|
|
1278
1278
|
};
|
|
1279
|
-
const
|
|
1280
|
-
function
|
|
1279
|
+
const Le = () => !!X();
|
|
1280
|
+
function Re() {
|
|
1281
1281
|
let n = null, r = !1, i = null, a = function() {
|
|
1282
1282
|
var e = t(function* (e) {
|
|
1283
1283
|
r = !0, i = null;
|
|
1284
1284
|
try {
|
|
1285
1285
|
var t;
|
|
1286
|
-
let r = yield Pe
|
|
1286
|
+
let r = yield Ne(Pe, { slug: e });
|
|
1287
1287
|
if (r.errors) {
|
|
1288
1288
|
var a;
|
|
1289
1289
|
i = ((a = r.errors[0]) == null ? void 0 : a.message) || "Unknown error", n = null;
|
|
@@ -1300,10 +1300,10 @@ function ze() {
|
|
|
1300
1300
|
}(), o = function() {
|
|
1301
1301
|
var r = t(function* (t) {
|
|
1302
1302
|
if (!n) return;
|
|
1303
|
-
let r =
|
|
1303
|
+
let r = Ie(n.featuresArr, t);
|
|
1304
1304
|
try {
|
|
1305
1305
|
var i;
|
|
1306
|
-
let t = yield
|
|
1306
|
+
let t = yield Ne(Fe, {
|
|
1307
1307
|
gameSlug: n.slug,
|
|
1308
1308
|
input: { featuresArr: r }
|
|
1309
1309
|
});
|
|
@@ -1351,7 +1351,7 @@ function ze() {
|
|
|
1351
1351
|
id: "features",
|
|
1352
1352
|
label: "Features",
|
|
1353
1353
|
render() {
|
|
1354
|
-
return
|
|
1354
|
+
return Le() ? `
|
|
1355
1355
|
<div class="features-view-container">
|
|
1356
1356
|
<div class="simulator-section">
|
|
1357
1357
|
<div class="simulator-section-title">Game Features</div>
|
|
@@ -1392,7 +1392,7 @@ function ze() {
|
|
|
1392
1392
|
e && (yield d(e));
|
|
1393
1393
|
})), i == null || i.addEventListener("keypress", (e) => {
|
|
1394
1394
|
e.key === "Enter" && (r == null || r.click());
|
|
1395
|
-
}), console.log("[FeaturesView] bind called, ctx.gameSlug:", e.gameSlug, "slugInput:", i), e.gameSlug && i && (i.value = e.gameSlug,
|
|
1395
|
+
}), console.log("[FeaturesView] bind called, ctx.gameSlug:", e.gameSlug, "slugInput:", i), e.gameSlug && i && (i.value = e.gameSlug, Le() && !n && d(e.gameSlug)), u();
|
|
1396
1396
|
},
|
|
1397
1397
|
onActivate(e) {
|
|
1398
1398
|
let t = e.getElement("#simulator-tab-features");
|
|
@@ -1401,7 +1401,7 @@ function ze() {
|
|
|
1401
1401
|
};
|
|
1402
1402
|
}
|
|
1403
1403
|
/** Renders a single keyboard key as an HTML button string */
|
|
1404
|
-
var
|
|
1404
|
+
var ze = (e, t) => {
|
|
1405
1405
|
var n, r;
|
|
1406
1406
|
let i = (n = t.symbols[e]) == null ? e : n, a = t.disabled.includes(e), o = t.highlight.includes(e), s = t.xl.includes(e), c = t.l.includes(e), l = (r = t.flexGrowSymbols) == null ? void 0 : r.includes(e);
|
|
1407
1407
|
return `<button class="${[
|
|
@@ -1412,9 +1412,9 @@ var Be = (e, t) => {
|
|
|
1412
1412
|
c ? "l" : "",
|
|
1413
1413
|
l ? "grow" : ""
|
|
1414
1414
|
].filter(Boolean).join(" ")}" data-key="${e}" ${a ? "disabled" : ""}>${i}</button>`;
|
|
1415
|
-
},
|
|
1416
|
-
function
|
|
1417
|
-
let e = null, t = () => e ?
|
|
1415
|
+
}, Be = (e) => `<div class="sim-kb">${e.layout.filter((e) => e != null).map((t) => `<div class="sim-kb-row">${[...t].map((t) => ze(t, e)).join("")}</div>`).join("")}</div>`;
|
|
1416
|
+
function Ve() {
|
|
1417
|
+
let e = null, t = () => e ? Be(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>";
|
|
1418
1418
|
return {
|
|
1419
1419
|
id: "kbd",
|
|
1420
1420
|
label: "Kbd",
|
|
@@ -1428,19 +1428,19 @@ function He() {
|
|
|
1428
1428
|
`;
|
|
1429
1429
|
},
|
|
1430
1430
|
bind(e) {
|
|
1431
|
-
|
|
1431
|
+
He(e);
|
|
1432
1432
|
},
|
|
1433
1433
|
onMessage(n, r, i) {
|
|
1434
1434
|
var a;
|
|
1435
1435
|
if (n !== "KEYBOARD_UPDATE_CONFIG") return;
|
|
1436
1436
|
e = !(!(r == null || (a = r.layout) == null) && a.length) || r.layout.every((e) => !e) ? null : r;
|
|
1437
1437
|
let o = i.getElement("#sim-kb-content");
|
|
1438
|
-
o && (o.innerHTML = t(),
|
|
1438
|
+
o && (o.innerHTML = t(), He(i)), i.updateBadge("kbd", void 0);
|
|
1439
1439
|
}
|
|
1440
1440
|
};
|
|
1441
1441
|
}
|
|
1442
1442
|
/** Attach click handlers to all rendered keys */
|
|
1443
|
-
function
|
|
1443
|
+
function He(e) {
|
|
1444
1444
|
var t;
|
|
1445
1445
|
let n = (t = e.getElement("#sim-kb-content")) == null ? void 0 : t.querySelectorAll(".sim-kb-key");
|
|
1446
1446
|
n == null || n.forEach((t) => {
|
|
@@ -1468,10 +1468,14 @@ function Ue() {
|
|
|
1468
1468
|
var i;
|
|
1469
1469
|
let a = t.getElement("#sim-settings-content");
|
|
1470
1470
|
a && (a.querySelectorAll("[data-setting]").forEach((n) => {
|
|
1471
|
-
let i = n.getAttribute("data-setting"),
|
|
1471
|
+
let i = n.getAttribute("data-setting"), o = n.getAttribute("data-setting-type");
|
|
1472
1472
|
n.addEventListener("change", () => {
|
|
1473
|
-
let
|
|
1474
|
-
o
|
|
1473
|
+
let s;
|
|
1474
|
+
if (o === "multiselect") {
|
|
1475
|
+
let e = a.querySelectorAll(`input[data-multiselect="${i}"]`);
|
|
1476
|
+
s = Array.from(e).filter((e) => e.checked).map((e) => e.value);
|
|
1477
|
+
} else s = n instanceof HTMLInputElement && n.type === "checkbox" ? n.checked : o === "number" ? Number(n.value) : n.value;
|
|
1478
|
+
t.state.gameSettings = e(e({}, t.state.gameSettings), {}, { [i]: s }), r(t);
|
|
1475
1479
|
});
|
|
1476
1480
|
}), (i = a.querySelector("#sim-settings-reset")) == null || i.addEventListener("click", () => {
|
|
1477
1481
|
var e;
|
|
@@ -1529,9 +1533,25 @@ function We(e, t) {
|
|
|
1529
1533
|
<select class="simulator-select" data-setting="${e.name}">${i}</select>
|
|
1530
1534
|
</div>`;
|
|
1531
1535
|
}
|
|
1532
|
-
case "
|
|
1536
|
+
case "multiselect": {
|
|
1533
1537
|
var i;
|
|
1534
|
-
let n = (i = t[e.name]) == null ? e.defaultValue : i, r =
|
|
1538
|
+
let n = (i = t[e.name]) == null ? e.defaultValue : i, r = Array.isArray(n) ? n : [], a = e.values.map((t, n) => {
|
|
1539
|
+
var i;
|
|
1540
|
+
return `
|
|
1541
|
+
<label class="sim-settings-row">
|
|
1542
|
+
<input type="checkbox" data-setting="${e.name}" data-setting-type="multiselect" data-multiselect="${e.name}" value="${Q(t)}" ${r.includes(t) ? "checked" : ""} />
|
|
1543
|
+
<span class="simulator-label">${Q((i = e.displays[n]) == null ? t : i)}</span>
|
|
1544
|
+
</label>`;
|
|
1545
|
+
}).join("");
|
|
1546
|
+
return `
|
|
1547
|
+
<div class="simulator-field">
|
|
1548
|
+
${Z(e)}
|
|
1549
|
+
${a}
|
|
1550
|
+
</div>`;
|
|
1551
|
+
}
|
|
1552
|
+
case "number": {
|
|
1553
|
+
var a;
|
|
1554
|
+
let n = (a = t[e.name]) == null ? e.defaultValue : a, r = e.values.map((e) => `<option value="${e}" ${e === n ? "selected" : ""}>${e}</option>`).join("");
|
|
1535
1555
|
return `
|
|
1536
1556
|
<div class="simulator-field">
|
|
1537
1557
|
${Z(e)}
|
|
@@ -1539,8 +1559,8 @@ function We(e, t) {
|
|
|
1539
1559
|
</div>`;
|
|
1540
1560
|
}
|
|
1541
1561
|
case "text": {
|
|
1542
|
-
var
|
|
1543
|
-
let n = String((
|
|
1562
|
+
var o, s;
|
|
1563
|
+
let n = String((o = (s = t[e.name]) == null ? e.defaultValue : s) == null ? "" : o), r = e.textarea ? `<textarea class="simulator-textarea" data-setting="${e.name}">${Q(n)}</textarea>` : `<input class="simulator-input" type="text" data-setting="${e.name}" value="${Q(n)}" />`;
|
|
1544
1564
|
return `
|
|
1545
1565
|
<div class="simulator-field">
|
|
1546
1566
|
${Z(e)}
|
|
@@ -1603,32 +1623,33 @@ var $ = null;
|
|
|
1603
1623
|
* This will show dropdowns in the Ctrl tab to select category and puzzle.
|
|
1604
1624
|
*/
|
|
1605
1625
|
function Ke(e = {}) {
|
|
1606
|
-
var n, r;
|
|
1626
|
+
var n, r, i;
|
|
1607
1627
|
if (console.log("[Simulator] createSimulator called with config:", {
|
|
1608
1628
|
slug: e.slug,
|
|
1609
1629
|
hasFixtures: !!e.fixtures
|
|
1610
1630
|
}), $) return e.fixtures && (console.log("[Simulator] Instance already exists, updating fixtures"), $.updateFixtures(e.fixtures)), $;
|
|
1611
|
-
let
|
|
1631
|
+
let a = (n = e.autoStart) == null ? !0 : n, o = e.fixtures ? re(e.fixtures) : null, s = o ? Array.from(o.keys()).sort() : [], c = se(), l = ue(), d = [
|
|
1612
1632
|
ae(),
|
|
1613
1633
|
oe(),
|
|
1614
|
-
|
|
1634
|
+
c,
|
|
1615
1635
|
ce(),
|
|
1616
1636
|
le(),
|
|
1617
|
-
|
|
1637
|
+
l,
|
|
1618
1638
|
de(),
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
Ue()
|
|
1623
|
-
|
|
1639
|
+
Se(),
|
|
1640
|
+
Re(),
|
|
1641
|
+
Ve(),
|
|
1642
|
+
Ue(),
|
|
1643
|
+
...(r = e.views) == null ? [] : r
|
|
1644
|
+
], f = d.map((e) => e.id), h = u(e, s, f), g = {
|
|
1624
1645
|
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>",
|
|
1625
1646
|
play: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><polygon points=\"2,1 9,5 2,9\"/></svg>",
|
|
1626
1647
|
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>",
|
|
1627
1648
|
cog: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><path d=\"M9.5 5.8l-.8-.5c0-.2.1-.5.1-.8s0-.5-.1-.8l.8-.5c.1-.1.2-.2.1-.4l-.8-1.4c-.1-.1-.2-.2-.4-.1l-1 .3c-.3-.3-.7-.5-1.1-.6L6.1.2C6.1.1 6 0 5.8 0H4.2c-.2 0-.3.1-.3.2l-.2 1c-.4.1-.7.3-1.1.6l-1-.3c-.2 0-.3 0-.4.1l-.8 1.4c-.1.2 0 .3.1.4l.8.5c0 .2-.1.5-.1.8s0 .5.1.8l-.8.5c-.1.1-.2.2-.1.4l.8 1.4c.1.1.2.2.4.1l1-.3c.3.3.7.5 1.1.6l.2 1c0 .1.1.2.3.2h1.6c.2 0 .3-.1.3-.2l.2-1c.4-.1.7-.3 1.1-.6l1 .3c.2 0 .3 0 .4-.1l.8-1.4c.1-.2 0-.3-.1-.4zM5 6.5c-.8 0-1.5-.7-1.5-1.5S4.2 3.5 5 3.5 6.5 4.2 6.5 5 5.8 6.5 5 6.5z\"/></svg>",
|
|
1628
1649
|
minimize: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><rect x=\"1\" y=\"4\" width=\"8\" height=\"2\"/></svg>",
|
|
1629
1650
|
expand: "<svg width=\"8\" height=\"8\" viewBox=\"0 0 8 8\" fill=\"currentColor\"><polygon points=\"1,1 7,4 1,7\"/></svg>"
|
|
1630
|
-
},
|
|
1631
|
-
|
|
1651
|
+
}, _ = document.createElement("div");
|
|
1652
|
+
_.id = "simulator", _.innerHTML = `
|
|
1632
1653
|
<style>
|
|
1633
1654
|
:root {
|
|
1634
1655
|
--sim-bg: #1a1a2e;
|
|
@@ -2865,15 +2886,15 @@ function Ke(e = {}) {
|
|
|
2865
2886
|
border-top: 2px solid var(--sim-border);
|
|
2866
2887
|
}
|
|
2867
2888
|
</style>
|
|
2868
|
-
<div id="simulator-panel" class="${
|
|
2889
|
+
<div id="simulator-panel" class="${h.isCollapsed ? "collapsed" : ""}">
|
|
2869
2890
|
<div id="simulator-header">
|
|
2870
2891
|
<span id="simulator-title">PUZZMO SIMULATOR</span>
|
|
2871
2892
|
<span class="header-sep">|</span>
|
|
2872
2893
|
<div id="simulator-timer">--:--</div>
|
|
2873
2894
|
<span class="header-sep">|</span>
|
|
2874
2895
|
<div id="simulator-header-controls">
|
|
2875
|
-
<button id="simulator-header-pause" class="header-icon-btn" title="Pause" disabled>${
|
|
2876
|
-
<button id="simulator-header-retry" class="header-icon-btn" title="Retry" disabled>${
|
|
2896
|
+
<button id="simulator-header-pause" class="header-icon-btn" title="Pause" disabled>${g.pause}</button>
|
|
2897
|
+
<button id="simulator-header-retry" class="header-icon-btn" title="Retry" disabled>${g.retry}</button>
|
|
2877
2898
|
</div>
|
|
2878
2899
|
<span class="header-sep">|</span>
|
|
2879
2900
|
<div id="simulator-header-status">
|
|
@@ -2881,106 +2902,106 @@ function Ke(e = {}) {
|
|
|
2881
2902
|
<span id="simulator-header-status-text">Waiting...</span>
|
|
2882
2903
|
</div>
|
|
2883
2904
|
<span class="header-spacer"></span>
|
|
2884
|
-
<button id="simulator-header-settings" class="header-icon-btn" title="Settings">${
|
|
2885
|
-
<button id="simulator-toggle" class="header-icon-btn" title="Minimize">${
|
|
2905
|
+
<button id="simulator-header-settings" class="header-icon-btn" title="Settings">${g.cog}</button>
|
|
2906
|
+
<button id="simulator-toggle" class="header-icon-btn" title="Minimize">${g.minimize}</button>
|
|
2886
2907
|
</div>
|
|
2887
2908
|
<div id="simulator-body">
|
|
2888
2909
|
<div id="simulator-tabs">
|
|
2889
|
-
${
|
|
2910
|
+
${d.filter((e) => e.id !== "auth").map((e) => `<button class="simulator-tab" data-tab="${e.id}">${e.label}<span class="simulator-tab-badge" data-badge="${e.id}"></span></button>`).join("")}
|
|
2890
2911
|
</div>
|
|
2891
2912
|
<div id="simulator-content" class="hidden">
|
|
2892
|
-
${
|
|
2913
|
+
${d.map((e) => `<div id="simulator-tab-${e.id}" class="simulator-tab-content">${e.render()}</div>`).join("")}
|
|
2893
2914
|
</div>
|
|
2894
2915
|
</div>
|
|
2895
2916
|
</div>
|
|
2896
|
-
`, document.body.appendChild(
|
|
2897
|
-
let
|
|
2898
|
-
|
|
2899
|
-
}, k = (e, t) => {
|
|
2900
|
-
let n = D("#simulator-status .text"), r = D("#simulator-status .indicator"), i = t === "complete" ? "✓" : "";
|
|
2901
|
-
n && (n.textContent = e), r && (r.className = `indicator ${t}`, r.textContent = i), v.className = t, v.textContent = i, y.textContent = e;
|
|
2917
|
+
`, document.body.appendChild(_);
|
|
2918
|
+
let v = _.querySelector("#simulator-panel"), y = _.querySelector("#simulator-header"), b = _.querySelector("#simulator-header-indicator"), ie = _.querySelector("#simulator-header-status-text"), x = _.querySelector("#simulator-header-pause"), S = _.querySelector("#simulator-header-retry"), C = _.querySelector("#simulator-header-settings"), w = _.querySelector("#simulator-toggle"), T = _.querySelector("#simulator-timer"), E = _.querySelector("#simulator-tabs"), D = _.querySelector("#simulator-content"), O = (e) => _.querySelector(e), k = (e) => {
|
|
2919
|
+
x.innerHTML = e ? g.play : g.pause, x.title = e ? "Resume" : "Pause";
|
|
2902
2920
|
}, A = (e, t) => {
|
|
2903
|
-
|
|
2904
|
-
|
|
2921
|
+
let n = O("#simulator-status .text"), r = O("#simulator-status .indicator"), i = t === "complete" ? "✓" : "";
|
|
2922
|
+
n && (n.textContent = e), r && (r.className = `indicator ${t}`, r.textContent = i), b.className = t, b.textContent = i, ie.textContent = e;
|
|
2923
|
+
}, j = (e, t) => {
|
|
2924
|
+
t && t !== "0" ? T.innerHTML = `${e}<span class="penalty">+${t}</span>` : T.textContent = e;
|
|
2925
|
+
}, M = (e) => {
|
|
2905
2926
|
var t;
|
|
2906
|
-
|
|
2927
|
+
h.activeTab = e, D.classList.remove("hidden"), m(e), E.querySelectorAll(".simulator-tab").forEach((t) => {
|
|
2907
2928
|
t.classList.toggle("active", t.getAttribute("data-tab") === e);
|
|
2908
|
-
}),
|
|
2929
|
+
}), _.querySelectorAll(".simulator-tab-content").forEach((t) => {
|
|
2909
2930
|
t.classList.toggle("active", t.id === `simulator-tab-${e}`);
|
|
2910
|
-
}),
|
|
2911
|
-
let n =
|
|
2912
|
-
n == null || (t = n.onActivate) == null || t.call(n,
|
|
2913
|
-
},
|
|
2914
|
-
|
|
2915
|
-
},
|
|
2916
|
-
|
|
2917
|
-
},
|
|
2931
|
+
}), C.classList.toggle("active", e === "auth");
|
|
2932
|
+
let n = d.find((t) => t.id === e);
|
|
2933
|
+
n == null || (t = n.onActivate) == null || t.call(n, z);
|
|
2934
|
+
}, N = (e) => {
|
|
2935
|
+
h.isCollapsed = e, v.classList.toggle("collapsed", e), p(e), e ? (D.classList.add("hidden"), E.querySelectorAll(".simulator-tab").forEach((e) => e.classList.remove("active"))) : M(h.activeTab);
|
|
2936
|
+
}, P = () => {
|
|
2937
|
+
l.updatePreview(z);
|
|
2938
|
+
}, F = function() {
|
|
2918
2939
|
var e = t(function* () {
|
|
2919
2940
|
var e, t;
|
|
2920
|
-
if (
|
|
2921
|
-
if (!
|
|
2922
|
-
let n = (e =
|
|
2941
|
+
if (h.puzzleData) return h.puzzleData;
|
|
2942
|
+
if (!o || o.size === 0) throw Error("No fixtures configured. Add puzzle fixture files (.json or .toml) to a fixtures directory and pass fixturesGlob to the simulator.");
|
|
2943
|
+
let n = (e = h.selectedCategory) == null ? s[0] : e, r = n ? o.get(n) : void 0;
|
|
2923
2944
|
if (!r || r.size === 0) throw Error(`No puzzles found in fixture category "${n}"`);
|
|
2924
|
-
let i = (t =
|
|
2925
|
-
if (!
|
|
2926
|
-
|
|
2945
|
+
let i = (t = h.selectedPuzzle) == null ? r.keys().next().value : t, a = i ? r.get(i) : void 0;
|
|
2946
|
+
if (!a) throw Error(`Puzzle "${i}" not found in category "${n}"`);
|
|
2947
|
+
h.puzzleData = a, console.log("Simulator: Puzzle loaded from fixtures", {
|
|
2927
2948
|
category: n,
|
|
2928
2949
|
puzzle: i
|
|
2929
|
-
}),
|
|
2930
|
-
let c =
|
|
2931
|
-
return c && (c.value =
|
|
2950
|
+
}), h.originalPuzzle = a;
|
|
2951
|
+
let c = O("#simulator-puzzle");
|
|
2952
|
+
return c && (c.value = h.originalPuzzle), h.activeTab === "thumb" && P(), h.puzzleData;
|
|
2932
2953
|
});
|
|
2933
2954
|
return function() {
|
|
2934
2955
|
return e.apply(this, arguments);
|
|
2935
2956
|
};
|
|
2936
|
-
}(),
|
|
2937
|
-
|
|
2938
|
-
}),
|
|
2939
|
-
|
|
2940
|
-
},
|
|
2941
|
-
let n =
|
|
2957
|
+
}(), I = ee((e) => {
|
|
2958
|
+
c.addLogEntry(e, z);
|
|
2959
|
+
}), L = (e, t) => {
|
|
2960
|
+
te(e, t, I);
|
|
2961
|
+
}, R = (e, t) => {
|
|
2962
|
+
let n = _.querySelector(`[data-badge="${e}"]`);
|
|
2942
2963
|
n && (n.textContent = t && t > 0 ? String(t) : "");
|
|
2943
|
-
},
|
|
2944
|
-
state:
|
|
2945
|
-
getElement:
|
|
2946
|
-
sendToGame:
|
|
2947
|
-
logMessage:
|
|
2948
|
-
loadPuzzle:
|
|
2949
|
-
updateStatus:
|
|
2950
|
-
updateTimer:
|
|
2951
|
-
setCollapsed:
|
|
2952
|
-
switchTab:
|
|
2953
|
-
updateThumbnail:
|
|
2954
|
-
updateBadge:
|
|
2955
|
-
fixtures:
|
|
2956
|
-
fixtureCategories:
|
|
2957
|
-
gameSlug: (
|
|
2964
|
+
}, z = {
|
|
2965
|
+
state: h,
|
|
2966
|
+
getElement: O,
|
|
2967
|
+
sendToGame: L,
|
|
2968
|
+
logMessage: I.log,
|
|
2969
|
+
loadPuzzle: F,
|
|
2970
|
+
updateStatus: A,
|
|
2971
|
+
updateTimer: j,
|
|
2972
|
+
setCollapsed: N,
|
|
2973
|
+
switchTab: M,
|
|
2974
|
+
updateThumbnail: P,
|
|
2975
|
+
updateBadge: R,
|
|
2976
|
+
fixtures: o,
|
|
2977
|
+
fixtureCategories: s,
|
|
2978
|
+
gameSlug: (i = e.slug) == null ? null : i
|
|
2958
2979
|
};
|
|
2959
|
-
console.log("[Simulator] Context created with gameSlug:",
|
|
2980
|
+
console.log("[Simulator] Context created with gameSlug:", z.gameSlug), d.forEach((e) => e.bind(z)), E.querySelectorAll(".simulator-tab").forEach((e) => {
|
|
2960
2981
|
e.addEventListener("click", () => {
|
|
2961
2982
|
let t = e.getAttribute("data-tab");
|
|
2962
|
-
|
|
2983
|
+
M(t), R(t, 0);
|
|
2963
2984
|
});
|
|
2964
|
-
}),
|
|
2965
|
-
e.stopPropagation(),
|
|
2966
|
-
}), b.addEventListener("click", (e) => {
|
|
2967
|
-
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"));
|
|
2968
|
-
let t = D("#simulator-pause");
|
|
2969
|
-
t && (t.textContent = f.isPaused ? "Resume" : "Pause");
|
|
2985
|
+
}), w.addEventListener("click", (e) => {
|
|
2986
|
+
e.stopPropagation(), N(!0);
|
|
2970
2987
|
}), x.addEventListener("click", (e) => {
|
|
2971
|
-
e.stopPropagation(),
|
|
2972
|
-
let t =
|
|
2973
|
-
t && (t.
|
|
2988
|
+
e.stopPropagation(), h.isPaused ? (L("RESUME_GAME", {}), h.isPaused = !1, k(!1), A("Running", "ready")) : (L("PAUSE_GAME", {}), h.isPaused = !0, k(!0), A("Paused", "paused"));
|
|
2989
|
+
let t = O("#simulator-pause");
|
|
2990
|
+
t && (t.textContent = h.isPaused ? "Resume" : "Pause");
|
|
2974
2991
|
}), S.addEventListener("click", (e) => {
|
|
2975
|
-
e.stopPropagation(),
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
}),
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2992
|
+
e.stopPropagation(), L("RETRY_PUZZLE", {}), h.hasStarted = !1, h.isPaused = !1, k(!1), x.disabled = !0, A("Ready to retry", "ready");
|
|
2993
|
+
let t = O("#simulator-pause"), n = O("#simulator-start");
|
|
2994
|
+
t && (t.disabled = !0, t.textContent = "Pause"), n && (n.textContent = "Start");
|
|
2995
|
+
}), C.addEventListener("click", (e) => {
|
|
2996
|
+
e.stopPropagation(), h.isCollapsed && N(!1), M("auth");
|
|
2997
|
+
}), y.addEventListener("click", (e) => {
|
|
2998
|
+
h.isCollapsed && e.target !== w && N(!1);
|
|
2999
|
+
}), h.isCollapsed || M(h.activeTab);
|
|
3000
|
+
let B = new URLSearchParams(window.location.search);
|
|
3001
|
+
(B.has("code") || B.has("error")) && (N(!1), M("auth"));
|
|
3002
|
+
let V = (e) => ({
|
|
2982
3003
|
userState: {
|
|
2983
|
-
gameSettings:
|
|
3004
|
+
gameSettings: h.gameSettings,
|
|
2984
3005
|
id: "simulator-user",
|
|
2985
3006
|
ownerID: "simulator-owner"
|
|
2986
3007
|
},
|
|
@@ -2995,7 +3016,7 @@ function Ke(e = {}) {
|
|
|
2995
3016
|
},
|
|
2996
3017
|
startOrFindGameplay: { gamePlayed: {
|
|
2997
3018
|
additionalTimeAddedSecs: 0,
|
|
2998
|
-
boardState:
|
|
3019
|
+
boardState: h.currentInputStr,
|
|
2999
3020
|
combinedTimeSecs: 0,
|
|
3000
3021
|
completed: !1,
|
|
3001
3022
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -3017,49 +3038,49 @@ function Ke(e = {}) {
|
|
|
3017
3038
|
mostRecentDaily: null
|
|
3018
3039
|
}
|
|
3019
3040
|
} },
|
|
3020
|
-
theme:
|
|
3041
|
+
theme: h.selectedTheme,
|
|
3021
3042
|
hostContext: [{
|
|
3022
3043
|
type: "app",
|
|
3023
3044
|
layout: "desktop",
|
|
3024
3045
|
host: null
|
|
3025
3046
|
}],
|
|
3026
3047
|
appRuntimeContract: "1.0"
|
|
3027
|
-
}),
|
|
3048
|
+
}), fe = function() {
|
|
3028
3049
|
var e = t(function* () {
|
|
3029
|
-
|
|
3050
|
+
A("Loading puzzle...", "waiting");
|
|
3030
3051
|
try {
|
|
3031
|
-
let e =
|
|
3032
|
-
|
|
3052
|
+
let e = V(yield F());
|
|
3053
|
+
A("Sending READY_DATA...", "waiting"), L("READY_DATA", e), A("Waiting for game to load...", "waiting");
|
|
3033
3054
|
} catch (e) {
|
|
3034
|
-
|
|
3055
|
+
A(`Error: ${e}`, "paused");
|
|
3035
3056
|
}
|
|
3036
3057
|
});
|
|
3037
3058
|
return function() {
|
|
3038
3059
|
return e.apply(this, arguments);
|
|
3039
3060
|
};
|
|
3040
|
-
}(),
|
|
3041
|
-
console.log("Simulator: Game loaded, ready to start"),
|
|
3061
|
+
}(), H = () => {
|
|
3062
|
+
console.log("Simulator: Game loaded, ready to start"), S.disabled = !1, d.forEach((e) => {
|
|
3042
3063
|
var t;
|
|
3043
|
-
return (t = e.onMessage) == null ? void 0 : t.call(e, "READY_GAME_LOADED", void 0,
|
|
3044
|
-
}),
|
|
3045
|
-
let e =
|
|
3046
|
-
e == null || e.click(),
|
|
3064
|
+
return (t = e.onMessage) == null ? void 0 : t.call(e, "READY_GAME_LOADED", void 0, z);
|
|
3065
|
+
}), a && !h.hasStarted && setTimeout(() => {
|
|
3066
|
+
let e = O("#simulator-start");
|
|
3067
|
+
e == null || e.click(), x.disabled = !1, h.hasStarted = !0, A("Running", "ready");
|
|
3047
3068
|
}, 100);
|
|
3048
3069
|
};
|
|
3049
|
-
return
|
|
3070
|
+
return ne((e, t) => {
|
|
3050
3071
|
var n, r;
|
|
3051
3072
|
if (e === "READY") {
|
|
3052
|
-
console.log("Simulator: Received READY from game"),
|
|
3073
|
+
console.log("Simulator: Received READY from game"), fe();
|
|
3053
3074
|
return;
|
|
3054
3075
|
}
|
|
3055
3076
|
if (e === "READY_GAME_LOADED") {
|
|
3056
|
-
|
|
3077
|
+
H();
|
|
3057
3078
|
return;
|
|
3058
3079
|
}
|
|
3059
3080
|
if (e === "TIMER_TICK") {
|
|
3060
3081
|
if (t != null && t.display) {
|
|
3061
3082
|
let [e, n] = t.display;
|
|
3062
|
-
|
|
3083
|
+
j(e, n);
|
|
3063
3084
|
}
|
|
3064
3085
|
return;
|
|
3065
3086
|
}
|
|
@@ -3068,30 +3089,30 @@ function Ke(e = {}) {
|
|
|
3068
3089
|
console.log("Simulator: Sidebar update", t);
|
|
3069
3090
|
return;
|
|
3070
3091
|
}
|
|
3071
|
-
|
|
3092
|
+
d.forEach((n) => {
|
|
3072
3093
|
var r;
|
|
3073
|
-
return (r = n.onMessage) == null ? void 0 : r.call(n, e, t,
|
|
3094
|
+
return (r = n.onMessage) == null ? void 0 : r.call(n, e, t, z);
|
|
3074
3095
|
});
|
|
3075
3096
|
let i = (n = t == null || (r = t.input) == null ? void 0 : r.boardState) == null ? t == null ? void 0 : t.boardState : n;
|
|
3076
|
-
e === "UPLOAD_NEW_GAME_STATE" && i && (
|
|
3077
|
-
},
|
|
3097
|
+
e === "UPLOAD_NEW_GAME_STATE" && i && (h.currentInputStr = i, h.activeTab === "thumb" && P(), console.log("Simulator: Game state uploaded", t)), e === "GAME_COMPLETED" && (console.log("Simulator: Game completed!", t), x.disabled = !0, h.hasStarted = !1, A("Completed!", "complete"));
|
|
3098
|
+
}, I), console.log("Simulator initialized"), $ = {
|
|
3078
3099
|
updateFixtures: (e) => {
|
|
3079
|
-
|
|
3100
|
+
o = re(e), s = Array.from(o.keys()).sort(), z.fixtures = o, z.fixtureCategories = s;
|
|
3080
3101
|
let t = localStorage.getItem("simulator-fixture-category");
|
|
3081
|
-
if (!
|
|
3102
|
+
if (!h.selectedCategory || !s.includes(h.selectedCategory)) {
|
|
3082
3103
|
var n;
|
|
3083
|
-
|
|
3104
|
+
h.selectedCategory = t && s.includes(t) ? t : (n = s[0]) == null ? null : n;
|
|
3084
3105
|
}
|
|
3085
|
-
let r =
|
|
3086
|
-
r == null || r.bind(
|
|
3087
|
-
categories:
|
|
3088
|
-
selectedCategory:
|
|
3106
|
+
let r = d.find((e) => e.id === "ctrl");
|
|
3107
|
+
r == null || r.bind(z), console.log("Simulator: Fixtures updated", {
|
|
3108
|
+
categories: s,
|
|
3109
|
+
selectedCategory: h.selectedCategory
|
|
3089
3110
|
});
|
|
3090
3111
|
},
|
|
3091
|
-
sendToGame:
|
|
3092
|
-
loadPuzzle:
|
|
3112
|
+
sendToGame: L,
|
|
3113
|
+
loadPuzzle: F
|
|
3093
3114
|
}, $;
|
|
3094
3115
|
}
|
|
3095
3116
|
export { Ke as t };
|
|
3096
3117
|
|
|
3097
|
-
//# sourceMappingURL=createSimulator-
|
|
3118
|
+
//# sourceMappingURL=createSimulator-COj3lAeu.js.map
|