@puzzmo/sdk 1.0.61 → 1.0.63
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/{createSimulator-PNeBoNux.cjs → createSimulator-CJ8LJCe4.cjs} +190 -40
- package/dist/createSimulator-CJ8LJCe4.cjs.map +1 -0
- package/dist/{createSimulator-CdInpCHG.js → createSimulator-DqxQK61P.js} +572 -297
- package/dist/createSimulator-DqxQK61P.js.map +1 -0
- package/dist/{lua-C3M-mB0u.js → lua-DKb2Tu2V.js} +2 -2
- package/dist/{lua-C3M-mB0u.js.map → lua-DKb2Tu2V.js.map} +1 -1
- package/dist/{lua-D5xtGGen.cjs → lua-QeU9Rzet.cjs} +2 -2
- package/dist/{lua-D5xtGGen.cjs.map → lua-QeU9Rzet.cjs.map} +1 -1
- package/dist/pico8/index.cjs +1 -1
- package/dist/pico8/index.js +1 -1
- package/dist/pico8/lua.d.ts +1 -1
- package/dist/simulator/checklistProgress.d.ts +23 -0
- package/dist/simulator/checklistProgress.d.ts.map +1 -0
- package/dist/simulator/checklistProgress.spec.d.ts +2 -0
- package/dist/simulator/checklistProgress.spec.d.ts.map +1 -0
- package/dist/simulator/createSimulator.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/styles.d.ts +1 -1
- package/dist/simulator/styles.d.ts.map +1 -1
- package/dist/simulator/types.d.ts +25 -0
- package/dist/simulator/types.d.ts.map +1 -1
- package/dist/simulator/views/ChecklistView.d.ts +4 -0
- package/dist/simulator/views/ChecklistView.d.ts.map +1 -0
- package/dist/simulator/views/index.d.ts +1 -0
- package/dist/simulator/views/index.d.ts.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/vite.cjs +3 -3
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.ts +3 -1
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +18 -5
- package/dist/vite.js.map +1 -1
- package/package.json +1 -1
- package/dist/createSimulator-CdInpCHG.js.map +0 -1
- package/dist/createSimulator-PNeBoNux.cjs.map +0 -1
|
@@ -561,7 +561,7 @@ function j(e, t) {
|
|
|
561
561
|
`;
|
|
562
562
|
}
|
|
563
563
|
/** Update puzzle select options based on selected category */
|
|
564
|
-
function
|
|
564
|
+
function se(e, t, n, r) {
|
|
565
565
|
let i = t.get(n);
|
|
566
566
|
if (!i) return null;
|
|
567
567
|
let a = Array.from(i.keys()), o = r;
|
|
@@ -572,7 +572,7 @@ function M(e, t, n, r) {
|
|
|
572
572
|
return e.innerHTML = a.map((e) => `<option value="${e}" ${e === o ? "selected" : ""}>${e}</option>`).join(""), o;
|
|
573
573
|
}
|
|
574
574
|
/** Get puzzle data from fixtures */
|
|
575
|
-
function
|
|
575
|
+
function M(e, t, n) {
|
|
576
576
|
var r, i;
|
|
577
577
|
return !t || !n || (r = (i = e.get(t)) == null ? void 0 : i.get(n)) == null ? null : r;
|
|
578
578
|
}
|
|
@@ -584,8 +584,8 @@ function N(e, t, n) {
|
|
|
584
584
|
* `puzzmo games validate` greps build output for it — keep it in sync with the copy in
|
|
585
585
|
* packages/cli/src/util/lintDist.ts.
|
|
586
586
|
*/
|
|
587
|
-
const
|
|
588
|
-
function
|
|
587
|
+
const ce = "puzzmo-simulator-dev-only-do-not-ship";
|
|
588
|
+
function le() {
|
|
589
589
|
return {
|
|
590
590
|
id: "ctrl",
|
|
591
591
|
label: "Ctrl",
|
|
@@ -603,8 +603,8 @@ function ce() {
|
|
|
603
603
|
i.innerHTML = j(e.fixtureCategories, e.state.selectedCategory);
|
|
604
604
|
let t = e.getElement("#simulator-fixture-category"), n = e.getElement("#simulator-fixture-puzzle");
|
|
605
605
|
if (t && n && e.state.selectedCategory) {
|
|
606
|
-
e.state.selectedPuzzle =
|
|
607
|
-
let r =
|
|
606
|
+
e.state.selectedPuzzle = se(n, e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
|
|
607
|
+
let r = M(e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
|
|
608
608
|
console.log("Simulator: Loading fixture puzzle", {
|
|
609
609
|
category: e.state.selectedCategory,
|
|
610
610
|
puzzle: e.state.selectedPuzzle,
|
|
@@ -638,10 +638,10 @@ function ce() {
|
|
|
638
638
|
* Inlined here (rather than shared with the rest of the monorepo) because the SDK ships to OSS and
|
|
639
639
|
* must stay self-contained.
|
|
640
640
|
*/
|
|
641
|
-
function
|
|
641
|
+
function N(e) {
|
|
642
642
|
var t;
|
|
643
643
|
if (typeof e != "string") return e;
|
|
644
|
-
let n = (t =
|
|
644
|
+
let n = (t = P(e)) == null ? {
|
|
645
645
|
width: 800,
|
|
646
646
|
height: 800
|
|
647
647
|
} : t;
|
|
@@ -652,7 +652,7 @@ function P(e) {
|
|
|
652
652
|
};
|
|
653
653
|
}
|
|
654
654
|
/** Reads an SVG's intrinsic size from its `viewBox` (preferred) or its `width`/`height` attributes. */
|
|
655
|
-
function
|
|
655
|
+
function P(e) {
|
|
656
656
|
var t, n, r, i;
|
|
657
657
|
let a = e.indexOf("<svg");
|
|
658
658
|
if (a === -1) return;
|
|
@@ -670,9 +670,9 @@ function F(e) {
|
|
|
670
670
|
height: u
|
|
671
671
|
};
|
|
672
672
|
}
|
|
673
|
-
var
|
|
673
|
+
var F = "simulator-saved-states";
|
|
674
674
|
/** Find thumbnail function on globalThis (looks for functions ending in "Thumbnail") */
|
|
675
|
-
function
|
|
675
|
+
function I() {
|
|
676
676
|
let e = globalThis;
|
|
677
677
|
for (let t of Object.keys(e)) if (t.endsWith("Thumbnail") && typeof e[t] == "function") return {
|
|
678
678
|
name: t,
|
|
@@ -681,8 +681,8 @@ function L() {
|
|
|
681
681
|
return null;
|
|
682
682
|
}
|
|
683
683
|
/** Generate a small thumbnail SVG for a given input string */
|
|
684
|
-
function
|
|
685
|
-
let n =
|
|
684
|
+
function L(e, t) {
|
|
685
|
+
let n = I();
|
|
686
686
|
if (!n) return "";
|
|
687
687
|
try {
|
|
688
688
|
var r;
|
|
@@ -692,19 +692,19 @@ function R(e, t) {
|
|
|
692
692
|
strict: !0,
|
|
693
693
|
renderHost: "game"
|
|
694
694
|
};
|
|
695
|
-
return
|
|
695
|
+
return N(n.fn(i, t, a)).svg;
|
|
696
696
|
} catch (e) {
|
|
697
697
|
return "";
|
|
698
698
|
}
|
|
699
699
|
}
|
|
700
|
-
var
|
|
701
|
-
function
|
|
700
|
+
var R = [];
|
|
701
|
+
function z(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 ue() {
|
|
708
708
|
let e = "", t = "";
|
|
709
709
|
return {
|
|
710
710
|
id: "data",
|
|
@@ -722,18 +722,18 @@ function le() {
|
|
|
722
722
|
let i = n.getElement(".data-view-container");
|
|
723
723
|
i == null || i.querySelectorAll(".data-subtab-content").forEach((e) => {
|
|
724
724
|
e.classList.toggle("active", e.id === `data-subtab-${t}`);
|
|
725
|
-
}), t === "edit" ?
|
|
725
|
+
}), t === "edit" ? fe(n) : t === "history" ? V(n) : t === "saves" && H(n);
|
|
726
726
|
});
|
|
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, z(i)), a && n.state.currentInputStr && document.activeElement !== a && (a.value = n.state.currentInputStr, t = n.state.currentInputStr, z(a)), pe(n);
|
|
731
731
|
}, 0), i == null || i.addEventListener("input", () => {
|
|
732
|
-
|
|
732
|
+
z(i);
|
|
733
733
|
let t = i.value !== e;
|
|
734
734
|
l && (l.disabled = !t);
|
|
735
735
|
}), a == null || a.addEventListener("input", () => {
|
|
736
|
-
|
|
736
|
+
z(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, z(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, z(a), d && (d.disabled = !0));
|
|
759
759
|
}), d == null || d.addEventListener("click", () => {
|
|
760
760
|
if (a) {
|
|
761
761
|
if (!s("input", a.value)) {
|
|
@@ -767,87 +767,87 @@ function le() {
|
|
|
767
767
|
});
|
|
768
768
|
let f = n.getElement("#simulator-history-clear");
|
|
769
769
|
f == null || f.addEventListener("click", () => {
|
|
770
|
-
|
|
770
|
+
R = [], V(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 = B(), t = {
|
|
776
776
|
name: p.value.trim(),
|
|
777
777
|
puzzleStr: n.state.originalPuzzle,
|
|
778
778
|
inputStr: n.state.currentInputStr,
|
|
779
779
|
timestamp: Date.now()
|
|
780
780
|
};
|
|
781
|
-
e.push(t), localStorage.setItem(
|
|
782
|
-
}),
|
|
781
|
+
e.push(t), localStorage.setItem(F, JSON.stringify(e)), p.value = "", H(n);
|
|
782
|
+
}), H(n);
|
|
783
783
|
},
|
|
784
784
|
onActivate(n) {
|
|
785
|
-
e = n.state.originalPuzzle, t = n.state.currentInputStr,
|
|
785
|
+
e = n.state.originalPuzzle, t = n.state.currentInputStr, fe(n), V(n);
|
|
786
786
|
},
|
|
787
787
|
onMessage(e, n, r) {
|
|
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, R.length === 0 || R[R.length - 1].value !== c) {
|
|
792
|
+
R.push({
|
|
793
793
|
value: c,
|
|
794
794
|
timestamp: Date.now()
|
|
795
|
-
}),
|
|
795
|
+
}), R.length > 100 && (R = R.slice(-100));
|
|
796
796
|
let e = r.getElement("#data-subtab-history");
|
|
797
|
-
e != null && e.classList.contains("active") &&
|
|
797
|
+
e != null && e.classList.contains("active") && V(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, z(o)), t = c, s && (s.disabled = !0));
|
|
800
800
|
}
|
|
801
801
|
}
|
|
802
802
|
};
|
|
803
803
|
}
|
|
804
|
-
function
|
|
804
|
+
function B() {
|
|
805
805
|
try {
|
|
806
|
-
let e = localStorage.getItem(
|
|
806
|
+
let e = localStorage.getItem(F);
|
|
807
807
|
return e ? JSON.parse(e) : [];
|
|
808
808
|
} catch (e) {
|
|
809
809
|
return [];
|
|
810
810
|
}
|
|
811
811
|
}
|
|
812
|
-
function
|
|
812
|
+
function V(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), R.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 = [...R].reverse().map((t, n) => {
|
|
820
|
+
let r = R.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">${L(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>
|
|
827
827
|
<span class="history-item-time">${i}</span>
|
|
828
828
|
<button class="simulator-btn tiny history-restore-btn" data-history-idx="${r}">Restore</button>
|
|
829
829
|
</div>
|
|
830
|
-
<div class="history-item-preview">${
|
|
830
|
+
<div class="history-item-preview">${de(a)}</div>
|
|
831
831
|
</div>
|
|
832
832
|
</div>
|
|
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 = R[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, z(n)), i && (i.disabled = !1), e.updateStatus("Input restored — press Apply to load it", "ready");
|
|
842
842
|
}
|
|
843
843
|
});
|
|
844
844
|
});
|
|
845
845
|
}
|
|
846
846
|
}
|
|
847
|
-
function
|
|
847
|
+
function H(e) {
|
|
848
848
|
let t = e.getElement("#simulator-saves-list");
|
|
849
849
|
if (!t) return;
|
|
850
|
-
let n =
|
|
850
|
+
let n = B();
|
|
851
851
|
if (n.length === 0) {
|
|
852
852
|
t.innerHTML = "<div class=\"simulator-empty\">No saved states</div>";
|
|
853
853
|
return;
|
|
@@ -857,7 +857,7 @@ function U(e) {
|
|
|
857
857
|
return `
|
|
858
858
|
<div class="save-item">
|
|
859
859
|
<div class="save-item-header">
|
|
860
|
-
<span class="save-item-name">${
|
|
860
|
+
<span class="save-item-name">${de(e.name)}</span>
|
|
861
861
|
<span class="save-item-time">${i} ${a}</span>
|
|
862
862
|
</div>
|
|
863
863
|
<div class="save-item-actions">
|
|
@@ -880,25 +880,25 @@ function U(e) {
|
|
|
880
880
|
}), t.querySelectorAll(".save-delete-btn").forEach((t) => {
|
|
881
881
|
t.addEventListener("click", (t) => {
|
|
882
882
|
let r = parseInt(t.target.getAttribute("data-save-idx") || "0"), i = n.filter((e, t) => t !== r);
|
|
883
|
-
localStorage.setItem(
|
|
883
|
+
localStorage.setItem(F, JSON.stringify(i)), H(e);
|
|
884
884
|
});
|
|
885
885
|
});
|
|
886
886
|
}
|
|
887
|
-
function
|
|
887
|
+
function de(e) {
|
|
888
888
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
889
889
|
}
|
|
890
|
-
function
|
|
890
|
+
function fe(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, z(t), r && (r.disabled = !0)), n && (n.value = e.state.currentInputStr, z(n), i && (i.disabled = !0)), pe(e);
|
|
893
893
|
}
|
|
894
|
-
function
|
|
894
|
+
function pe(e) {
|
|
895
895
|
let t = e.getElement("#simulator-puzzle-override-tag"), n = e.getElement("#simulator-input-override-tag");
|
|
896
896
|
t && (t.hidden = e.state.appliedPuzzleOverride === null), n && (n.hidden = e.state.appliedInputOverride === null);
|
|
897
897
|
}
|
|
898
|
-
function
|
|
898
|
+
function me(e) {
|
|
899
899
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
900
900
|
}
|
|
901
|
-
function
|
|
901
|
+
function he() {
|
|
902
902
|
let e = 0;
|
|
903
903
|
return {
|
|
904
904
|
id: "msgs",
|
|
@@ -925,7 +925,7 @@ function me() {
|
|
|
925
925
|
<span class="simulator-msg-type">${t.direction === "out" ? "→" : "←"} ${t.type}</span>
|
|
926
926
|
<span class="simulator-msg-time">${t.time}</span>
|
|
927
927
|
</div>
|
|
928
|
-
${a ? `<div class="simulator-msg-data">${
|
|
928
|
+
${a ? `<div class="simulator-msg-data">${me(a)}</div>` : ""}
|
|
929
929
|
`;
|
|
930
930
|
let o = i.querySelector(".simulator-msg-data");
|
|
931
931
|
for (o && o.addEventListener("click", () => {
|
|
@@ -936,7 +936,7 @@ function me() {
|
|
|
936
936
|
}
|
|
937
937
|
};
|
|
938
938
|
}
|
|
939
|
-
function
|
|
939
|
+
function ge() {
|
|
940
940
|
return {
|
|
941
941
|
id: "done",
|
|
942
942
|
label: "Done",
|
|
@@ -973,7 +973,7 @@ function he() {
|
|
|
973
973
|
}
|
|
974
974
|
};
|
|
975
975
|
}
|
|
976
|
-
function
|
|
976
|
+
function _e() {
|
|
977
977
|
let e = [], t = () => (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", { hour12: !1 }), n = (e) => {
|
|
978
978
|
let { checkpointName: t, augConfig: n, time: r } = e, i = n == null ? void 0 : n.deeds;
|
|
979
979
|
return `
|
|
@@ -1023,8 +1023,160 @@ function ge() {
|
|
|
1023
1023
|
}
|
|
1024
1024
|
};
|
|
1025
1025
|
}
|
|
1026
|
+
/** Builds the expression scope from deeds the same way the API's `getScopeFromDeedsForGame` does. */
|
|
1027
|
+
const ve = (e) => {
|
|
1028
|
+
let t = {};
|
|
1029
|
+
if (!Array.isArray(e)) return t;
|
|
1030
|
+
for (let r of e) {
|
|
1031
|
+
var n;
|
|
1032
|
+
r.value !== void 0 && (t[Ce((n = r.name) == null ? r.id : n)] = r.value);
|
|
1033
|
+
}
|
|
1034
|
+
return t;
|
|
1035
|
+
}, ye = (e, t) => {
|
|
1036
|
+
try {
|
|
1037
|
+
if (e.filterExp && !xe(e.filterExp, t) || !e.incrementExp) return {
|
|
1038
|
+
complete: !1,
|
|
1039
|
+
value: 0
|
|
1040
|
+
};
|
|
1041
|
+
let n = xe(e.incrementExp, t);
|
|
1042
|
+
if (typeof n == "boolean" && (n = n ? 1 : 0), n === void 0 && (n = 0), typeof n != "number" || isNaN(n)) throw Error(`incrementExp must return a number, undefined or boolean, got ${n}`);
|
|
1043
|
+
let r = Math.floor(n);
|
|
1044
|
+
return {
|
|
1045
|
+
complete: r >= (e.targetCount || 1),
|
|
1046
|
+
value: r
|
|
1047
|
+
};
|
|
1048
|
+
} catch (e) {
|
|
1049
|
+
return {
|
|
1050
|
+
complete: !1,
|
|
1051
|
+
value: 0,
|
|
1052
|
+
error: e.message
|
|
1053
|
+
};
|
|
1054
|
+
}
|
|
1055
|
+
}, be = (e) => {
|
|
1056
|
+
let { items: t, scope: n, mode: r } = e, i = Math.min(Math.max(e.index, 0), t.length), a;
|
|
1057
|
+
for (; i < t.length && (a = ye(t[i], n), !(!a.complete || r === "checkpoint" && !t[i].liveUpdate)); i++);
|
|
1058
|
+
return {
|
|
1059
|
+
index: i,
|
|
1060
|
+
head: i < t.length ? a : void 0
|
|
1061
|
+
};
|
|
1062
|
+
};
|
|
1063
|
+
/** Runs an expression with scope keys as locals; unknown identifiers read as undefined like angular-expressions. */
|
|
1064
|
+
var xe = (e, t) => {
|
|
1065
|
+
let n = Object.keys(t).filter(Se);
|
|
1066
|
+
try {
|
|
1067
|
+
return Function(...n, `"use strict"; return (${e})`)(...n.map((e) => t[e]));
|
|
1068
|
+
} catch (e) {
|
|
1069
|
+
if (e instanceof ReferenceError) return;
|
|
1070
|
+
throw e;
|
|
1071
|
+
}
|
|
1072
|
+
}, Se = (e) => {
|
|
1073
|
+
if (!/^[A-Za-z_$][\w$]*$/.test(e)) return !1;
|
|
1074
|
+
try {
|
|
1075
|
+
return Function(e, "\"use strict\""), !0;
|
|
1076
|
+
} catch (e) {
|
|
1077
|
+
return !1;
|
|
1078
|
+
}
|
|
1079
|
+
}, Ce = (e) => e.replace(/-./g, (e) => e[1].toUpperCase());
|
|
1080
|
+
/** A minimal take on puzzmo.com's tutorial checklist, driven by deeds from checkpoints and completion. */
|
|
1081
|
+
function we(e) {
|
|
1082
|
+
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = null, i = 0, a, o = (e) => {
|
|
1083
|
+
var t;
|
|
1084
|
+
return `simulator-checklist:${(t = r) == null ? "game" : t}:${e}`;
|
|
1085
|
+
}, s = (e) => {
|
|
1086
|
+
try {
|
|
1087
|
+
let t = Number(localStorage.getItem(o(e.stableID))) || 0;
|
|
1088
|
+
return Math.min(Math.max(t, 0), e.items.length);
|
|
1089
|
+
} catch (e) {
|
|
1090
|
+
return 0;
|
|
1091
|
+
}
|
|
1092
|
+
}, c = (e, t) => {
|
|
1093
|
+
try {
|
|
1094
|
+
t === 0 ? localStorage.removeItem(o(e)) : localStorage.setItem(o(e), String(t));
|
|
1095
|
+
} catch (e) {}
|
|
1096
|
+
}, l = (e, t, r, i) => {
|
|
1097
|
+
var a;
|
|
1098
|
+
let o = r < i.index ? "done" : r === i.index ? "active" : "upcoming", s = `${e.stableID}:${r}`, c = n.has(s), l = !!t.expandMD && o !== "done", u = t.targetCount || 1, d = o === "active" && i.head ? `${Math.min(i.head.value, u)}/${u}` : "", f = [
|
|
1099
|
+
t.incrementExp && `increment: ${t.incrementExp}`,
|
|
1100
|
+
t.filterExp && `filter: ${t.filterExp}`,
|
|
1101
|
+
`target: ${u}`,
|
|
1102
|
+
t.liveUpdate ? "liveUpdate: checkpoints + completion" : "completion only"
|
|
1103
|
+
].filter(Boolean).join("\n");
|
|
1104
|
+
return `${e.instructionsVisibleFromItemIndex === r && r > 0 ? "<div class=\"checklist-divider\"><span>full instructions unlock</span></div>" : ""}
|
|
1105
|
+
<div class="checklist-item ${o}" title="${U(f)}">
|
|
1106
|
+
<div class="checklist-row">
|
|
1107
|
+
<span class="checklist-tick">${o === "done" ? "■" : "□"}</span>
|
|
1108
|
+
<span class="checklist-title">${U((a = t.title) == null ? `Step ${r + 1}` : a)}</span>
|
|
1109
|
+
${d ? `<span class="checklist-count">${d}</span>` : ""}
|
|
1110
|
+
${l ? `<button class="checklist-help${c ? " open" : ""}" data-help="${U(s)}">?</button>` : ""}
|
|
1111
|
+
</div>
|
|
1112
|
+
${o === "active" && t.subtitle ? `<div class="checklist-subtitle">${U(t.subtitle)}</div>` : ""}
|
|
1113
|
+
${l && c ? `<pre class="checklist-expand">${U(t.expandMD)}</pre>` : ""}
|
|
1114
|
+
</div>`;
|
|
1115
|
+
}, u = (e) => {
|
|
1116
|
+
var n, r, i, o;
|
|
1117
|
+
let s = (n = t.get(e.stableID)) == null ? { index: 0 } : n, c = e.items.length, u = s.index, d = ((r = s.head) == null ? void 0 : r.error) && `${(i = (o = e.items[s.index]) == null ? void 0 : o.title) == null ? `Step ${s.index + 1}` : i}: ${s.head.error}`;
|
|
1118
|
+
return `
|
|
1119
|
+
<div class="checklist-section">
|
|
1120
|
+
<div class="checklist-header">
|
|
1121
|
+
<span class="simulator-label">Checklist</span>
|
|
1122
|
+
<span class="checklist-progress${u === c ? " complete" : ""}">${u}/${c}</span>
|
|
1123
|
+
<button class="simulator-btn subtle small" data-reset="${U(e.stableID)}">Reset</button>
|
|
1124
|
+
</div>
|
|
1125
|
+
<div class="checklist-items">
|
|
1126
|
+
${e.items.map((t, n) => l(e, t, n, s)).join("")}
|
|
1127
|
+
</div>
|
|
1128
|
+
${a ? `<div class="checklist-footer">last eval: ${U(a)}</div>` : ""}
|
|
1129
|
+
${d ? `<div class="checklist-error">${U(d)}</div>` : ""}
|
|
1130
|
+
</div>`;
|
|
1131
|
+
}, d = () => e.length === 0 ? "<div class=\"simulator-empty\">No checklists in puzzmo.json → integrations.checklists\n<pre class=\"checklist-expand\">\"checklists\": [{\n \"stableID\": \"my-game:tutorial\",\n \"type\": \"tutorial\",\n \"items\": [{ \"title\": \"Make a move\", \"incrementExp\": \"moves\", \"liveUpdate\": true }]\n}]</pre></div>" : e.map(u).join(""), f = (e) => {
|
|
1132
|
+
let t = e.getElement("#simulator-checklist-list");
|
|
1133
|
+
t && (t.innerHTML = d());
|
|
1134
|
+
}, p = (n, r, o, s) => {
|
|
1135
|
+
let l = 0, u = ve(r);
|
|
1136
|
+
a = s;
|
|
1137
|
+
for (let n of e) {
|
|
1138
|
+
var d, p;
|
|
1139
|
+
let e = (d = (p = t.get(n.stableID)) == null ? void 0 : p.index) == null ? 0 : d, r = be({
|
|
1140
|
+
items: n.items,
|
|
1141
|
+
index: e,
|
|
1142
|
+
scope: u,
|
|
1143
|
+
mode: o
|
|
1144
|
+
});
|
|
1145
|
+
l += r.index - e, t.set(n.stableID, r), r.index !== e && c(n.stableID, r.index);
|
|
1146
|
+
}
|
|
1147
|
+
l > 0 && (i += l, n.updateBadge("checklist", i)), f(n);
|
|
1148
|
+
};
|
|
1149
|
+
return {
|
|
1150
|
+
id: "checklist",
|
|
1151
|
+
label: "Cklst",
|
|
1152
|
+
render() {
|
|
1153
|
+
return `<div id="simulator-checklist-list" class="checklist-view-container">${d()}</div>`;
|
|
1154
|
+
},
|
|
1155
|
+
bind(o) {
|
|
1156
|
+
var l;
|
|
1157
|
+
r = o.gameSlug;
|
|
1158
|
+
for (let n of e) t.set(n.stableID, { index: s(n) });
|
|
1159
|
+
f(o), (l = o.getElement("#simulator-checklist-list")) == null || l.addEventListener("click", (e) => {
|
|
1160
|
+
var r, s;
|
|
1161
|
+
let l = e.target, u = (r = l.closest("[data-reset]")) == null ? void 0 : r.dataset.reset, d = (s = l.closest("[data-help]")) == null ? void 0 : s.dataset.help;
|
|
1162
|
+
if (u) t.set(u, { index: 0 }), c(u, 0), a = void 0, i = 0, o.updateBadge("checklist", 0);
|
|
1163
|
+
else if (d) n.has(d) ? n.delete(d) : n.add(d);
|
|
1164
|
+
else return;
|
|
1165
|
+
f(o);
|
|
1166
|
+
});
|
|
1167
|
+
},
|
|
1168
|
+
onActivate() {
|
|
1169
|
+
i = 0;
|
|
1170
|
+
},
|
|
1171
|
+
onMessage(e, t, n) {
|
|
1172
|
+
var r, i, a;
|
|
1173
|
+
e === "HIT_CHECKPOINT" ? p(n, t == null || (r = t.augConfig) == null ? void 0 : r.deeds, "checkpoint", `checkpoint "${(i = t == null ? void 0 : t.checkpointName) == null ? "?" : i}"`) : e === "GAME_COMPLETED" && p(n, t == null || (a = t.config) == null ? void 0 : a.deeds, "completion", "completion");
|
|
1174
|
+
}
|
|
1175
|
+
};
|
|
1176
|
+
}
|
|
1177
|
+
var U = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
1026
1178
|
/** Find thumbnail function on globalThis (looks for functions ending in "Thumbnail") */
|
|
1027
|
-
function
|
|
1179
|
+
function Te() {
|
|
1028
1180
|
let e = globalThis;
|
|
1029
1181
|
for (let t of Object.keys(e)) if (t.endsWith("Thumbnail") && typeof e[t] == "function") return {
|
|
1030
1182
|
name: t,
|
|
@@ -1033,23 +1185,23 @@ function _e() {
|
|
|
1033
1185
|
return null;
|
|
1034
1186
|
}
|
|
1035
1187
|
/** The bundle's `getShareString` (if any), exposed to the sim via vite.ts's bundle loader. */
|
|
1036
|
-
function
|
|
1188
|
+
function Ee() {
|
|
1037
1189
|
let e = globalThis.getShareString;
|
|
1038
1190
|
return typeof e == "function" ? e : null;
|
|
1039
1191
|
}
|
|
1040
|
-
function
|
|
1192
|
+
function De(e) {
|
|
1041
1193
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
1042
1194
|
}
|
|
1043
|
-
function
|
|
1195
|
+
function Oe() {
|
|
1044
1196
|
let e = /* @__PURE__ */ new Date();
|
|
1045
1197
|
return `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`;
|
|
1046
1198
|
}
|
|
1047
|
-
function
|
|
1199
|
+
function ke(e) {
|
|
1048
1200
|
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
1049
1201
|
}
|
|
1050
1202
|
/** Shown when Preview Kind = Text but the bundle doesn't export `getShareString`. */
|
|
1051
|
-
var
|
|
1052
|
-
function
|
|
1203
|
+
var Ae = "\n <div class=\"simulator-share-missing\">\n <p>The app bundle doesn't export <code>getShareString</code>.</p>\n <p>Add it to your app bundle to preview share strings here:</p>\n <pre>export const getShareString: AppBundle[\"getShareString\"] = (\n inputStr, title, { puzzleString, dateKey, gameplaySlug },\n) => ({ str: `${title}: ...` })</pre>\n </div>\n";
|
|
1204
|
+
function je() {
|
|
1053
1205
|
return {
|
|
1054
1206
|
id: "thumb",
|
|
1055
1207
|
label: "Thumb",
|
|
@@ -1085,26 +1237,26 @@ function Ce() {
|
|
|
1085
1237
|
updatePreview: (e) => {
|
|
1086
1238
|
let t = e.getElement("#simulator-thumb-preview"), n = e.getElement("#simulator-thumb-fn");
|
|
1087
1239
|
if (t == null || t.style.setProperty("--sim-thumb-bg", e.state.selectedTheme.g_bg), e.state.previewKind === "text") {
|
|
1088
|
-
let s =
|
|
1240
|
+
let s = Ee();
|
|
1089
1241
|
if (!s) {
|
|
1090
|
-
t && (t.innerHTML =
|
|
1242
|
+
t && (t.innerHTML = Ae), n && (n.textContent = "");
|
|
1091
1243
|
return;
|
|
1092
1244
|
}
|
|
1093
1245
|
n && (n.textContent = "Using: getShareString()");
|
|
1094
1246
|
try {
|
|
1095
1247
|
var r, i, a, o;
|
|
1096
|
-
let n = (r = e.gameSlug) == null ? "game" : r, c = s((i = e.state.currentInputStr) == null ? "" : i,
|
|
1248
|
+
let n = (r = e.gameSlug) == null ? "game" : r, c = s((i = e.state.currentInputStr) == null ? "" : i, ke(n), {
|
|
1097
1249
|
puzzleString: (a = e.state.puzzleData) == null ? "" : a,
|
|
1098
|
-
dateKey:
|
|
1250
|
+
dateKey: Oe(),
|
|
1099
1251
|
gameplaySlug: `simulator:${n}`
|
|
1100
1252
|
}), l = (o = c == null ? void 0 : c.str) == null ? "" : o;
|
|
1101
|
-
t && (t.innerHTML = `<pre class="simulator-share-preview" style="color: ${e.state.selectedTheme.fg}">${
|
|
1253
|
+
t && (t.innerHTML = `<pre class="simulator-share-preview" style="color: ${e.state.selectedTheme.fg}">${De(l)}</pre>`);
|
|
1102
1254
|
} catch (e) {
|
|
1103
1255
|
console.error("Simulator: Share string error", e), t && (t.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
|
|
1104
1256
|
}
|
|
1105
1257
|
return;
|
|
1106
1258
|
}
|
|
1107
|
-
let s =
|
|
1259
|
+
let s = Te();
|
|
1108
1260
|
if (!s) {
|
|
1109
1261
|
t && (t.innerHTML = "<span class=\"simulator-empty\">No thumbnail function found</span>"), n && (n.textContent = "");
|
|
1110
1262
|
return;
|
|
@@ -1118,7 +1270,7 @@ function Ce() {
|
|
|
1118
1270
|
strict: !0,
|
|
1119
1271
|
renderHost: e.state.renderHost,
|
|
1120
1272
|
renderContext: e.state.renderContext
|
|
1121
|
-
}, { svg: i } =
|
|
1273
|
+
}, { svg: i } = N(s.fn(n, e.state.currentInputStr, r));
|
|
1122
1274
|
t && (t.innerHTML = i);
|
|
1123
1275
|
} catch (e) {
|
|
1124
1276
|
console.error("Simulator: Thumbnail error", e), t && (t.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
|
|
@@ -1127,7 +1279,7 @@ function Ce() {
|
|
|
1127
1279
|
};
|
|
1128
1280
|
}
|
|
1129
1281
|
/** Generate theme preview HTML showing key colors */
|
|
1130
|
-
function
|
|
1282
|
+
function Me(e) {
|
|
1131
1283
|
let t = [
|
|
1132
1284
|
e.key,
|
|
1133
1285
|
e.subBrand,
|
|
@@ -1138,7 +1290,7 @@ function we(e) {
|
|
|
1138
1290
|
].map((e) => `<div class="simulator-theme-preview-cell" style="background: ${e}"></div>`).join("");
|
|
1139
1291
|
return `<div class="simulator-theme-preview" style="background: ${e.g_bg}">${t}</div>`;
|
|
1140
1292
|
}
|
|
1141
|
-
function
|
|
1293
|
+
function Ne() {
|
|
1142
1294
|
return {
|
|
1143
1295
|
id: "theme",
|
|
1144
1296
|
label: "Theme",
|
|
@@ -1150,7 +1302,7 @@ function Te() {
|
|
|
1150
1302
|
t && n.forEach((n) => {
|
|
1151
1303
|
let r = document.createElement("div");
|
|
1152
1304
|
r.className = `simulator-theme-item${n.name === e.state.selectedTheme.name ? " selected" : ""}`, r.innerHTML = `
|
|
1153
|
-
${
|
|
1305
|
+
${Me(n)}
|
|
1154
1306
|
<div class="simulator-theme-name">${n.name}</div>
|
|
1155
1307
|
<div class="simulator-theme-type">${n.type}</div>
|
|
1156
1308
|
`, r.addEventListener("click", () => {
|
|
@@ -1160,7 +1312,7 @@ function Te() {
|
|
|
1160
1312
|
}
|
|
1161
1313
|
};
|
|
1162
1314
|
}
|
|
1163
|
-
var
|
|
1315
|
+
var Pe = [
|
|
1164
1316
|
{
|
|
1165
1317
|
name: "app (desktop)",
|
|
1166
1318
|
context: [{
|
|
@@ -1207,8 +1359,8 @@ var Ee = [
|
|
|
1207
1359
|
* The bootstrap is only read at game boot, so applying a change persists it to localStorage and
|
|
1208
1360
|
* restarts (reloads) the page — the same flow as the Theme tab.
|
|
1209
1361
|
*/
|
|
1210
|
-
function
|
|
1211
|
-
let t = [...
|
|
1362
|
+
function Fe(e = []) {
|
|
1363
|
+
let t = [...Pe, ...e];
|
|
1212
1364
|
return {
|
|
1213
1365
|
id: "host",
|
|
1214
1366
|
label: "Host",
|
|
@@ -1225,7 +1377,7 @@ function De(e = []) {
|
|
|
1225
1377
|
<div class="host-note" id="host-source"></div>
|
|
1226
1378
|
<select class="simulator-select" id="host-presets">
|
|
1227
1379
|
<option value="">Preset…</option>
|
|
1228
|
-
${t.map((e, t) => `<option value="${t}">${
|
|
1380
|
+
${t.map((e, t) => `<option value="${t}">${Ie(e.name)}</option>`).join("")}
|
|
1229
1381
|
</select>
|
|
1230
1382
|
<textarea class="simulator-textarea" id="host-json" spellcheck="false"></textarea>
|
|
1231
1383
|
<div class="host-actions">
|
|
@@ -1262,12 +1414,12 @@ function De(e = []) {
|
|
|
1262
1414
|
};
|
|
1263
1415
|
}
|
|
1264
1416
|
/** Minimal HTML-escape so preset names can't break the simulator markup. */
|
|
1265
|
-
function
|
|
1417
|
+
function Ie(e) {
|
|
1266
1418
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
1267
1419
|
}
|
|
1268
|
-
var
|
|
1269
|
-
localStorage.setItem(
|
|
1270
|
-
}, K = null,
|
|
1420
|
+
var Le = "puzzmo_sim_api_mode", W = "http://localhost:8911", Re = "https://api.puzzmo.com", G = () => localStorage.getItem(Le) === "dev" ? "dev" : "prod", ze = (e) => {
|
|
1421
|
+
localStorage.setItem(Le, e);
|
|
1422
|
+
}, K = null, Be = function() {
|
|
1271
1423
|
var e = t(function* () {
|
|
1272
1424
|
if (K !== null) return K;
|
|
1273
1425
|
try {
|
|
@@ -1281,23 +1433,23 @@ var ke = "puzzmo_sim_api_mode", W = "http://localhost:8911", Ae = "https://api.p
|
|
|
1281
1433
|
return e.apply(this, arguments);
|
|
1282
1434
|
};
|
|
1283
1435
|
}(), q = () => ({
|
|
1284
|
-
apiURL: G() === "dev" ? W :
|
|
1436
|
+
apiURL: G() === "dev" ? W : Re,
|
|
1285
1437
|
clientID: "protosdk:oauthclient",
|
|
1286
1438
|
redirectUri: `${window.location.origin}/oauth/callback`
|
|
1287
|
-
}),
|
|
1439
|
+
}), Ve = () => {
|
|
1288
1440
|
let e = new Uint8Array(32);
|
|
1289
1441
|
return crypto.getRandomValues(e), Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
1290
|
-
},
|
|
1291
|
-
let e = localStorage.getItem(
|
|
1442
|
+
}, He = "puzzmo_sim_oauth_token", Ue = "puzzmo_sim_oauth_refresh_token", We = (e) => localStorage.setItem(He, e), Ge = (e) => localStorage.setItem(Ue, e), Ke = () => {
|
|
1443
|
+
let e = localStorage.getItem(He);
|
|
1292
1444
|
return e && `${e.substring(0, 20)}`, e;
|
|
1293
|
-
},
|
|
1294
|
-
localStorage.removeItem(
|
|
1295
|
-
},
|
|
1296
|
-
let e = q(), t =
|
|
1445
|
+
}, qe = () => localStorage.getItem(Ue), Je = () => {
|
|
1446
|
+
localStorage.removeItem(He), localStorage.removeItem(Ue);
|
|
1447
|
+
}, Ye = () => {
|
|
1448
|
+
let e = q(), t = Ve();
|
|
1297
1449
|
sessionStorage.setItem("oauth_state", t), sessionStorage.setItem("oauth_return_url", window.location.href);
|
|
1298
1450
|
let n = new URL(`${e.apiURL}/oauth/auth`);
|
|
1299
1451
|
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
|
-
},
|
|
1452
|
+
}, Xe = (e) => {
|
|
1301
1453
|
try {
|
|
1302
1454
|
let t = e.split(".");
|
|
1303
1455
|
if (t.length !== 3) return !0;
|
|
@@ -1306,9 +1458,9 @@ var ke = "puzzmo_sim_api_mode", W = "http://localhost:8911", Ae = "https://api.p
|
|
|
1306
1458
|
} catch (e) {
|
|
1307
1459
|
return !0;
|
|
1308
1460
|
}
|
|
1309
|
-
},
|
|
1461
|
+
}, Ze = function() {
|
|
1310
1462
|
var e = t(function* () {
|
|
1311
|
-
let e =
|
|
1463
|
+
let e = qe();
|
|
1312
1464
|
if (!e) return !1;
|
|
1313
1465
|
let t = q();
|
|
1314
1466
|
try {
|
|
@@ -1324,9 +1476,9 @@ var ke = "puzzmo_sim_api_mode", W = "http://localhost:8911", Ae = "https://api.p
|
|
|
1324
1476
|
if (!r.ok) return r.statusText, !1;
|
|
1325
1477
|
let i = yield r.json(), a = i.access_token || i.accessToken;
|
|
1326
1478
|
if (!a) return !1;
|
|
1327
|
-
|
|
1479
|
+
We(a);
|
|
1328
1480
|
let o = i.refresh_token || i.refreshToken;
|
|
1329
|
-
return o &&
|
|
1481
|
+
return o && Ge(o), !0;
|
|
1330
1482
|
} catch (e) {
|
|
1331
1483
|
return !1;
|
|
1332
1484
|
}
|
|
@@ -1334,7 +1486,7 @@ var ke = "puzzmo_sim_api_mode", W = "http://localhost:8911", Ae = "https://api.p
|
|
|
1334
1486
|
return function() {
|
|
1335
1487
|
return e.apply(this, arguments);
|
|
1336
1488
|
};
|
|
1337
|
-
}(),
|
|
1489
|
+
}(), Qe = function() {
|
|
1338
1490
|
var e = t(function* (e, t) {
|
|
1339
1491
|
let n = q(), r = sessionStorage.getItem("oauth_state");
|
|
1340
1492
|
if (!r || r !== t) return null;
|
|
@@ -1358,13 +1510,13 @@ var ke = "puzzmo_sim_api_mode", W = "http://localhost:8911", Ae = "https://api.p
|
|
|
1358
1510
|
return function(t, n) {
|
|
1359
1511
|
return e.apply(this, arguments);
|
|
1360
1512
|
};
|
|
1361
|
-
}(),
|
|
1513
|
+
}(), $e = function() {
|
|
1362
1514
|
var e = t(function* (e, t = {}) {
|
|
1363
|
-
let n = q(), r =
|
|
1515
|
+
let n = q(), r = Ke();
|
|
1364
1516
|
if (!r) throw Error("Not authenticated");
|
|
1365
|
-
if (
|
|
1366
|
-
if (r =
|
|
1367
|
-
} else throw
|
|
1517
|
+
if (Xe(r)) if (yield Ze()) {
|
|
1518
|
+
if (r = Ke(), !r) throw Error("Token refresh succeeded but no token available");
|
|
1519
|
+
} else throw Je(), Error("Session expired. Please log in again.");
|
|
1368
1520
|
let i = yield fetch(`${n.apiURL}/graphql`, {
|
|
1369
1521
|
method: "POST",
|
|
1370
1522
|
headers: {
|
|
@@ -1383,7 +1535,7 @@ var ke = "puzzmo_sim_api_mode", W = "http://localhost:8911", Ae = "https://api.p
|
|
|
1383
1535
|
return function(t) {
|
|
1384
1536
|
return e.apply(this, arguments);
|
|
1385
1537
|
};
|
|
1386
|
-
}(),
|
|
1538
|
+
}(), et = (e) => {
|
|
1387
1539
|
try {
|
|
1388
1540
|
let t = e.split(".");
|
|
1389
1541
|
return t.length, t.length === 3 ? JSON.parse(atob(t[1])) : null;
|
|
@@ -1391,15 +1543,15 @@ var ke = "puzzmo_sim_api_mode", W = "http://localhost:8911", Ae = "https://api.p
|
|
|
1391
1543
|
return null;
|
|
1392
1544
|
}
|
|
1393
1545
|
};
|
|
1394
|
-
function
|
|
1546
|
+
function tt() {
|
|
1395
1547
|
let e = !1;
|
|
1396
1548
|
return {
|
|
1397
1549
|
id: "auth",
|
|
1398
1550
|
label: "Auth",
|
|
1399
1551
|
render() {
|
|
1400
|
-
let e =
|
|
1552
|
+
let e = Ke(), t = !!e, n = G(), r = n === "dev" ? W : Re, i = `<button class="simulator-btn tiny" id="auth-dev-toggle" style="display: none;">${n === "dev" ? "Using Dev" : "Dev"}</button>`;
|
|
1401
1553
|
if (t) {
|
|
1402
|
-
let t =
|
|
1554
|
+
let t = et(e), n = t != null && t.exp ? (/* @__PURE__ */ new Date(t.exp * 1e3)).toLocaleString() : "Unknown", a = !!qe(), o = a ? et(qe()) : null, s = o != null && o.exp ? (/* @__PURE__ */ new Date(o.exp * 1e3)).toLocaleString() : null;
|
|
1403
1555
|
return `
|
|
1404
1556
|
<div class="simulator-section">
|
|
1405
1557
|
<div class="simulator-section-title auth-title-row">
|
|
@@ -1451,21 +1603,21 @@ function qe() {
|
|
|
1451
1603
|
},
|
|
1452
1604
|
bind(n) {
|
|
1453
1605
|
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");
|
|
1454
|
-
e ? K && c && (c.style.display = "", G() === "dev" && c.classList.add("active")) : (e = !0,
|
|
1606
|
+
e ? K && c && (c.style.display = "", G() === "dev" && c.classList.add("active")) : (e = !0, Be().then((e) => {
|
|
1455
1607
|
e && c && (c.style.display = "", G() === "dev" && c.classList.add("active"));
|
|
1456
1608
|
})), c == null || c.addEventListener("click", () => {
|
|
1457
|
-
|
|
1609
|
+
ze(G() === "dev" ? "prod" : "dev"), Je(), window.location.reload();
|
|
1458
1610
|
}), r == null || r.addEventListener("click", () => {
|
|
1459
|
-
|
|
1611
|
+
Ye();
|
|
1460
1612
|
}), i == null || i.addEventListener("click", () => {
|
|
1461
|
-
|
|
1613
|
+
Je(), window.location.reload();
|
|
1462
1614
|
}), a == null || a.addEventListener("click", t(function* () {
|
|
1463
|
-
a.disabled = !0, a.textContent = "Refreshing...", (yield
|
|
1615
|
+
a.disabled = !0, a.textContent = "Refreshing...", (yield Ze()) ? window.location.reload() : (a.textContent = "Refresh Failed", a.disabled = !1);
|
|
1464
1616
|
})), o == null || o.addEventListener("click", t(function* () {
|
|
1465
1617
|
if (s) {
|
|
1466
1618
|
s.innerHTML = "<div class=\"loading\">Loading...</div>";
|
|
1467
1619
|
try {
|
|
1468
|
-
let t = yield
|
|
1620
|
+
let t = yield $e("\n query {\n currentUser {\n id\n username\n usernameID\n name\n }\n }\n ");
|
|
1469
1621
|
if (t.errors) {
|
|
1470
1622
|
var e;
|
|
1471
1623
|
s.innerHTML = `<div class="error">Error: ${((e = t.errors[0]) == null ? void 0 : e.message) || "Unknown error"}</div>`;
|
|
@@ -1487,13 +1639,13 @@ function qe() {
|
|
|
1487
1639
|
if (n && r) {
|
|
1488
1640
|
let t = e.getElement("#auth-status");
|
|
1489
1641
|
t && (t.innerHTML = "<span class=\"indicator waiting\"></span><span>Exchanging code...</span>");
|
|
1490
|
-
let i = yield
|
|
1642
|
+
let i = yield Qe(n, r);
|
|
1491
1643
|
if (window.history.replaceState({}, "", window.location.pathname), i) {
|
|
1492
1644
|
let e = i.access_token || i.accessToken;
|
|
1493
1645
|
if (e) {
|
|
1494
|
-
|
|
1646
|
+
We(e);
|
|
1495
1647
|
let t = i.refresh_token || i.refreshToken;
|
|
1496
|
-
t &&
|
|
1648
|
+
t && Ge(t);
|
|
1497
1649
|
}
|
|
1498
1650
|
window.location.reload();
|
|
1499
1651
|
} else {
|
|
@@ -1505,9 +1657,9 @@ function qe() {
|
|
|
1505
1657
|
}
|
|
1506
1658
|
};
|
|
1507
1659
|
}
|
|
1508
|
-
var
|
|
1509
|
-
localStorage.removeItem(
|
|
1510
|
-
},
|
|
1660
|
+
var nt = "puzzmo_sim_api_mode", rt = "http://localhost:8911", it = "https://api.puzzmo.com", at = "puzzmo_sim_oauth_token", ot = "puzzmo_sim_oauth_refresh_token", st = () => localStorage.getItem(nt) === "dev" ? "dev" : "prod", ct = () => localStorage.getItem(at), lt = () => localStorage.getItem(ot), ut = (e) => localStorage.setItem(at, e), dt = (e) => localStorage.setItem(ot, e), ft = () => {
|
|
1661
|
+
localStorage.removeItem(at), localStorage.removeItem(ot);
|
|
1662
|
+
}, pt = (e) => {
|
|
1511
1663
|
try {
|
|
1512
1664
|
let t = e.split(".");
|
|
1513
1665
|
if (t.length !== 3) return !0;
|
|
@@ -1516,11 +1668,11 @@ var Je = "puzzmo_sim_api_mode", Ye = "http://localhost:8911", Xe = "https://api.
|
|
|
1516
1668
|
} catch (e) {
|
|
1517
1669
|
return !0;
|
|
1518
1670
|
}
|
|
1519
|
-
},
|
|
1671
|
+
}, mt = function() {
|
|
1520
1672
|
var e = t(function* () {
|
|
1521
|
-
let e =
|
|
1673
|
+
let e = lt();
|
|
1522
1674
|
if (!e) return !1;
|
|
1523
|
-
let t =
|
|
1675
|
+
let t = st() === "dev" ? rt : it;
|
|
1524
1676
|
try {
|
|
1525
1677
|
let n = new URLSearchParams({
|
|
1526
1678
|
grant_type: "refresh_token",
|
|
@@ -1534,9 +1686,9 @@ var Je = "puzzmo_sim_api_mode", Ye = "http://localhost:8911", Xe = "https://api.
|
|
|
1534
1686
|
if (!r.ok) return !1;
|
|
1535
1687
|
let i = yield r.json(), a = i.access_token || i.accessToken;
|
|
1536
1688
|
if (!a) return !1;
|
|
1537
|
-
|
|
1689
|
+
ut(a);
|
|
1538
1690
|
let o = i.refresh_token || i.refreshToken;
|
|
1539
|
-
return o &&
|
|
1691
|
+
return o && dt(o), !0;
|
|
1540
1692
|
} catch (e) {
|
|
1541
1693
|
return !1;
|
|
1542
1694
|
}
|
|
@@ -1544,13 +1696,13 @@ var Je = "puzzmo_sim_api_mode", Ye = "http://localhost:8911", Xe = "https://api.
|
|
|
1544
1696
|
return function() {
|
|
1545
1697
|
return e.apply(this, arguments);
|
|
1546
1698
|
};
|
|
1547
|
-
}(),
|
|
1699
|
+
}(), ht = function() {
|
|
1548
1700
|
var e = t(function* (e, t = {}) {
|
|
1549
|
-
let n =
|
|
1701
|
+
let n = st() === "dev" ? rt : it, r = ct();
|
|
1550
1702
|
if (!r) throw Error("Not authenticated");
|
|
1551
|
-
if (
|
|
1552
|
-
if (r =
|
|
1553
|
-
} else throw
|
|
1703
|
+
if (pt(r)) if (yield mt()) {
|
|
1704
|
+
if (r = ct(), !r) throw Error("Token refresh succeeded but no token available");
|
|
1705
|
+
} else throw ft(), Error("Session expired. Please log in again.");
|
|
1554
1706
|
let i = yield fetch(`${n}/graphql`, {
|
|
1555
1707
|
method: "POST",
|
|
1556
1708
|
headers: {
|
|
@@ -1569,19 +1721,19 @@ var Je = "puzzmo_sim_api_mode", Ye = "http://localhost:8911", Xe = "https://api.
|
|
|
1569
1721
|
return function(t) {
|
|
1570
1722
|
return e.apply(this, arguments);
|
|
1571
1723
|
};
|
|
1572
|
-
}(),
|
|
1724
|
+
}(), gt = "\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", _t = "\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", vt = (e, t) => {
|
|
1573
1725
|
let n = t - 1, r = Math.floor(n / 31), i = n % 31, a = [...e];
|
|
1574
1726
|
for (; a.length <= r;) a.push(0);
|
|
1575
1727
|
return a[r] = a[r] ^ 1 << i, a;
|
|
1576
1728
|
};
|
|
1577
|
-
const
|
|
1578
|
-
function
|
|
1729
|
+
const yt = () => !!ct();
|
|
1730
|
+
function bt() {
|
|
1579
1731
|
let n = null, r = !1, i = null, a = function() {
|
|
1580
1732
|
var e = t(function* (e) {
|
|
1581
1733
|
r = !0, i = null;
|
|
1582
1734
|
try {
|
|
1583
1735
|
var t;
|
|
1584
|
-
let r = yield
|
|
1736
|
+
let r = yield ht(gt, { slug: e });
|
|
1585
1737
|
if (r.errors) {
|
|
1586
1738
|
var a;
|
|
1587
1739
|
i = ((a = r.errors[0]) == null ? void 0 : a.message) || "Unknown error", n = null;
|
|
@@ -1598,10 +1750,10 @@ function ft() {
|
|
|
1598
1750
|
}(), o = function() {
|
|
1599
1751
|
var r = t(function* (t) {
|
|
1600
1752
|
if (!n) return;
|
|
1601
|
-
let r =
|
|
1753
|
+
let r = vt(n.featuresArr, t);
|
|
1602
1754
|
try {
|
|
1603
1755
|
var i;
|
|
1604
|
-
let t = yield
|
|
1756
|
+
let t = yield ht(_t, {
|
|
1605
1757
|
gameSlug: n.slug,
|
|
1606
1758
|
input: { featuresArr: r }
|
|
1607
1759
|
});
|
|
@@ -1649,7 +1801,7 @@ function ft() {
|
|
|
1649
1801
|
id: "features",
|
|
1650
1802
|
label: "Features",
|
|
1651
1803
|
render() {
|
|
1652
|
-
return
|
|
1804
|
+
return yt() ? `
|
|
1653
1805
|
<div class="features-view-container">
|
|
1654
1806
|
<div class="simulator-section">
|
|
1655
1807
|
<div class="simulator-section-title">Game Features</div>
|
|
@@ -1690,7 +1842,7 @@ function ft() {
|
|
|
1690
1842
|
e && (yield d(e));
|
|
1691
1843
|
})), i == null || i.addEventListener("keypress", (e) => {
|
|
1692
1844
|
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,
|
|
1845
|
+
}), console.log("[FeaturesView] bind called, ctx.gameSlug:", e.gameSlug, "slugInput:", i), e.gameSlug && i && (i.value = e.gameSlug, yt() && !n && d(e.gameSlug)), u();
|
|
1694
1846
|
},
|
|
1695
1847
|
onActivate(e) {
|
|
1696
1848
|
let t = e.getElement("#simulator-tab-features");
|
|
@@ -1714,15 +1866,15 @@ function ft() {
|
|
|
1714
1866
|
* tuning it needs to see it.
|
|
1715
1867
|
*/
|
|
1716
1868
|
/** Space the keys occupy. */
|
|
1717
|
-
var
|
|
1869
|
+
var xt = 200, St = 24;
|
|
1718
1870
|
/** What the keyboard takes off the bottom of the game, and what the game must lay out without. */
|
|
1719
|
-
const J =
|
|
1871
|
+
const J = xt + St;
|
|
1720
1872
|
/** Drag-cursor thresholds, from useKeyboardCursor in @puzzmo-com/keyboard. */
|
|
1721
|
-
var
|
|
1873
|
+
var Ct = 6, wt = 2.5, Tt = 100, Et = (e, t) => e ? "14.7%" : t ? "17.85%" : "9.75%", Y = (e, t) => {
|
|
1722
1874
|
let n = e.replace("#", ""), r = n.length === 3 ? [...n].map((e) => e + e).join("") : n, i = parseInt(r, 16);
|
|
1723
1875
|
return r.length !== 6 || Number.isNaN(i) ? e : `rgba(${i >> 16 & 255}, ${i >> 8 & 255}, ${i & 255}, ${t})`;
|
|
1724
|
-
},
|
|
1725
|
-
function
|
|
1876
|
+
}, Dt = (e) => e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<"), Ot = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
1877
|
+
function kt(e) {
|
|
1726
1878
|
let { theme: t, sendToGame: n } = e, r = !1, i = null, a = null, o = document.createElement("style");
|
|
1727
1879
|
o.id = "sim-docked-kbd-page-style", o.textContent = `
|
|
1728
1880
|
html.sim-kbd-docked #simulator {
|
|
@@ -1771,7 +1923,7 @@ function xt(e) {
|
|
|
1771
1923
|
}, f = (e, t) => {
|
|
1772
1924
|
var n, r;
|
|
1773
1925
|
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:${
|
|
1926
|
+
`width:${Et(t.l.includes(e), t.xl.includes(e))}`,
|
|
1775
1927
|
`flex:${o ? "1 0 auto" : "0 1 auto"}`,
|
|
1776
1928
|
"height:100%",
|
|
1777
1929
|
"display:flex",
|
|
@@ -1781,8 +1933,8 @@ function xt(e) {
|
|
|
1781
1933
|
"position:relative",
|
|
1782
1934
|
a ? "pointer-events:none" : ""
|
|
1783
1935
|
].filter(Boolean).join(";"), c = u(e, t), l = d(e, t);
|
|
1784
|
-
return `<div class="sim-docked-kbd-key" data-key="${
|
|
1785
|
-
<div class="sim-docked-kbd-key-inner" style="${c}"><div style="${l}">${
|
|
1936
|
+
return `<div class="sim-docked-kbd-key" data-key="${Dt(e)}" style="${s}">
|
|
1937
|
+
<div class="sim-docked-kbd-key-inner" style="${c}"><div style="${l}">${Ot(i)}</div></div>
|
|
1786
1938
|
</div>`;
|
|
1787
1939
|
}, p = (e) => {
|
|
1788
1940
|
let n = e.layout.filter((e) => !!e), r = `calc(100% / ${n.length})`;
|
|
@@ -1801,7 +1953,7 @@ function xt(e) {
|
|
|
1801
1953
|
}, S = (e) => {
|
|
1802
1954
|
y = ee(e), a == null || a.setPointerCapture(e.pointerId);
|
|
1803
1955
|
}, C = (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, _ >=
|
|
1956
|
+
!(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, _ >= Ct && Date.now() - v >= Tt && (m = !0, b(!0))), m && g && (h = [h[0] + (e.clientX - g.clientX) * wt, h[1] + (e.clientY - g.clientY) * wt]), g = {
|
|
1805
1957
|
clientX: e.clientX,
|
|
1806
1958
|
clientY: e.clientY,
|
|
1807
1959
|
pointerId: e.pointerId
|
|
@@ -1817,7 +1969,7 @@ function xt(e) {
|
|
|
1817
1969
|
`height:${J}px`,
|
|
1818
1970
|
"box-sizing:border-box",
|
|
1819
1971
|
"padding-top:8px",
|
|
1820
|
-
`padding-bottom:${
|
|
1972
|
+
`padding-bottom:${St}px`,
|
|
1821
1973
|
"display:flex",
|
|
1822
1974
|
"flex-direction:column",
|
|
1823
1975
|
"z-index:999998",
|
|
@@ -1845,13 +1997,13 @@ function xt(e) {
|
|
|
1845
1997
|
r = e, E();
|
|
1846
1998
|
},
|
|
1847
1999
|
setConfig(e) {
|
|
1848
|
-
let t = a && e && i &&
|
|
2000
|
+
let t = a && e && i && At(e) === At(i);
|
|
1849
2001
|
i = e, t ? T() : E();
|
|
1850
2002
|
}
|
|
1851
2003
|
};
|
|
1852
2004
|
}
|
|
1853
2005
|
/** Everything about a config except its per-key styling, so a styling-only update can be spotted. */
|
|
1854
|
-
var
|
|
2006
|
+
var At = (e) => JSON.stringify([
|
|
1855
2007
|
e.layout,
|
|
1856
2008
|
e.symbols,
|
|
1857
2009
|
e.highlight,
|
|
@@ -1863,9 +2015,9 @@ var St = (e) => JSON.stringify([
|
|
|
1863
2015
|
e.keyStyles
|
|
1864
2016
|
]);
|
|
1865
2017
|
/** 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()}`)}:${
|
|
2018
|
+
const X = (e) => Object.entries(e == null ? {} : e).map(([e, t]) => `${e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`)}:${Dt(String(t))}`).join(";");
|
|
1867
2019
|
/** Renders a single keyboard key as an HTML button string */
|
|
1868
|
-
var
|
|
2020
|
+
var jt = (e, t) => {
|
|
1869
2021
|
var n, r, i, a;
|
|
1870
2022
|
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 = [
|
|
1871
2023
|
"sim-kb-key",
|
|
@@ -1876,9 +2028,9 @@ var Ct = (e, t) => {
|
|
|
1876
2028
|
d ? "grow" : ""
|
|
1877
2029
|
].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
2030
|
return `<button class="${f}" data-key="${e}" style="${p}" ${s ? "disabled" : ""}><span style="${m}">${o}</span></button>`;
|
|
1879
|
-
},
|
|
1880
|
-
function
|
|
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>` :
|
|
2031
|
+
}, Mt = (e) => `<div class="sim-kb">${e.layout.filter((e) => e != null).map((t) => `<div class="sim-kb-row">${[...t].map((t) => jt(t, e)).join("")}</div>`).join("")}</div>`;
|
|
2032
|
+
function Nt() {
|
|
2033
|
+
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>` : Mt(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>";
|
|
1882
2034
|
return {
|
|
1883
2035
|
id: "kbd",
|
|
1884
2036
|
label: "Kbd",
|
|
@@ -1898,14 +2050,14 @@ function Tt() {
|
|
|
1898
2050
|
`;
|
|
1899
2051
|
},
|
|
1900
2052
|
bind(e) {
|
|
1901
|
-
t != null || (t =
|
|
2053
|
+
t != null || (t = kt({
|
|
1902
2054
|
theme: e.state.selectedTheme,
|
|
1903
2055
|
sendToGame: e.sendToGame
|
|
1904
2056
|
})), t.setEnabled(e.state.keyboardDocked);
|
|
1905
2057
|
let n = e.getElement("#sim-kb-dock");
|
|
1906
2058
|
n && (n.checked = e.state.keyboardDocked, n.addEventListener("change", () => {
|
|
1907
2059
|
e.state.keyboardDocked = n.checked, m(n.checked), t == null || t.setEnabled(n.checked), r(e);
|
|
1908
|
-
})),
|
|
2060
|
+
})), Pt(e);
|
|
1909
2061
|
},
|
|
1910
2062
|
onMessage(n, i, a) {
|
|
1911
2063
|
var o;
|
|
@@ -1915,11 +2067,11 @@ function Tt() {
|
|
|
1915
2067
|
/** Re-render the tab's own content (not the dock) and rebind its keys. */
|
|
1916
2068
|
function r(e) {
|
|
1917
2069
|
let t = e.getElement("#sim-kb-content");
|
|
1918
|
-
t && (t.innerHTML = n(e.state.keyboardDocked),
|
|
2070
|
+
t && (t.innerHTML = n(e.state.keyboardDocked), Pt(e));
|
|
1919
2071
|
}
|
|
1920
2072
|
}
|
|
1921
2073
|
/** Attach click handlers to all rendered keys */
|
|
1922
|
-
function
|
|
2074
|
+
function Pt(e) {
|
|
1923
2075
|
var t;
|
|
1924
2076
|
let n = (t = e.getElement("#sim-kb-content")) == null ? void 0 : t.querySelectorAll(".sim-kb-key");
|
|
1925
2077
|
n == null || n.forEach((t) => {
|
|
@@ -1934,10 +2086,10 @@ function Et(e) {
|
|
|
1934
2086
|
* change values (persisted to localStorage and pushed to the game as SETTINGS_UPDATE, matching the
|
|
1935
2087
|
* production host) and reflects UPDATE_SETTINGS_FROM_EMBED writes coming from the game.
|
|
1936
2088
|
*/
|
|
1937
|
-
function
|
|
2089
|
+
function Ft() {
|
|
1938
2090
|
let t = (e) => {
|
|
1939
2091
|
let t = e.state.settingsComponents;
|
|
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) =>
|
|
2092
|
+
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) => It(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>`;
|
|
1941
2093
|
}, n = (e) => {
|
|
1942
2094
|
let n = e.getElement("#sim-settings-content");
|
|
1943
2095
|
n && (n.innerHTML = t(e), i(e));
|
|
@@ -1958,7 +2110,7 @@ function Dt() {
|
|
|
1958
2110
|
});
|
|
1959
2111
|
}), (i = a.querySelector("#sim-settings-reset")) == null || i.addEventListener("click", () => {
|
|
1960
2112
|
var e;
|
|
1961
|
-
C(), t.state.gameSettings =
|
|
2113
|
+
C(), t.state.gameSettings = Lt((e = t.state.settingsComponents) == null ? [] : e), r(t), n(t);
|
|
1962
2114
|
}));
|
|
1963
2115
|
};
|
|
1964
2116
|
return {
|
|
@@ -1981,13 +2133,13 @@ function Dt() {
|
|
|
1981
2133
|
};
|
|
1982
2134
|
}
|
|
1983
2135
|
/** Renders a single settings UI component as HTML, reading its current value from `settings` */
|
|
1984
|
-
function
|
|
2136
|
+
function It(e, t) {
|
|
1985
2137
|
switch (e.type) {
|
|
1986
2138
|
case "title": return `<div class="sim-settings-heading">${Q(e.value)}</div>`;
|
|
1987
2139
|
case "subtitle": return `<div class="sim-settings-subheading">${Q(e.value)}</div>`;
|
|
1988
2140
|
case "paragraph": return `<p class="sim-settings-paragraph">${Q(e.value)}</p>`;
|
|
1989
2141
|
case "separator": return "<div class=\"simulator-divider\"></div>";
|
|
1990
|
-
case "split": return `<div class="sim-settings-split">${e.content.map((e) =>
|
|
2142
|
+
case "split": return `<div class="sim-settings-split">${e.content.map((e) => It(e, t)).join("")}</div>`;
|
|
1991
2143
|
case "boolean": {
|
|
1992
2144
|
var n;
|
|
1993
2145
|
let r = ((n = t[e.name]) == null ? e.defaultValue : n) ? "checked" : "", i = e.subtitle ? `<div class="sim-settings-subtitle">${Q(e.subtitle)}</div>` : "";
|
|
@@ -2055,9 +2207,9 @@ function Z(e) {
|
|
|
2055
2207
|
return `<span class="simulator-label">${Q(e.title)}</span>${t}`;
|
|
2056
2208
|
}
|
|
2057
2209
|
/** Collects name → defaultValue pairs from components, recursing into split groups */
|
|
2058
|
-
function
|
|
2210
|
+
function Lt(e) {
|
|
2059
2211
|
let t = {};
|
|
2060
|
-
for (let n of e) n.type === "split" ? Object.assign(t,
|
|
2212
|
+
for (let n of e) n.type === "split" ? Object.assign(t, Lt(n.content)) : "name" in n && (t[n.name] = n.defaultValue);
|
|
2061
2213
|
return t;
|
|
2062
2214
|
}
|
|
2063
2215
|
function Q(e) {
|
|
@@ -2068,8 +2220,8 @@ function Q(e) {
|
|
|
2068
2220
|
* parts the host owns: the sound-enabled gate (games boot muted, so this is what lets you hear
|
|
2069
2221
|
* anything) and a log of the cues the game asked us for, with any haptic it wanted.
|
|
2070
2222
|
*/
|
|
2071
|
-
function
|
|
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">${
|
|
2223
|
+
function Rt() {
|
|
2224
|
+
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">${Bt(e.id)}</span>${e.haptic ? `<span class="sound-haptic">${Bt(e.haptic)}</span>` : ""}<span class="sound-time">${e.time}</span></div>`).join(""), r = (t) => {
|
|
2073
2225
|
let r = t.getElement("#sound-events");
|
|
2074
2226
|
r && (r.innerHTML = n()), t.updateBadge("sound", e.length);
|
|
2075
2227
|
};
|
|
@@ -2116,13 +2268,13 @@ function At() {
|
|
|
2116
2268
|
n === "SENSORY_EVENT" && (e.unshift({
|
|
2117
2269
|
id: (o = i == null ? void 0 : i.id) == null ? JSON.stringify(i) : o,
|
|
2118
2270
|
haptic: i == null ? void 0 : i.haptic,
|
|
2119
|
-
time:
|
|
2271
|
+
time: zt()
|
|
2120
2272
|
}), e.length > 100 && e.pop(), r(a));
|
|
2121
2273
|
}
|
|
2122
2274
|
};
|
|
2123
2275
|
}
|
|
2124
2276
|
/** Current wall-clock time as HH:MM:SS, matching the simulator's message log formatting. */
|
|
2125
|
-
function
|
|
2277
|
+
function zt() {
|
|
2126
2278
|
return (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
|
|
2127
2279
|
hour12: !1,
|
|
2128
2280
|
hour: "2-digit",
|
|
@@ -2131,16 +2283,16 @@ function jt() {
|
|
|
2131
2283
|
});
|
|
2132
2284
|
}
|
|
2133
2285
|
/** Minimal HTML-escape so event ids can't break the simulator markup. */
|
|
2134
|
-
function
|
|
2286
|
+
function Bt(e) {
|
|
2135
2287
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
2136
2288
|
}
|
|
2137
2289
|
var $ = null;
|
|
2138
2290
|
/** True when the game is embedded in the real Puzzmo app, which sets `?developer=true` on the iframe. */
|
|
2139
|
-
function
|
|
2291
|
+
function Vt() {
|
|
2140
2292
|
return typeof window > "u" ? !1 : new URLSearchParams(window.location.search).has("developer");
|
|
2141
2293
|
}
|
|
2142
2294
|
/** Inert instance returned when the simulator declines to boot (the app is the host). */
|
|
2143
|
-
var
|
|
2295
|
+
var Ht = {
|
|
2144
2296
|
updateFixtures: () => {},
|
|
2145
2297
|
sendToGame: () => {},
|
|
2146
2298
|
loadPuzzle: function() {
|
|
@@ -2189,37 +2341,38 @@ var Pt = {
|
|
|
2189
2341
|
* Fixtures are loaded as raw strings and passed to the game verbatim (any text format works; the game parses it).
|
|
2190
2342
|
* This will show dropdowns in the Ctrl tab to select category and puzzle.
|
|
2191
2343
|
*/
|
|
2192
|
-
function
|
|
2193
|
-
var r, i, a;
|
|
2194
|
-
if (
|
|
2344
|
+
function Ut(n = {}) {
|
|
2345
|
+
var r, i, a, o, s;
|
|
2346
|
+
if (Vt()) return console.log("[Simulator] developer=true in URL — running inside the Puzzmo app, skipping simulator boot"), Ht;
|
|
2195
2347
|
if (console.log("[Simulator] createSimulator called with config:", {
|
|
2196
2348
|
slug: n.slug,
|
|
2197
2349
|
hasFixtures: !!n.fixtures
|
|
2198
2350
|
}), $) return n.fixtures && (console.log("[Simulator] Instance already exists, updating fixtures"), $.updateFixtures(n.fixtures)), $;
|
|
2199
|
-
let
|
|
2200
|
-
ce(),
|
|
2351
|
+
let c = (r = n.autoStart) == null ? !0 : r, l = n.fixtures ? oe(n.fixtures) : null, u = l ? Array.from(l.keys()).sort() : [], d = he(), f = je(), p = [
|
|
2201
2352
|
le(),
|
|
2202
|
-
|
|
2203
|
-
|
|
2353
|
+
ue(),
|
|
2354
|
+
d,
|
|
2204
2355
|
ge(),
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2356
|
+
_e(),
|
|
2357
|
+
we((i = (a = n.integrations) == null ? void 0 : a.checklists) == null ? [] : i),
|
|
2358
|
+
f,
|
|
2359
|
+
Ne(),
|
|
2360
|
+
Fe(n.hostContextPresets),
|
|
2361
|
+
tt(),
|
|
2362
|
+
bt(),
|
|
2363
|
+
Nt(),
|
|
2364
|
+
Ft(),
|
|
2365
|
+
Rt(),
|
|
2366
|
+
...(o = n.views) == null ? [] : o
|
|
2367
|
+
], m = p.map((e) => e.id), h = ee(n, u, m), g = {
|
|
2215
2368
|
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>",
|
|
2216
2369
|
play: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><polygon points=\"2,1 9,5 2,9\"/></svg>",
|
|
2217
2370
|
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>",
|
|
2218
2371
|
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>",
|
|
2219
2372
|
minimize: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><rect x=\"1\" y=\"4\" width=\"8\" height=\"2\"/></svg>",
|
|
2220
2373
|
expand: "<svg width=\"8\" height=\"8\" viewBox=\"0 0 8 8\" fill=\"currentColor\"><polygon points=\"1,1 7,4 1,7\"/></svg>"
|
|
2221
|
-
},
|
|
2222
|
-
|
|
2374
|
+
}, _ = document.createElement("div");
|
|
2375
|
+
_.id = "simulator", _.dataset.puzzmoBuild = ce, _.innerHTML = `
|
|
2223
2376
|
<style>
|
|
2224
2377
|
:root {
|
|
2225
2378
|
--sim-bg: #1a1a2e;
|
|
@@ -3395,6 +3548,128 @@ function Ft(n = {}) {
|
|
|
3395
3548
|
color: var(--sim-text-dim);
|
|
3396
3549
|
font-size: 9px;
|
|
3397
3550
|
}
|
|
3551
|
+
/* Checklist view styles */
|
|
3552
|
+
.checklist-view-container {
|
|
3553
|
+
display: flex;
|
|
3554
|
+
flex-direction: column;
|
|
3555
|
+
gap: 10px;
|
|
3556
|
+
overflow-y: auto;
|
|
3557
|
+
}
|
|
3558
|
+
.checklist-header {
|
|
3559
|
+
display: flex;
|
|
3560
|
+
align-items: center;
|
|
3561
|
+
gap: 6px;
|
|
3562
|
+
padding-bottom: 4px;
|
|
3563
|
+
margin-bottom: 4px;
|
|
3564
|
+
border-bottom: 1px solid var(--sim-border);
|
|
3565
|
+
}
|
|
3566
|
+
.checklist-progress {
|
|
3567
|
+
flex: 1;
|
|
3568
|
+
color: var(--sim-text-dim);
|
|
3569
|
+
font-size: 10px;
|
|
3570
|
+
}
|
|
3571
|
+
.checklist-progress.complete {
|
|
3572
|
+
color: var(--sim-success);
|
|
3573
|
+
}
|
|
3574
|
+
.checklist-items {
|
|
3575
|
+
display: flex;
|
|
3576
|
+
flex-direction: column;
|
|
3577
|
+
gap: 1px;
|
|
3578
|
+
}
|
|
3579
|
+
.checklist-item {
|
|
3580
|
+
padding: 3px 6px;
|
|
3581
|
+
border-left: 3px solid transparent;
|
|
3582
|
+
}
|
|
3583
|
+
.checklist-item.done {
|
|
3584
|
+
opacity: 0.5;
|
|
3585
|
+
}
|
|
3586
|
+
.checklist-item.upcoming {
|
|
3587
|
+
opacity: 0.35;
|
|
3588
|
+
}
|
|
3589
|
+
.checklist-item.active {
|
|
3590
|
+
border-left-color: var(--sim-accent);
|
|
3591
|
+
background: var(--sim-bg);
|
|
3592
|
+
}
|
|
3593
|
+
.checklist-row {
|
|
3594
|
+
display: flex;
|
|
3595
|
+
align-items: center;
|
|
3596
|
+
gap: 6px;
|
|
3597
|
+
}
|
|
3598
|
+
.checklist-tick {
|
|
3599
|
+
color: var(--sim-text-dim);
|
|
3600
|
+
}
|
|
3601
|
+
.checklist-item.done .checklist-tick {
|
|
3602
|
+
color: var(--sim-success);
|
|
3603
|
+
}
|
|
3604
|
+
.checklist-title {
|
|
3605
|
+
flex: 1;
|
|
3606
|
+
color: var(--sim-text);
|
|
3607
|
+
}
|
|
3608
|
+
.checklist-item.active .checklist-title {
|
|
3609
|
+
color: var(--sim-accent);
|
|
3610
|
+
font-weight: bold;
|
|
3611
|
+
}
|
|
3612
|
+
.checklist-count {
|
|
3613
|
+
color: var(--sim-text-dim);
|
|
3614
|
+
font-size: 10px;
|
|
3615
|
+
}
|
|
3616
|
+
.checklist-help {
|
|
3617
|
+
width: 14px;
|
|
3618
|
+
height: 14px;
|
|
3619
|
+
padding: 0;
|
|
3620
|
+
border: 1px solid var(--sim-border-light);
|
|
3621
|
+
border-radius: 50%;
|
|
3622
|
+
background: transparent;
|
|
3623
|
+
color: var(--sim-text-dim);
|
|
3624
|
+
font: inherit;
|
|
3625
|
+
font-size: 9px;
|
|
3626
|
+
line-height: 12px;
|
|
3627
|
+
cursor: pointer;
|
|
3628
|
+
}
|
|
3629
|
+
.checklist-help:hover, .checklist-help.open {
|
|
3630
|
+
color: var(--sim-accent);
|
|
3631
|
+
border-color: var(--sim-accent);
|
|
3632
|
+
}
|
|
3633
|
+
.checklist-subtitle {
|
|
3634
|
+
margin: 2px 0 0 15px;
|
|
3635
|
+
color: var(--sim-text-dim);
|
|
3636
|
+
font-size: 10px;
|
|
3637
|
+
}
|
|
3638
|
+
.checklist-expand {
|
|
3639
|
+
margin: 4px 0 0 15px;
|
|
3640
|
+
padding: 4px 6px;
|
|
3641
|
+
background: var(--sim-panel);
|
|
3642
|
+
border: 1px solid var(--sim-border);
|
|
3643
|
+
border-radius: 2px;
|
|
3644
|
+
color: var(--sim-text);
|
|
3645
|
+
font: inherit;
|
|
3646
|
+
font-size: 10px;
|
|
3647
|
+
white-space: pre-wrap;
|
|
3648
|
+
text-align: left;
|
|
3649
|
+
user-select: text;
|
|
3650
|
+
}
|
|
3651
|
+
.checklist-divider {
|
|
3652
|
+
display: flex;
|
|
3653
|
+
align-items: center;
|
|
3654
|
+
gap: 6px;
|
|
3655
|
+
margin: 3px 0;
|
|
3656
|
+
color: var(--sim-text-dim);
|
|
3657
|
+
font-size: 9px;
|
|
3658
|
+
}
|
|
3659
|
+
.checklist-divider::before, .checklist-divider::after {
|
|
3660
|
+
content: "";
|
|
3661
|
+
flex: 1;
|
|
3662
|
+
border-top: 1px dashed var(--sim-border-light);
|
|
3663
|
+
}
|
|
3664
|
+
.checklist-footer {
|
|
3665
|
+
margin-top: 4px;
|
|
3666
|
+
color: var(--sim-text-dim);
|
|
3667
|
+
font-size: 9px;
|
|
3668
|
+
}
|
|
3669
|
+
.checklist-error {
|
|
3670
|
+
color: var(--sim-error);
|
|
3671
|
+
font-size: 9px;
|
|
3672
|
+
}
|
|
3398
3673
|
/* Keyboard view styles */
|
|
3399
3674
|
.keyboard-view-container {
|
|
3400
3675
|
padding: 4px;
|
|
@@ -3537,15 +3812,15 @@ function Ft(n = {}) {
|
|
|
3537
3812
|
border-top: 2px solid var(--sim-border);
|
|
3538
3813
|
}
|
|
3539
3814
|
</style>
|
|
3540
|
-
<div id="simulator-panel" class="${
|
|
3815
|
+
<div id="simulator-panel" class="${h.isCollapsed ? "collapsed" : ""}">
|
|
3541
3816
|
<div id="simulator-header">
|
|
3542
3817
|
<span id="simulator-title">PUZZMO SIMULATOR</span>
|
|
3543
3818
|
<span class="header-sep">|</span>
|
|
3544
3819
|
<div id="simulator-timer">--:--</div>
|
|
3545
3820
|
<span class="header-sep">|</span>
|
|
3546
3821
|
<div id="simulator-header-controls">
|
|
3547
|
-
<button id="simulator-header-pause" class="header-icon-btn" title="Pause" disabled>${
|
|
3548
|
-
<button id="simulator-header-retry" class="header-icon-btn" title="Retry" disabled>${
|
|
3822
|
+
<button id="simulator-header-pause" class="header-icon-btn" title="Pause" disabled>${g.pause}</button>
|
|
3823
|
+
<button id="simulator-header-retry" class="header-icon-btn" title="Retry" disabled>${g.retry}</button>
|
|
3549
3824
|
</div>
|
|
3550
3825
|
<span class="header-sep">|</span>
|
|
3551
3826
|
<div id="simulator-header-status">
|
|
@@ -3553,108 +3828,108 @@ function Ft(n = {}) {
|
|
|
3553
3828
|
<span id="simulator-header-status-text">Waiting...</span>
|
|
3554
3829
|
</div>
|
|
3555
3830
|
<span class="header-spacer"></span>
|
|
3556
|
-
<button id="simulator-header-settings" class="header-icon-btn" title="Settings">${
|
|
3557
|
-
<button id="simulator-toggle" class="header-icon-btn" title="Minimize">${
|
|
3831
|
+
<button id="simulator-header-settings" class="header-icon-btn" title="Settings">${g.cog}</button>
|
|
3832
|
+
<button id="simulator-toggle" class="header-icon-btn" title="Minimize">${g.minimize}</button>
|
|
3558
3833
|
</div>
|
|
3559
3834
|
<div id="simulator-body">
|
|
3560
3835
|
<div id="simulator-tabs">
|
|
3561
|
-
${
|
|
3836
|
+
${p.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("")}
|
|
3562
3837
|
</div>
|
|
3563
3838
|
<div id="simulator-content" class="hidden">
|
|
3564
|
-
${
|
|
3839
|
+
${p.map((e) => `<div id="simulator-tab-${e.id}" class="simulator-tab-content">${e.render()}</div>`).join("")}
|
|
3565
3840
|
</div>
|
|
3566
3841
|
</div>
|
|
3567
3842
|
</div>
|
|
3568
|
-
`, document.body.appendChild(
|
|
3569
|
-
let
|
|
3570
|
-
|
|
3571
|
-
},
|
|
3572
|
-
let n =
|
|
3573
|
-
n && (n.textContent = e), r && (r.className = `indicator ${t}`, r.textContent = i),
|
|
3574
|
-
},
|
|
3575
|
-
t && t !== "0" ?
|
|
3576
|
-
},
|
|
3843
|
+
`, document.body.appendChild(_);
|
|
3844
|
+
let v = _.querySelector("#simulator-panel"), y = _.querySelector("#simulator-header"), b = _.querySelector("#simulator-header-indicator"), x = _.querySelector("#simulator-header-status-text"), S = _.querySelector("#simulator-header-pause"), C = _.querySelector("#simulator-header-retry"), w = _.querySelector("#simulator-header-settings"), T = _.querySelector("#simulator-toggle"), E = _.querySelector("#simulator-timer"), D = _.querySelector("#simulator-tabs"), O = _.querySelector("#simulator-content"), k = (e) => _.querySelector(e), A = (e) => {
|
|
3845
|
+
S.innerHTML = e ? g.play : g.pause, S.title = e ? "Resume" : "Pause";
|
|
3846
|
+
}, j = (e, t) => {
|
|
3847
|
+
let n = k("#simulator-status .text"), r = k("#simulator-status .indicator"), i = t === "complete" ? "✓" : "";
|
|
3848
|
+
n && (n.textContent = e), r && (r.className = `indicator ${t}`, r.textContent = i), b.className = t, b.textContent = i, x.textContent = e;
|
|
3849
|
+
}, se = (e, t) => {
|
|
3850
|
+
t && t !== "0" ? E.innerHTML = `${e}<span class="penalty">+${t}</span>` : E.textContent = e;
|
|
3851
|
+
}, M = (e) => {
|
|
3577
3852
|
var t;
|
|
3578
|
-
|
|
3853
|
+
h.activeTab = e, O.classList.remove("hidden"), ne(e), D.querySelectorAll(".simulator-tab").forEach((t) => {
|
|
3579
3854
|
t.classList.toggle("active", t.getAttribute("data-tab") === e);
|
|
3580
|
-
}),
|
|
3855
|
+
}), _.querySelectorAll(".simulator-tab-content").forEach((t) => {
|
|
3581
3856
|
t.classList.toggle("active", t.id === `simulator-tab-${e}`);
|
|
3582
|
-
}),
|
|
3583
|
-
let n =
|
|
3584
|
-
n == null || (t = n.onActivate) == null || t.call(n,
|
|
3585
|
-
},
|
|
3586
|
-
|
|
3587
|
-
},
|
|
3588
|
-
|
|
3589
|
-
},
|
|
3857
|
+
}), w.classList.toggle("active", e === "auth");
|
|
3858
|
+
let n = p.find((t) => t.id === e);
|
|
3859
|
+
n == null || (t = n.onActivate) == null || t.call(n, z);
|
|
3860
|
+
}, N = (e) => {
|
|
3861
|
+
h.isCollapsed = e, v.classList.toggle("collapsed", e), te(e), e ? (O.classList.add("hidden"), D.querySelectorAll(".simulator-tab").forEach((e) => e.classList.remove("active"))) : M(h.activeTab);
|
|
3862
|
+
}, P = () => {
|
|
3863
|
+
f.updatePreview(z);
|
|
3864
|
+
}, F = function() {
|
|
3590
3865
|
var e = t(function* () {
|
|
3591
3866
|
var e, t;
|
|
3592
|
-
if (
|
|
3593
|
-
if (
|
|
3594
|
-
if (!
|
|
3595
|
-
let n = (e =
|
|
3867
|
+
if (h.appliedPuzzleOverride !== null) return h.appliedPuzzleOverride;
|
|
3868
|
+
if (h.puzzleData) return h.puzzleData;
|
|
3869
|
+
if (!l || l.size === 0) throw Error("No fixtures configured. Add puzzle fixture files (.json or .toml) to a fixtures directory and pass fixturesGlob to the simulator.");
|
|
3870
|
+
let n = (e = h.selectedCategory) == null ? u[0] : e, r = n ? l.get(n) : void 0;
|
|
3596
3871
|
if (!r || r.size === 0) throw Error(`No puzzles found in fixture category "${n}"`);
|
|
3597
|
-
let i = (t =
|
|
3872
|
+
let i = (t = h.selectedPuzzle) == null ? r.keys().next().value : t, a = i ? r.get(i) : void 0;
|
|
3598
3873
|
if (!a) throw Error(`Puzzle "${i}" not found in category "${n}"`);
|
|
3599
|
-
|
|
3874
|
+
h.puzzleData = a, console.log("Simulator: Puzzle loaded from fixtures", {
|
|
3600
3875
|
category: n,
|
|
3601
3876
|
puzzle: i
|
|
3602
|
-
}),
|
|
3603
|
-
let o =
|
|
3604
|
-
return o && (o.value =
|
|
3877
|
+
}), h.originalPuzzle = a;
|
|
3878
|
+
let o = k("#simulator-puzzle");
|
|
3879
|
+
return o && (o.value = h.originalPuzzle), h.activeTab === "thumb" && P(), h.puzzleData;
|
|
3605
3880
|
});
|
|
3606
3881
|
return function() {
|
|
3607
3882
|
return e.apply(this, arguments);
|
|
3608
3883
|
};
|
|
3609
|
-
}(),
|
|
3610
|
-
|
|
3611
|
-
}),
|
|
3612
|
-
ie(e, t,
|
|
3613
|
-
},
|
|
3614
|
-
let n =
|
|
3884
|
+
}(), I = re((e) => {
|
|
3885
|
+
d.addLogEntry(e, z);
|
|
3886
|
+
}), L = (e, t) => {
|
|
3887
|
+
ie(e, t, I);
|
|
3888
|
+
}, R = (e, t) => {
|
|
3889
|
+
let n = _.querySelector(`[data-badge="${e}"]`);
|
|
3615
3890
|
n && (n.textContent = t && t > 0 ? String(t) : "");
|
|
3616
|
-
},
|
|
3617
|
-
state:
|
|
3618
|
-
getElement:
|
|
3619
|
-
sendToGame:
|
|
3620
|
-
logMessage:
|
|
3621
|
-
loadPuzzle:
|
|
3622
|
-
updateStatus:
|
|
3623
|
-
updateTimer:
|
|
3624
|
-
setCollapsed:
|
|
3625
|
-
switchTab:
|
|
3626
|
-
updateThumbnail:
|
|
3627
|
-
updateBadge:
|
|
3628
|
-
fixtures:
|
|
3629
|
-
fixtureCategories:
|
|
3630
|
-
gameSlug: (
|
|
3891
|
+
}, z = {
|
|
3892
|
+
state: h,
|
|
3893
|
+
getElement: k,
|
|
3894
|
+
sendToGame: L,
|
|
3895
|
+
logMessage: I.log,
|
|
3896
|
+
loadPuzzle: F,
|
|
3897
|
+
updateStatus: j,
|
|
3898
|
+
updateTimer: se,
|
|
3899
|
+
setCollapsed: N,
|
|
3900
|
+
switchTab: M,
|
|
3901
|
+
updateThumbnail: P,
|
|
3902
|
+
updateBadge: R,
|
|
3903
|
+
fixtures: l,
|
|
3904
|
+
fixtureCategories: u,
|
|
3905
|
+
gameSlug: (s = n.slug) == null ? null : s
|
|
3631
3906
|
};
|
|
3632
|
-
console.log("[Simulator] Context created with gameSlug:",
|
|
3907
|
+
console.log("[Simulator] Context created with gameSlug:", z.gameSlug), p.forEach((e) => e.bind(z)), D.querySelectorAll(".simulator-tab").forEach((e) => {
|
|
3633
3908
|
e.addEventListener("click", () => {
|
|
3634
3909
|
let t = e.getAttribute("data-tab");
|
|
3635
|
-
|
|
3910
|
+
M(t), R(t, 0);
|
|
3636
3911
|
});
|
|
3912
|
+
}), T.addEventListener("click", (e) => {
|
|
3913
|
+
e.stopPropagation(), N(!0);
|
|
3914
|
+
}), S.addEventListener("click", (e) => {
|
|
3915
|
+
e.stopPropagation(), h.isPaused ? (L("RESUME_GAME", {}), h.isPaused = !1, A(!1), j("Running", "ready")) : (L("PAUSE_GAME", {}), h.isPaused = !0, A(!0), j("Paused", "paused"));
|
|
3916
|
+
let t = k("#simulator-pause");
|
|
3917
|
+
t && (t.textContent = h.isPaused ? "Resume" : "Pause");
|
|
3637
3918
|
}), C.addEventListener("click", (e) => {
|
|
3638
|
-
e.stopPropagation(),
|
|
3639
|
-
|
|
3640
|
-
e.stopPropagation(), p.isPaused ? (I("RESUME_GAME", {}), p.isPaused = !1, O(!1), k("Running", "ready")) : (I("PAUSE_GAME", {}), p.isPaused = !0, O(!0), k("Paused", "paused"));
|
|
3641
|
-
let t = D("#simulator-pause");
|
|
3642
|
-
t && (t.textContent = p.isPaused ? "Resume" : "Pause");
|
|
3643
|
-
}), x.addEventListener("click", (e) => {
|
|
3644
|
-
e.stopPropagation(), I("RETRY_PUZZLE", {}), p.hasStarted = !1, p.isPaused = !1, O(!1), b.disabled = !0, k("Ready to retry", "ready");
|
|
3645
|
-
let t = D("#simulator-pause"), n = D("#simulator-start");
|
|
3919
|
+
e.stopPropagation(), L("RETRY_PUZZLE", {}), h.hasStarted = !1, h.isPaused = !1, A(!1), S.disabled = !0, j("Ready to retry", "ready");
|
|
3920
|
+
let t = k("#simulator-pause"), n = k("#simulator-start");
|
|
3646
3921
|
t && (t.disabled = !0, t.textContent = "Pause"), n && (n.textContent = "Start");
|
|
3647
|
-
}),
|
|
3648
|
-
e.stopPropagation(),
|
|
3649
|
-
}),
|
|
3650
|
-
|
|
3651
|
-
}),
|
|
3652
|
-
let
|
|
3653
|
-
(
|
|
3654
|
-
let
|
|
3922
|
+
}), w.addEventListener("click", (e) => {
|
|
3923
|
+
e.stopPropagation(), h.isCollapsed && N(!1), M("auth");
|
|
3924
|
+
}), y.addEventListener("click", (e) => {
|
|
3925
|
+
h.isCollapsed && e.target !== T && N(!1);
|
|
3926
|
+
}), h.isCollapsed || M(h.activeTab);
|
|
3927
|
+
let B = new URLSearchParams(window.location.search);
|
|
3928
|
+
(B.has("code") || B.has("error")) && (N(!1), M("auth"));
|
|
3929
|
+
let V = (e) => {
|
|
3655
3930
|
let t = {
|
|
3656
3931
|
additionalTimeAddedSecs: 0,
|
|
3657
|
-
boardState:
|
|
3932
|
+
boardState: h.currentInputStr,
|
|
3658
3933
|
combinedTimeSecs: 0,
|
|
3659
3934
|
completed: !1,
|
|
3660
3935
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -3672,7 +3947,7 @@ function Ft(n = {}) {
|
|
|
3672
3947
|
};
|
|
3673
3948
|
return {
|
|
3674
3949
|
userState: {
|
|
3675
|
-
gameSettings: { "proto-game":
|
|
3950
|
+
gameSettings: { "proto-game": h.gameSettings },
|
|
3676
3951
|
id: "simulator-user",
|
|
3677
3952
|
ownerID: "simulator-owner"
|
|
3678
3953
|
},
|
|
@@ -3684,51 +3959,51 @@ function Ft(n = {}) {
|
|
|
3684
3959
|
type: "User",
|
|
3685
3960
|
roles: ""
|
|
3686
3961
|
},
|
|
3687
|
-
game:
|
|
3962
|
+
game: Wt,
|
|
3688
3963
|
session: {
|
|
3689
3964
|
gameplay: t,
|
|
3690
3965
|
puzzle: n
|
|
3691
3966
|
},
|
|
3692
|
-
theme:
|
|
3693
|
-
hostContext:
|
|
3967
|
+
theme: h.selectedTheme,
|
|
3968
|
+
hostContext: h.hostContext,
|
|
3694
3969
|
appRuntimeContract: "1.0"
|
|
3695
3970
|
};
|
|
3696
|
-
},
|
|
3971
|
+
}, H = function() {
|
|
3697
3972
|
var n = t(function* (t) {
|
|
3698
|
-
|
|
3973
|
+
j("Loading puzzle...", "waiting");
|
|
3699
3974
|
try {
|
|
3700
|
-
let n = e(e({},
|
|
3701
|
-
|
|
3975
|
+
let n = e(e({}, V(yield F())), {}, { appRuntimeContract: t });
|
|
3976
|
+
j("Sending READY_DATA...", "waiting"), L("READY_DATA", n), j("Waiting for game to load...", "waiting");
|
|
3702
3977
|
} catch (e) {
|
|
3703
|
-
|
|
3978
|
+
j(`Error: ${e}`, "paused");
|
|
3704
3979
|
}
|
|
3705
3980
|
});
|
|
3706
3981
|
return function(e) {
|
|
3707
3982
|
return n.apply(this, arguments);
|
|
3708
3983
|
};
|
|
3709
|
-
}(),
|
|
3710
|
-
console.log("Simulator: Game loaded, ready to start"),
|
|
3984
|
+
}(), de = () => {
|
|
3985
|
+
console.log("Simulator: Game loaded, ready to start"), C.disabled = !1, p.forEach((e) => {
|
|
3711
3986
|
var t;
|
|
3712
|
-
return (t = e.onMessage) == null ? void 0 : t.call(e, "READY_GAME_LOADED", void 0,
|
|
3713
|
-
}),
|
|
3714
|
-
let e =
|
|
3715
|
-
e == null || e.click(),
|
|
3987
|
+
return (t = e.onMessage) == null ? void 0 : t.call(e, "READY_GAME_LOADED", void 0, z);
|
|
3988
|
+
}), c && !h.hasStarted && setTimeout(() => {
|
|
3989
|
+
let e = k("#simulator-start");
|
|
3990
|
+
e == null || e.click(), S.disabled = !1, h.hasStarted = !0, j("Running", "ready");
|
|
3716
3991
|
}, 100);
|
|
3717
3992
|
};
|
|
3718
3993
|
return ae((e, t) => {
|
|
3719
3994
|
var n, r;
|
|
3720
3995
|
if (e === "READY") {
|
|
3721
|
-
console.log("Simulator: Received READY from game"),
|
|
3996
|
+
console.log("Simulator: Received READY from game"), H((t == null ? void 0 : t.runtimeContract) === "1.1" ? "1.1" : "1.0");
|
|
3722
3997
|
return;
|
|
3723
3998
|
}
|
|
3724
3999
|
if (e === "READY_GAME_LOADED") {
|
|
3725
|
-
|
|
4000
|
+
de();
|
|
3726
4001
|
return;
|
|
3727
4002
|
}
|
|
3728
4003
|
if (e === "TIMER_TICK") {
|
|
3729
4004
|
if (t != null && t.display) {
|
|
3730
4005
|
let [e, n] = t.display;
|
|
3731
|
-
|
|
4006
|
+
se(e, n);
|
|
3732
4007
|
}
|
|
3733
4008
|
return;
|
|
3734
4009
|
}
|
|
@@ -3737,32 +4012,32 @@ function Ft(n = {}) {
|
|
|
3737
4012
|
console.log("Simulator: Sidebar update", t);
|
|
3738
4013
|
return;
|
|
3739
4014
|
}
|
|
3740
|
-
|
|
4015
|
+
p.forEach((n) => {
|
|
3741
4016
|
var r;
|
|
3742
|
-
return (r = n.onMessage) == null ? void 0 : r.call(n, e, t,
|
|
4017
|
+
return (r = n.onMessage) == null ? void 0 : r.call(n, e, t, z);
|
|
3743
4018
|
});
|
|
3744
4019
|
let i = (n = t == null || (r = t.input) == null ? void 0 : r.boardState) == null ? t == null ? void 0 : t.boardState : n;
|
|
3745
|
-
e === "UPLOAD_NEW_GAME_STATE" && i && (
|
|
3746
|
-
},
|
|
4020
|
+
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), S.disabled = !0, h.hasStarted = !1, j("Completed!", "complete"));
|
|
4021
|
+
}, I), console.log("Simulator initialized"), $ = {
|
|
3747
4022
|
updateFixtures: (e) => {
|
|
3748
|
-
|
|
4023
|
+
l = oe(e), u = Array.from(l.keys()).sort(), z.fixtures = l, z.fixtureCategories = u;
|
|
3749
4024
|
let t = localStorage.getItem("simulator-fixture-category");
|
|
3750
|
-
if (!
|
|
4025
|
+
if (!h.selectedCategory || !u.includes(h.selectedCategory)) {
|
|
3751
4026
|
var n;
|
|
3752
|
-
|
|
4027
|
+
h.selectedCategory = t && u.includes(t) ? t : (n = u[0]) == null ? null : n;
|
|
3753
4028
|
}
|
|
3754
|
-
let r =
|
|
3755
|
-
r == null || r.bind(
|
|
3756
|
-
categories:
|
|
3757
|
-
selectedCategory:
|
|
4029
|
+
let r = p.find((e) => e.id === "ctrl");
|
|
4030
|
+
r == null || r.bind(z), console.log("Simulator: Fixtures updated", {
|
|
4031
|
+
categories: u,
|
|
4032
|
+
selectedCategory: h.selectedCategory
|
|
3758
4033
|
});
|
|
3759
4034
|
},
|
|
3760
|
-
sendToGame:
|
|
3761
|
-
loadPuzzle:
|
|
4035
|
+
sendToGame: L,
|
|
4036
|
+
loadPuzzle: F
|
|
3762
4037
|
}, $;
|
|
3763
4038
|
}
|
|
3764
4039
|
/** The game the simulator stands in for, with placeholder IDs since nothing is stored */
|
|
3765
|
-
var
|
|
4040
|
+
var Wt = {
|
|
3766
4041
|
id: "simulator-game",
|
|
3767
4042
|
slug: "proto-game",
|
|
3768
4043
|
stableSlug: "proto-game",
|
|
@@ -3778,6 +4053,6 @@ var It = {
|
|
|
3778
4053
|
}
|
|
3779
4054
|
}
|
|
3780
4055
|
};
|
|
3781
|
-
export {
|
|
4056
|
+
export { Rt as n, ce as r, Ut as t };
|
|
3782
4057
|
|
|
3783
|
-
//# sourceMappingURL=createSimulator-
|
|
4058
|
+
//# sourceMappingURL=createSimulator-DqxQK61P.js.map
|