@puzzmo/sdk 1.0.85 → 1.0.87
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/{createSimulator-CIE72Xs2.cjs → createSimulator-BfoUQbBk.cjs} +20 -20
- package/dist/{createSimulator-CIE72Xs2.cjs.map → createSimulator-BfoUQbBk.cjs.map} +1 -1
- package/dist/{createSimulator-Dz1KYZ25.js → createSimulator-Dk_oznjb.js} +546 -546
- package/dist/{createSimulator-Dz1KYZ25.js.map → createSimulator-Dk_oznjb.js.map} +1 -1
- package/dist/hostDialogs.spec.d.ts +2 -0
- package/dist/hostDialogs.spec.d.ts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.global.js +1 -1
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +38 -7
- package/dist/index.js.map +1 -1
- package/dist/sdk.d.ts +33 -7
- package/dist/sdk.d.ts.map +1 -1
- package/dist/simulator/index.cjs +1 -1
- package/dist/simulator/index.js +1 -1
- package/dist/simulator/standalone.cjs +1 -1
- package/dist/simulator/standalone.js +1 -1
- package/dist/simulator/views/PmmgView.d.ts.map +1 -1
- package/dist/types.d.ts +29 -4
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -510,31 +510,31 @@ function N() {
|
|
|
510
510
|
function P(e) {
|
|
511
511
|
localStorage.setItem(l.collapsed, String(e));
|
|
512
512
|
}
|
|
513
|
-
function
|
|
513
|
+
function F(e) {
|
|
514
514
|
localStorage.setItem(l.tab, e);
|
|
515
515
|
}
|
|
516
|
-
function
|
|
516
|
+
function I(e) {
|
|
517
517
|
localStorage.setItem(l.theme, e);
|
|
518
518
|
}
|
|
519
|
-
function
|
|
519
|
+
function L(e) {
|
|
520
520
|
localStorage.setItem(l.fixtureCategory, e);
|
|
521
521
|
}
|
|
522
|
-
function
|
|
522
|
+
function R(e) {
|
|
523
523
|
localStorage.setItem(l.fixturePuzzle, e);
|
|
524
524
|
}
|
|
525
|
-
function
|
|
525
|
+
function z() {
|
|
526
526
|
localStorage.removeItem(l.fixturePuzzle);
|
|
527
527
|
}
|
|
528
|
-
function
|
|
528
|
+
function B(e) {
|
|
529
529
|
e ? localStorage.setItem(l.renderHost, e) : localStorage.removeItem(l.renderHost);
|
|
530
530
|
}
|
|
531
|
-
function
|
|
531
|
+
function V(e) {
|
|
532
532
|
localStorage.setItem(l.previewKind, e);
|
|
533
533
|
}
|
|
534
|
-
function
|
|
534
|
+
function H(e) {
|
|
535
535
|
e ? localStorage.setItem(l.renderContext, e) : localStorage.removeItem(l.renderContext);
|
|
536
536
|
}
|
|
537
|
-
function
|
|
537
|
+
function ee(e) {
|
|
538
538
|
let t = [];
|
|
539
539
|
return {
|
|
540
540
|
log(n, r, i) {
|
|
@@ -559,13 +559,13 @@ function te(e) {
|
|
|
559
559
|
}
|
|
560
560
|
};
|
|
561
561
|
}
|
|
562
|
-
function
|
|
562
|
+
function te(e, t, n) {
|
|
563
563
|
console.log("Simulator sending:", e, t), n == null || n.log(e, t, "out"), window.postMessage({
|
|
564
564
|
type: e,
|
|
565
565
|
data: t
|
|
566
566
|
}, "*");
|
|
567
567
|
}
|
|
568
|
-
function
|
|
568
|
+
function ne(e, t) {
|
|
569
569
|
let n = (n) => {
|
|
570
570
|
var r, i, a;
|
|
571
571
|
if (!(!(n == null || (r = n.data) == null) && r.type)) return;
|
|
@@ -575,7 +575,7 @@ function re(e, t) {
|
|
|
575
575
|
return window.addEventListener("message", n), () => window.removeEventListener("message", n);
|
|
576
576
|
}
|
|
577
577
|
/** Parse fixture imports into a structured format: { category: { filename: data } } */
|
|
578
|
-
function
|
|
578
|
+
function U(e) {
|
|
579
579
|
let t = /* @__PURE__ */ new Map();
|
|
580
580
|
console.log("Simulator: Parsing fixtures", Object.keys(e));
|
|
581
581
|
for (let [o, s] of Object.entries(e)) {
|
|
@@ -594,7 +594,7 @@ function H(e) {
|
|
|
594
594
|
}), t;
|
|
595
595
|
}
|
|
596
596
|
/** Render fixture selector HTML */
|
|
597
|
-
function
|
|
597
|
+
function W(e, t) {
|
|
598
598
|
return e.length === 0 ? "" : `
|
|
599
599
|
<div class="simulator-fixtures">
|
|
600
600
|
<div class="simulator-field">
|
|
@@ -611,7 +611,7 @@ function ie(e, t) {
|
|
|
611
611
|
`;
|
|
612
612
|
}
|
|
613
613
|
/** Update puzzle select options based on selected category */
|
|
614
|
-
function
|
|
614
|
+
function G(e, t, n, r) {
|
|
615
615
|
let i = t.get(n);
|
|
616
616
|
if (!i) return null;
|
|
617
617
|
let a = Array.from(i.keys()), o = r;
|
|
@@ -622,7 +622,7 @@ function U(e, t, n, r) {
|
|
|
622
622
|
return e.innerHTML = a.map((e) => `<option value="${e}" ${e === o ? "selected" : ""}>${e}</option>`).join(""), o;
|
|
623
623
|
}
|
|
624
624
|
/** Get puzzle data from fixtures */
|
|
625
|
-
function
|
|
625
|
+
function K(e, t, n) {
|
|
626
626
|
var r, i;
|
|
627
627
|
return !t || !n || (r = (i = e.get(t)) == null ? void 0 : i.get(n)) == null ? null : r;
|
|
628
628
|
}
|
|
@@ -634,8 +634,8 @@ function W(e, t, n) {
|
|
|
634
634
|
* `puzzmo games validate` greps build output for it — keep it in sync with the copy in
|
|
635
635
|
* packages/cli/src/util/lintDist.ts.
|
|
636
636
|
*/
|
|
637
|
-
const
|
|
638
|
-
function
|
|
637
|
+
const re = "puzzmo-simulator-dev-only-do-not-ship";
|
|
638
|
+
function ie() {
|
|
639
639
|
return {
|
|
640
640
|
id: "ctrl",
|
|
641
641
|
label: "Ctrl",
|
|
@@ -650,19 +650,19 @@ function oe() {
|
|
|
650
650
|
selectedCategory: e.state.selectedCategory,
|
|
651
651
|
selectedPuzzle: e.state.selectedPuzzle
|
|
652
652
|
}), e.fixtures && e.fixtureCategories.length > 0 && i) {
|
|
653
|
-
i.innerHTML =
|
|
653
|
+
i.innerHTML = W(e.fixtureCategories, e.state.selectedCategory);
|
|
654
654
|
let t = e.getElement("#simulator-fixture-category"), n = e.getElement("#simulator-fixture-puzzle");
|
|
655
655
|
if (t && n && e.state.selectedCategory) {
|
|
656
|
-
e.state.selectedPuzzle =
|
|
657
|
-
let r =
|
|
656
|
+
e.state.selectedPuzzle = G(n, e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
|
|
657
|
+
let r = K(e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
|
|
658
658
|
console.log("Simulator: Loading fixture puzzle", {
|
|
659
659
|
category: e.state.selectedCategory,
|
|
660
660
|
puzzle: e.state.selectedPuzzle,
|
|
661
661
|
hasPuzzleData: !!r
|
|
662
|
-
}), r && (e.state.appliedPuzzleOverride === null && (e.state.puzzleData = r, e.state.originalPuzzle = r), e.state.selectedCategory &&
|
|
663
|
-
console.log("Simulator: Category changed, reloading...", t.value), h(),
|
|
662
|
+
}), r && (e.state.appliedPuzzleOverride === null && (e.state.puzzleData = r, e.state.originalPuzzle = r), e.state.selectedCategory && L(e.state.selectedCategory), e.state.selectedPuzzle && R(e.state.selectedPuzzle)), t.addEventListener("change", () => {
|
|
663
|
+
console.log("Simulator: Category changed, reloading...", t.value), h(), L(t.value), z(), window.location.reload();
|
|
664
664
|
}), n.addEventListener("change", () => {
|
|
665
|
-
console.log("Simulator: Puzzle changed, reloading...", n.value), h(),
|
|
665
|
+
console.log("Simulator: Puzzle changed, reloading...", n.value), h(), R(n.value), window.location.reload();
|
|
666
666
|
});
|
|
667
667
|
}
|
|
668
668
|
}
|
|
@@ -688,10 +688,10 @@ function oe() {
|
|
|
688
688
|
* Inlined here (rather than shared with the rest of the monorepo) because the SDK ships to OSS and
|
|
689
689
|
* must stay self-contained.
|
|
690
690
|
*/
|
|
691
|
-
function
|
|
691
|
+
function ae(e) {
|
|
692
692
|
var t;
|
|
693
693
|
if (typeof e != "string") return e;
|
|
694
|
-
let n = (t =
|
|
694
|
+
let n = (t = oe(e)) == null ? {
|
|
695
695
|
width: 800,
|
|
696
696
|
height: 800
|
|
697
697
|
} : t;
|
|
@@ -702,7 +702,7 @@ function se(e) {
|
|
|
702
702
|
};
|
|
703
703
|
}
|
|
704
704
|
/** Reads an SVG's intrinsic size from its `viewBox` (preferred) or its `width`/`height` attributes. */
|
|
705
|
-
function
|
|
705
|
+
function oe(e) {
|
|
706
706
|
var t, n, r, i;
|
|
707
707
|
let a = e.indexOf("<svg");
|
|
708
708
|
if (a === -1) return;
|
|
@@ -720,9 +720,9 @@ function ce(e) {
|
|
|
720
720
|
height: u
|
|
721
721
|
};
|
|
722
722
|
}
|
|
723
|
-
var
|
|
723
|
+
var se = "simulator-saved-states";
|
|
724
724
|
/** Find thumbnail function on globalThis (looks for functions ending in "Thumbnail") */
|
|
725
|
-
function
|
|
725
|
+
function ce() {
|
|
726
726
|
let e = globalThis;
|
|
727
727
|
for (let t of Object.keys(e)) if (t.endsWith("Thumbnail") && typeof e[t] == "function") return {
|
|
728
728
|
name: t,
|
|
@@ -731,8 +731,8 @@ function ue() {
|
|
|
731
731
|
return null;
|
|
732
732
|
}
|
|
733
733
|
/** Generate a small thumbnail SVG for a given input string */
|
|
734
|
-
function
|
|
735
|
-
let n =
|
|
734
|
+
function le(e, t) {
|
|
735
|
+
let n = ce();
|
|
736
736
|
if (!n) return "";
|
|
737
737
|
try {
|
|
738
738
|
var r;
|
|
@@ -742,19 +742,19 @@ function de(e, t) {
|
|
|
742
742
|
strict: !0,
|
|
743
743
|
renderHost: "game"
|
|
744
744
|
};
|
|
745
|
-
return
|
|
745
|
+
return ae(n.fn(i, t, a)).svg;
|
|
746
746
|
} catch (e) {
|
|
747
747
|
return "";
|
|
748
748
|
}
|
|
749
749
|
}
|
|
750
|
-
var
|
|
751
|
-
function
|
|
750
|
+
var q = [];
|
|
751
|
+
function J(e, t = 8) {
|
|
752
752
|
let n = 14 * t + 8 + 4;
|
|
753
753
|
e.style.height = "auto";
|
|
754
754
|
let r = Math.min(Math.max(e.scrollHeight, 40), n);
|
|
755
755
|
e.style.height = `${r}px`;
|
|
756
756
|
}
|
|
757
|
-
function
|
|
757
|
+
function ue() {
|
|
758
758
|
let e = "", t = "";
|
|
759
759
|
return {
|
|
760
760
|
id: "data",
|
|
@@ -772,18 +772,18 @@ function fe() {
|
|
|
772
772
|
let i = n.getElement(".data-view-container");
|
|
773
773
|
i == null || i.querySelectorAll(".data-subtab-content").forEach((e) => {
|
|
774
774
|
e.classList.toggle("active", e.id === `data-subtab-${t}`);
|
|
775
|
-
}), t === "edit" ?
|
|
775
|
+
}), t === "edit" ? he(n) : t === "history" ? fe(n) : t === "saves" && pe(n);
|
|
776
776
|
});
|
|
777
777
|
});
|
|
778
778
|
let i = n.getElement("#simulator-puzzle"), a = n.getElement("#simulator-input"), o = n.getElement("#simulator-puzzle-reset"), s = n.getElement("#simulator-puzzle-apply"), c = n.getElement("#simulator-input-reset"), l = n.getElement("#simulator-input-apply");
|
|
779
779
|
setTimeout(() => {
|
|
780
|
-
i && n.state.originalPuzzle && document.activeElement !== i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle,
|
|
780
|
+
i && n.state.originalPuzzle && document.activeElement !== i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle, J(i)), a && n.state.currentInputStr && document.activeElement !== a && (a.value = n.state.currentInputStr, t = n.state.currentInputStr, J(a)), ge(n);
|
|
781
781
|
}, 0), i == null || i.addEventListener("input", () => {
|
|
782
|
-
|
|
782
|
+
J(i);
|
|
783
783
|
let t = i.value !== e;
|
|
784
784
|
s && (s.disabled = !t);
|
|
785
785
|
}), a == null || a.addEventListener("input", () => {
|
|
786
|
-
|
|
786
|
+
J(a);
|
|
787
787
|
let e = a.value !== t;
|
|
788
788
|
l && (l.disabled = !e);
|
|
789
789
|
}), o == null || o.addEventListener("click", () => {
|
|
@@ -791,7 +791,7 @@ function fe() {
|
|
|
791
791
|
m("puzzle"), n.updateStatus("Restoring fixture puzzle...", "waiting"), window.location.reload();
|
|
792
792
|
return;
|
|
793
793
|
}
|
|
794
|
-
i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle,
|
|
794
|
+
i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle, J(i), s && (s.disabled = !0));
|
|
795
795
|
}), s == null || s.addEventListener("click", () => {
|
|
796
796
|
if (i) {
|
|
797
797
|
if (!p("puzzle", i.value)) {
|
|
@@ -805,7 +805,7 @@ function fe() {
|
|
|
805
805
|
m("input"), n.updateStatus("Clearing input...", "waiting"), window.location.reload();
|
|
806
806
|
return;
|
|
807
807
|
}
|
|
808
|
-
a && (a.value = t,
|
|
808
|
+
a && (a.value = t, J(a), l && (l.disabled = !0));
|
|
809
809
|
}), l == null || l.addEventListener("click", () => {
|
|
810
810
|
if (a) {
|
|
811
811
|
if (!p("input", a.value)) {
|
|
@@ -817,87 +817,87 @@ function fe() {
|
|
|
817
817
|
});
|
|
818
818
|
let u = n.getElement("#simulator-history-clear");
|
|
819
819
|
u == null || u.addEventListener("click", () => {
|
|
820
|
-
|
|
820
|
+
q = [], fe(n);
|
|
821
821
|
});
|
|
822
822
|
let d = n.getElement("#simulator-save-name"), f = n.getElement("#simulator-save-btn");
|
|
823
823
|
f == null || f.addEventListener("click", () => {
|
|
824
824
|
if (!d || !d.value.trim()) return;
|
|
825
|
-
let e =
|
|
825
|
+
let e = de(), t = {
|
|
826
826
|
name: d.value.trim(),
|
|
827
827
|
puzzleStr: n.state.originalPuzzle,
|
|
828
828
|
inputStr: n.state.currentInputStr,
|
|
829
829
|
timestamp: Date.now()
|
|
830
830
|
};
|
|
831
|
-
e.push(t), localStorage.setItem(
|
|
832
|
-
}),
|
|
831
|
+
e.push(t), localStorage.setItem(se, JSON.stringify(e)), d.value = "", pe(n);
|
|
832
|
+
}), pe(n);
|
|
833
833
|
},
|
|
834
834
|
onActivate(n) {
|
|
835
|
-
e = n.state.originalPuzzle, t = n.state.currentInputStr,
|
|
835
|
+
e = n.state.originalPuzzle, t = n.state.currentInputStr, he(n), fe(n);
|
|
836
836
|
},
|
|
837
837
|
onMessage(e, n, r) {
|
|
838
838
|
var i, a;
|
|
839
839
|
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;
|
|
840
840
|
if (e === "UPLOAD_NEW_GAME_STATE" && c) {
|
|
841
|
-
if (r.state.currentInputStr = c,
|
|
842
|
-
|
|
841
|
+
if (r.state.currentInputStr = c, q.length === 0 || q[q.length - 1].value !== c) {
|
|
842
|
+
q.push({
|
|
843
843
|
value: c,
|
|
844
844
|
timestamp: Date.now()
|
|
845
|
-
}),
|
|
845
|
+
}), q.length > 100 && (q = q.slice(-100));
|
|
846
846
|
let e = r.getElement("#data-subtab-history");
|
|
847
|
-
e != null && e.classList.contains("active") &&
|
|
847
|
+
e != null && e.classList.contains("active") && fe(r);
|
|
848
848
|
}
|
|
849
|
-
o && document.activeElement !== o && (o.value !== c && (o.value = c,
|
|
849
|
+
o && document.activeElement !== o && (o.value !== c && (o.value = c, J(o)), t = c, s && (s.disabled = !0));
|
|
850
850
|
}
|
|
851
851
|
}
|
|
852
852
|
};
|
|
853
853
|
}
|
|
854
|
-
function
|
|
854
|
+
function de() {
|
|
855
855
|
try {
|
|
856
|
-
let e = localStorage.getItem(
|
|
856
|
+
let e = localStorage.getItem(se);
|
|
857
857
|
return e ? JSON.parse(e) : [];
|
|
858
858
|
} catch (e) {
|
|
859
859
|
return [];
|
|
860
860
|
}
|
|
861
861
|
}
|
|
862
|
-
function
|
|
862
|
+
function fe(e) {
|
|
863
863
|
let t = e.getElement("#simulator-history-list");
|
|
864
864
|
if (t) {
|
|
865
|
-
if (t.style.setProperty("--history-thumb-bg", e.state.selectedTheme.a_bg),
|
|
865
|
+
if (t.style.setProperty("--history-thumb-bg", e.state.selectedTheme.a_bg), q.length === 0) {
|
|
866
866
|
t.innerHTML = "<div class=\"simulator-empty\">No history yet</div>";
|
|
867
867
|
return;
|
|
868
868
|
}
|
|
869
|
-
t.innerHTML = [...
|
|
870
|
-
let r =
|
|
869
|
+
t.innerHTML = [...q].reverse().map((t, n) => {
|
|
870
|
+
let r = q.length - 1 - n, i = new Date(t.timestamp).toLocaleTimeString(), a = t.value.length > 60 ? t.value.slice(0, 60) + "..." : t.value;
|
|
871
871
|
return `
|
|
872
872
|
<div class="history-item" data-history-idx="${r}">
|
|
873
|
-
<div class="history-item-thumb">${
|
|
873
|
+
<div class="history-item-thumb">${le(e, t.value)}</div>
|
|
874
874
|
<div class="history-item-content">
|
|
875
875
|
<div class="history-item-header">
|
|
876
876
|
<span class="history-item-num">#${r + 1}</span>
|
|
877
877
|
<span class="history-item-time">${i}</span>
|
|
878
878
|
<button class="simulator-btn tiny history-restore-btn" data-history-idx="${r}">Restore</button>
|
|
879
879
|
</div>
|
|
880
|
-
<div class="history-item-preview">${
|
|
880
|
+
<div class="history-item-preview">${me(a)}</div>
|
|
881
881
|
</div>
|
|
882
882
|
</div>
|
|
883
883
|
`;
|
|
884
884
|
}).join(""), t.querySelectorAll(".history-restore-btn").forEach((t) => {
|
|
885
885
|
t.addEventListener("click", (t) => {
|
|
886
|
-
let n = parseInt(t.target.getAttribute("data-history-idx") || "0"), r =
|
|
886
|
+
let n = parseInt(t.target.getAttribute("data-history-idx") || "0"), r = q[n];
|
|
887
887
|
if (r) {
|
|
888
888
|
let t = e.getElement(".data-subtab[data-subtab=\"edit\"]");
|
|
889
889
|
t == null || t.click();
|
|
890
890
|
let n = e.getElement("#simulator-input"), i = e.getElement("#simulator-input-apply");
|
|
891
|
-
n && (n.value = r.value,
|
|
891
|
+
n && (n.value = r.value, J(n)), i && (i.disabled = !1), e.updateStatus("Input restored — press Apply to load it", "ready");
|
|
892
892
|
}
|
|
893
893
|
});
|
|
894
894
|
});
|
|
895
895
|
}
|
|
896
896
|
}
|
|
897
|
-
function
|
|
897
|
+
function pe(e) {
|
|
898
898
|
let t = e.getElement("#simulator-saves-list");
|
|
899
899
|
if (!t) return;
|
|
900
|
-
let n =
|
|
900
|
+
let n = de();
|
|
901
901
|
if (n.length === 0) {
|
|
902
902
|
t.innerHTML = "<div class=\"simulator-empty\">No saved states</div>";
|
|
903
903
|
return;
|
|
@@ -907,7 +907,7 @@ function he(e) {
|
|
|
907
907
|
return `
|
|
908
908
|
<div class="save-item">
|
|
909
909
|
<div class="save-item-header">
|
|
910
|
-
<span class="save-item-name">${
|
|
910
|
+
<span class="save-item-name">${me(e.name)}</span>
|
|
911
911
|
<span class="save-item-time">${i} ${a}</span>
|
|
912
912
|
</div>
|
|
913
913
|
<div class="save-item-actions">
|
|
@@ -930,25 +930,25 @@ function he(e) {
|
|
|
930
930
|
}), t.querySelectorAll(".save-delete-btn").forEach((t) => {
|
|
931
931
|
t.addEventListener("click", (t) => {
|
|
932
932
|
let r = parseInt(t.target.getAttribute("data-save-idx") || "0"), i = n.filter((e, t) => t !== r);
|
|
933
|
-
localStorage.setItem(
|
|
933
|
+
localStorage.setItem(se, JSON.stringify(i)), pe(e);
|
|
934
934
|
});
|
|
935
935
|
});
|
|
936
936
|
}
|
|
937
|
-
function
|
|
937
|
+
function me(e) {
|
|
938
938
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
939
939
|
}
|
|
940
|
-
function
|
|
940
|
+
function he(e) {
|
|
941
941
|
let t = e.getElement("#simulator-puzzle"), n = e.getElement("#simulator-input"), r = e.getElement("#simulator-puzzle-apply"), i = e.getElement("#simulator-input-apply");
|
|
942
|
-
t && e.state.originalPuzzle && (t.value = e.state.originalPuzzle,
|
|
942
|
+
t && e.state.originalPuzzle && (t.value = e.state.originalPuzzle, J(t), r && (r.disabled = !0)), n && (n.value = e.state.currentInputStr, J(n), i && (i.disabled = !0)), ge(e);
|
|
943
943
|
}
|
|
944
|
-
function
|
|
944
|
+
function ge(e) {
|
|
945
945
|
let t = e.getElement("#simulator-puzzle-override-tag"), n = e.getElement("#simulator-input-override-tag");
|
|
946
946
|
t && (t.hidden = e.state.appliedPuzzleOverride === null), n && (n.hidden = e.state.appliedInputOverride === null);
|
|
947
947
|
}
|
|
948
|
-
function
|
|
948
|
+
function _e(e) {
|
|
949
949
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
950
950
|
}
|
|
951
|
-
function
|
|
951
|
+
function ve() {
|
|
952
952
|
let e = 0;
|
|
953
953
|
return {
|
|
954
954
|
id: "msgs",
|
|
@@ -975,7 +975,7 @@ function be() {
|
|
|
975
975
|
<span class="simulator-msg-type">${t.direction === "out" ? "→" : "←"} ${t.type}</span>
|
|
976
976
|
<span class="simulator-msg-time">${t.time}</span>
|
|
977
977
|
</div>
|
|
978
|
-
${a ? `<div class="simulator-msg-data">${
|
|
978
|
+
${a ? `<div class="simulator-msg-data">${_e(a)}</div>` : ""}
|
|
979
979
|
`;
|
|
980
980
|
let o = i.querySelector(".simulator-msg-data");
|
|
981
981
|
for (o && o.addEventListener("click", () => {
|
|
@@ -986,7 +986,7 @@ function be() {
|
|
|
986
986
|
}
|
|
987
987
|
};
|
|
988
988
|
}
|
|
989
|
-
function
|
|
989
|
+
function ye() {
|
|
990
990
|
return {
|
|
991
991
|
id: "done",
|
|
992
992
|
label: "Done",
|
|
@@ -1023,7 +1023,7 @@ function xe() {
|
|
|
1023
1023
|
}
|
|
1024
1024
|
};
|
|
1025
1025
|
}
|
|
1026
|
-
function
|
|
1026
|
+
function be() {
|
|
1027
1027
|
let e = [], t = () => (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", { hour12: !1 }), n = (e) => {
|
|
1028
1028
|
let { checkpointName: t, augConfig: n, time: r } = e, i = n == null ? void 0 : n.deeds;
|
|
1029
1029
|
return `
|
|
@@ -1073,7 +1073,7 @@ function Se() {
|
|
|
1073
1073
|
}
|
|
1074
1074
|
};
|
|
1075
1075
|
}
|
|
1076
|
-
var
|
|
1076
|
+
var xe = /* @__PURE__ */ s(((e) => {
|
|
1077
1077
|
var t = { document: {} }, n = Object.prototype.hasOwnProperty, r = function(e) {
|
|
1078
1078
|
return v(e) ? e.toLowerCase() : e;
|
|
1079
1079
|
}, i = Array.isArray;
|
|
@@ -1491,7 +1491,7 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
1491
1491
|
d("+ - * / % === !== == != < > <= >= && || ?? ! = | ?".split(" "), function(e) {
|
|
1492
1492
|
P[e] = !0;
|
|
1493
1493
|
});
|
|
1494
|
-
var
|
|
1494
|
+
var F = {
|
|
1495
1495
|
n: "\n",
|
|
1496
1496
|
f: "\f",
|
|
1497
1497
|
r: "\r",
|
|
@@ -1503,11 +1503,11 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
1503
1503
|
/**
|
|
1504
1504
|
* @constructor
|
|
1505
1505
|
*/
|
|
1506
|
-
function
|
|
1506
|
+
function I(e) {
|
|
1507
1507
|
this.options = e || {};
|
|
1508
1508
|
}
|
|
1509
|
-
|
|
1510
|
-
constructor:
|
|
1509
|
+
I.prototype = {
|
|
1510
|
+
constructor: I,
|
|
1511
1511
|
lex: function(e) {
|
|
1512
1512
|
for (this.text = e, this.index = 0, this.tokens = []; this.index < this.text.length;) {
|
|
1513
1513
|
var t = this.text.charAt(this.index);
|
|
@@ -1624,7 +1624,7 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
1624
1624
|
text: "+",
|
|
1625
1625
|
operator: !0
|
|
1626
1626
|
});
|
|
1627
|
-
for (var l = new
|
|
1627
|
+
for (var l = new I(this.options).lex(c), u = 0, d = l.length; u < d; u++) this.tokens.push(l[u]);
|
|
1628
1628
|
this.tokens.push({
|
|
1629
1629
|
index: this.index,
|
|
1630
1630
|
text: "+",
|
|
@@ -1637,7 +1637,7 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
1637
1637
|
var f = this.text.substring(this.index + 1, this.index + 5);
|
|
1638
1638
|
f.match(/[\da-f]{4}/i) || this.throwError("Invalid unicode escape [\\u" + f + "]"), this.index += 4, n += String.fromCharCode(parseInt(f, 16));
|
|
1639
1639
|
} else {
|
|
1640
|
-
var p =
|
|
1640
|
+
var p = F[o];
|
|
1641
1641
|
n += p || o;
|
|
1642
1642
|
}
|
|
1643
1643
|
a = !1;
|
|
@@ -1656,10 +1656,10 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
1656
1656
|
this.throwError("Unterminated quote", t);
|
|
1657
1657
|
}
|
|
1658
1658
|
};
|
|
1659
|
-
function
|
|
1659
|
+
function L(e, t) {
|
|
1660
1660
|
this.lexer = e, this.options = t;
|
|
1661
1661
|
}
|
|
1662
|
-
|
|
1662
|
+
L.Program = "Program", L.ExpressionStatement = "ExpressionStatement", L.AssignmentExpression = "AssignmentExpression", L.ConditionalExpression = "ConditionalExpression", L.LogicalExpression = "LogicalExpression", L.BinaryExpression = "BinaryExpression", L.UnaryExpression = "UnaryExpression", L.CallExpression = "CallExpression", L.MemberExpression = "MemberExpression", L.Identifier = "Identifier", L.Literal = "Literal", L.ArrayExpression = "ArrayExpression", L.Property = "Property", L.ObjectExpression = "ObjectExpression", L.ThisExpression = "ThisExpression", L.LocalsExpression = "LocalsExpression", L.NGValueParameter = "NGValueParameter", L.prototype = {
|
|
1663
1663
|
ast: function(e) {
|
|
1664
1664
|
this.text = e, this.tokens = this.lexer.lex(e);
|
|
1665
1665
|
var t = this.program();
|
|
@@ -1667,13 +1667,13 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
1667
1667
|
},
|
|
1668
1668
|
program: function() {
|
|
1669
1669
|
for (var e = [];;) if (this.tokens.length > 0 && !this.peek("}", ")", ";", "]") && e.push(this.expressionStatement()), !this.expect(";")) return {
|
|
1670
|
-
type:
|
|
1670
|
+
type: L.Program,
|
|
1671
1671
|
body: e
|
|
1672
1672
|
};
|
|
1673
1673
|
},
|
|
1674
1674
|
expressionStatement: function() {
|
|
1675
1675
|
return {
|
|
1676
|
-
type:
|
|
1676
|
+
type: L.ExpressionStatement,
|
|
1677
1677
|
expression: this.filterChain()
|
|
1678
1678
|
};
|
|
1679
1679
|
},
|
|
@@ -1687,9 +1687,9 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
1687
1687
|
assignment: function() {
|
|
1688
1688
|
var e = this.ternary();
|
|
1689
1689
|
if (this.expect("=")) {
|
|
1690
|
-
if (!
|
|
1690
|
+
if (!ee(e)) throw M("lval", "Trying to assign a value to a non l-value");
|
|
1691
1691
|
e = {
|
|
1692
|
-
type:
|
|
1692
|
+
type: L.AssignmentExpression,
|
|
1693
1693
|
left: e,
|
|
1694
1694
|
right: this.assignment(),
|
|
1695
1695
|
operator: "="
|
|
@@ -1700,7 +1700,7 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
1700
1700
|
ternary: function() {
|
|
1701
1701
|
var e = this.nullishCoalescing(), t, n;
|
|
1702
1702
|
return this.expect("?") && (t = this.expression(), this.consume(":")) ? (n = this.expression(), {
|
|
1703
|
-
type:
|
|
1703
|
+
type: L.ConditionalExpression,
|
|
1704
1704
|
test: e,
|
|
1705
1705
|
alternate: t,
|
|
1706
1706
|
consequent: n
|
|
@@ -1708,7 +1708,7 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
1708
1708
|
},
|
|
1709
1709
|
nullishCoalescing: function() {
|
|
1710
1710
|
for (var e = this.logicalOR(); this.expect("??");) e = {
|
|
1711
|
-
type:
|
|
1711
|
+
type: L.LogicalExpression,
|
|
1712
1712
|
operator: "??",
|
|
1713
1713
|
left: e,
|
|
1714
1714
|
right: this.logicalOR()
|
|
@@ -1717,7 +1717,7 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
1717
1717
|
},
|
|
1718
1718
|
logicalOR: function() {
|
|
1719
1719
|
for (var e = this.logicalAND(); this.expect("||");) e = {
|
|
1720
|
-
type:
|
|
1720
|
+
type: L.LogicalExpression,
|
|
1721
1721
|
operator: "||",
|
|
1722
1722
|
left: e,
|
|
1723
1723
|
right: this.logicalAND()
|
|
@@ -1726,7 +1726,7 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
1726
1726
|
},
|
|
1727
1727
|
logicalAND: function() {
|
|
1728
1728
|
for (var e = this.equality(); this.expect("&&");) e = {
|
|
1729
|
-
type:
|
|
1729
|
+
type: L.LogicalExpression,
|
|
1730
1730
|
operator: "&&",
|
|
1731
1731
|
left: e,
|
|
1732
1732
|
right: this.equality()
|
|
@@ -1735,7 +1735,7 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
1735
1735
|
},
|
|
1736
1736
|
equality: function() {
|
|
1737
1737
|
for (var e = this.relational(), t; t = this.expect("==", "!=", "===", "!==");) e = {
|
|
1738
|
-
type:
|
|
1738
|
+
type: L.BinaryExpression,
|
|
1739
1739
|
operator: t.text,
|
|
1740
1740
|
left: e,
|
|
1741
1741
|
right: this.relational()
|
|
@@ -1744,7 +1744,7 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
1744
1744
|
},
|
|
1745
1745
|
relational: function() {
|
|
1746
1746
|
for (var e = this.additive(), t; t = this.expect("<", ">", "<=", ">=");) e = {
|
|
1747
|
-
type:
|
|
1747
|
+
type: L.BinaryExpression,
|
|
1748
1748
|
operator: t.text,
|
|
1749
1749
|
left: e,
|
|
1750
1750
|
right: this.additive()
|
|
@@ -1753,7 +1753,7 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
1753
1753
|
},
|
|
1754
1754
|
additive: function() {
|
|
1755
1755
|
for (var e = this.multiplicative(), t; t = this.expect("+", "-");) e = {
|
|
1756
|
-
type:
|
|
1756
|
+
type: L.BinaryExpression,
|
|
1757
1757
|
operator: t.text,
|
|
1758
1758
|
left: e,
|
|
1759
1759
|
right: this.multiplicative()
|
|
@@ -1762,7 +1762,7 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
1762
1762
|
},
|
|
1763
1763
|
multiplicative: function() {
|
|
1764
1764
|
for (var e = this.unary(), t; t = this.expect("*", "/", "%");) e = {
|
|
1765
|
-
type:
|
|
1765
|
+
type: L.BinaryExpression,
|
|
1766
1766
|
operator: t.text,
|
|
1767
1767
|
left: e,
|
|
1768
1768
|
right: this.unary()
|
|
@@ -1772,7 +1772,7 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
1772
1772
|
unary: function() {
|
|
1773
1773
|
var e;
|
|
1774
1774
|
return (e = this.expect("+", "-", "!")) ? {
|
|
1775
|
-
type:
|
|
1775
|
+
type: L.UnaryExpression,
|
|
1776
1776
|
operator: e.text,
|
|
1777
1777
|
prefix: !0,
|
|
1778
1778
|
argument: this.unary()
|
|
@@ -1781,20 +1781,20 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
1781
1781
|
primary: function() {
|
|
1782
1782
|
var e;
|
|
1783
1783
|
this.expect("(") ? (e = this.filterChain(), this.consume(")")) : this.expect("[") ? e = this.arrayDeclaration() : this.expect("{") ? e = this.object() : this.selfReferential.hasOwnProperty(this.peek().text) ? e = E(this.selfReferential[this.consume().text]) : this.options.literals.hasOwnProperty(this.peek().text) ? e = {
|
|
1784
|
-
type:
|
|
1784
|
+
type: L.Literal,
|
|
1785
1785
|
value: this.options.literals[this.consume().text]
|
|
1786
1786
|
} : this.peek().identifier ? e = this.identifier() : this.peek().constant ? e = this.constant() : this.throwError("not a primary expression", this.peek());
|
|
1787
1787
|
for (var t; t = this.expect("(", "[", ".");) t.text === "(" ? (e = {
|
|
1788
|
-
type:
|
|
1788
|
+
type: L.CallExpression,
|
|
1789
1789
|
callee: e,
|
|
1790
1790
|
arguments: this.parseArguments()
|
|
1791
1791
|
}, this.consume(")")) : t.text === "[" ? (e = {
|
|
1792
|
-
type:
|
|
1792
|
+
type: L.MemberExpression,
|
|
1793
1793
|
object: e,
|
|
1794
1794
|
property: this.expression(),
|
|
1795
1795
|
computed: !0
|
|
1796
1796
|
}, this.consume("]")) : t.text === "." ? e = {
|
|
1797
|
-
type:
|
|
1797
|
+
type: L.MemberExpression,
|
|
1798
1798
|
object: e,
|
|
1799
1799
|
property: this.identifier(),
|
|
1800
1800
|
computed: !1
|
|
@@ -1803,7 +1803,7 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
1803
1803
|
},
|
|
1804
1804
|
filter: function(e) {
|
|
1805
1805
|
for (var t = [e], n = {
|
|
1806
|
-
type:
|
|
1806
|
+
type: L.CallExpression,
|
|
1807
1807
|
callee: this.identifier(),
|
|
1808
1808
|
arguments: t,
|
|
1809
1809
|
filter: !0
|
|
@@ -1820,13 +1820,13 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
1820
1820
|
identifier: function() {
|
|
1821
1821
|
var e = this.consume();
|
|
1822
1822
|
return e.identifier || this.throwError("is not a valid identifier", e), {
|
|
1823
|
-
type:
|
|
1823
|
+
type: L.Identifier,
|
|
1824
1824
|
name: e.text
|
|
1825
1825
|
};
|
|
1826
1826
|
},
|
|
1827
1827
|
constant: function() {
|
|
1828
1828
|
return {
|
|
1829
|
-
type:
|
|
1829
|
+
type: L.Literal,
|
|
1830
1830
|
value: this.consume().value
|
|
1831
1831
|
};
|
|
1832
1832
|
},
|
|
@@ -1837,7 +1837,7 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
1837
1837
|
e.push(this.expression());
|
|
1838
1838
|
} while (this.expect(","));
|
|
1839
1839
|
return this.consume("]"), {
|
|
1840
|
-
type:
|
|
1840
|
+
type: L.ArrayExpression,
|
|
1841
1841
|
elements: e
|
|
1842
1842
|
};
|
|
1843
1843
|
},
|
|
@@ -1846,12 +1846,12 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
1846
1846
|
if (this.peekToken().text !== "}") do {
|
|
1847
1847
|
if (this.peek("}")) break;
|
|
1848
1848
|
t = {
|
|
1849
|
-
type:
|
|
1849
|
+
type: L.Property,
|
|
1850
1850
|
kind: "init"
|
|
1851
1851
|
}, this.peek().constant ? (t.key = this.constant(), t.computed = !1, this.consume(":"), t.value = this.expression()) : this.peek().identifier ? (t.key = this.identifier(), t.computed = !1, this.peek(":") ? (this.consume(":"), t.value = this.expression()) : t.value = t.key) : this.peek("[") ? (this.consume("["), t.key = this.expression(), this.consume("]"), t.computed = !0, this.consume(":"), t.value = this.expression()) : this.throwError("invalid key", this.peek()), e.push(t);
|
|
1852
1852
|
} while (this.expect(","));
|
|
1853
1853
|
return this.consume("}"), {
|
|
1854
|
-
type:
|
|
1854
|
+
type: L.ObjectExpression,
|
|
1855
1855
|
properties: e
|
|
1856
1856
|
};
|
|
1857
1857
|
},
|
|
@@ -1882,99 +1882,99 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
1882
1882
|
return i ? (this.tokens.shift(), i) : !1;
|
|
1883
1883
|
}
|
|
1884
1884
|
};
|
|
1885
|
-
function
|
|
1885
|
+
function R(e, t) {
|
|
1886
1886
|
return e === void 0 ? t : e;
|
|
1887
1887
|
}
|
|
1888
|
-
function
|
|
1888
|
+
function z(e, t) {
|
|
1889
1889
|
return e === void 0 ? t : t === void 0 ? e : e + t;
|
|
1890
1890
|
}
|
|
1891
|
-
function
|
|
1891
|
+
function B(e, t) {
|
|
1892
1892
|
var n = e(t);
|
|
1893
1893
|
if (!n) throw Error("Filter '" + t + "' is not defined");
|
|
1894
1894
|
return !n.$stateful;
|
|
1895
1895
|
}
|
|
1896
|
-
function
|
|
1896
|
+
function V(e, t) {
|
|
1897
1897
|
var n, r, i;
|
|
1898
1898
|
switch (e.type) {
|
|
1899
|
-
case
|
|
1899
|
+
case L.Program:
|
|
1900
1900
|
n = !0, d(e.body, function(e) {
|
|
1901
|
-
|
|
1901
|
+
V(e.expression, t), n = n && e.expression.constant;
|
|
1902
1902
|
}), e.constant = n;
|
|
1903
1903
|
break;
|
|
1904
|
-
case
|
|
1904
|
+
case L.Literal:
|
|
1905
1905
|
e.constant = !0, e.toWatch = [];
|
|
1906
1906
|
break;
|
|
1907
|
-
case
|
|
1908
|
-
|
|
1907
|
+
case L.UnaryExpression:
|
|
1908
|
+
V(e.argument, t), e.constant = e.argument.constant, e.toWatch = e.argument.toWatch;
|
|
1909
1909
|
break;
|
|
1910
|
-
case
|
|
1911
|
-
|
|
1910
|
+
case L.BinaryExpression:
|
|
1911
|
+
V(e.left, t), V(e.right, t), e.constant = e.left.constant && e.right.constant, e.toWatch = e.left.toWatch.concat(e.right.toWatch);
|
|
1912
1912
|
break;
|
|
1913
|
-
case
|
|
1914
|
-
|
|
1913
|
+
case L.LogicalExpression:
|
|
1914
|
+
V(e.left, t), V(e.right, t), e.constant = e.left.constant && e.right.constant, e.toWatch = e.constant ? [] : [e];
|
|
1915
1915
|
break;
|
|
1916
|
-
case
|
|
1917
|
-
|
|
1916
|
+
case L.ConditionalExpression:
|
|
1917
|
+
V(e.test, t), V(e.alternate, t), V(e.consequent, t), e.constant = e.test.constant && e.alternate.constant && e.consequent.constant, e.toWatch = e.constant ? [] : [e];
|
|
1918
1918
|
break;
|
|
1919
|
-
case
|
|
1919
|
+
case L.Identifier:
|
|
1920
1920
|
e.constant = !1, e.toWatch = [e];
|
|
1921
1921
|
break;
|
|
1922
|
-
case
|
|
1923
|
-
|
|
1922
|
+
case L.MemberExpression:
|
|
1923
|
+
V(e.object, t), e.computed && V(e.property, t), e.constant = e.object.constant && (!e.computed || e.property.constant), e.toWatch = [e];
|
|
1924
1924
|
break;
|
|
1925
|
-
case
|
|
1926
|
-
i = e.filter ?
|
|
1927
|
-
|
|
1925
|
+
case L.CallExpression:
|
|
1926
|
+
i = e.filter ? B(t, e.callee.name) : !1, n = i, r = [], d(e.arguments, function(e) {
|
|
1927
|
+
V(e, t), n = n && e.constant, e.constant || r.push.apply(r, e.toWatch);
|
|
1928
1928
|
}), e.constant = n, e.toWatch = i ? r : [e];
|
|
1929
1929
|
break;
|
|
1930
|
-
case
|
|
1931
|
-
|
|
1930
|
+
case L.AssignmentExpression:
|
|
1931
|
+
V(e.left, t), V(e.right, t), e.constant = e.left.constant && e.right.constant, e.toWatch = [e];
|
|
1932
1932
|
break;
|
|
1933
|
-
case
|
|
1933
|
+
case L.ArrayExpression:
|
|
1934
1934
|
n = !0, r = [], d(e.elements, function(e) {
|
|
1935
|
-
|
|
1935
|
+
V(e, t), n = n && e.constant, e.constant || r.push.apply(r, e.toWatch);
|
|
1936
1936
|
}), e.constant = n, e.toWatch = r;
|
|
1937
1937
|
break;
|
|
1938
|
-
case
|
|
1938
|
+
case L.ObjectExpression:
|
|
1939
1939
|
n = !0, r = [], d(e.properties, function(e) {
|
|
1940
|
-
|
|
1940
|
+
V(e.value, t), n = n && e.value.constant && !e.computed, e.value.constant || r.push.apply(r, e.value.toWatch);
|
|
1941
1941
|
}), e.constant = n, e.toWatch = r;
|
|
1942
1942
|
break;
|
|
1943
|
-
case
|
|
1943
|
+
case L.ThisExpression:
|
|
1944
1944
|
e.constant = !1, e.toWatch = [];
|
|
1945
1945
|
break;
|
|
1946
|
-
case
|
|
1946
|
+
case L.LocalsExpression:
|
|
1947
1947
|
e.constant = !1, e.toWatch = [];
|
|
1948
1948
|
break;
|
|
1949
1949
|
}
|
|
1950
1950
|
}
|
|
1951
|
-
function
|
|
1951
|
+
function H(e) {
|
|
1952
1952
|
if (e.length === 1) {
|
|
1953
1953
|
var t = e[0].expression, n = t.toWatch;
|
|
1954
1954
|
return n.length === 1 && n[0] === t ? void 0 : n;
|
|
1955
1955
|
}
|
|
1956
1956
|
}
|
|
1957
|
-
function
|
|
1958
|
-
return e.type ===
|
|
1957
|
+
function ee(e) {
|
|
1958
|
+
return e.type === L.Identifier || e.type === L.MemberExpression;
|
|
1959
1959
|
}
|
|
1960
|
-
function
|
|
1961
|
-
if (e.body.length === 1 &&
|
|
1962
|
-
type:
|
|
1960
|
+
function te(e) {
|
|
1961
|
+
if (e.body.length === 1 && ee(e.body[0].expression)) return {
|
|
1962
|
+
type: L.AssignmentExpression,
|
|
1963
1963
|
left: e.body[0].expression,
|
|
1964
|
-
right: { type:
|
|
1964
|
+
right: { type: L.NGValueParameter },
|
|
1965
1965
|
operator: "="
|
|
1966
1966
|
};
|
|
1967
1967
|
}
|
|
1968
|
-
function
|
|
1969
|
-
return e.body.length === 0 || e.body.length === 1 && (e.body[0].expression.type ===
|
|
1968
|
+
function ne(e) {
|
|
1969
|
+
return e.body.length === 0 || e.body.length === 1 && (e.body[0].expression.type === L.Literal || e.body[0].expression.type === L.ArrayExpression || e.body[0].expression.type === L.ObjectExpression);
|
|
1970
1970
|
}
|
|
1971
|
-
function
|
|
1971
|
+
function U(e) {
|
|
1972
1972
|
return e.constant;
|
|
1973
1973
|
}
|
|
1974
|
-
function
|
|
1974
|
+
function W(e, t) {
|
|
1975
1975
|
this.astBuilder = e, this.$filter = t;
|
|
1976
1976
|
}
|
|
1977
|
-
|
|
1977
|
+
W.prototype = {
|
|
1978
1978
|
compile: function(e) {
|
|
1979
1979
|
var t = this, n = this.astBuilder.ast(e);
|
|
1980
1980
|
this.state = {
|
|
@@ -1991,14 +1991,14 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
1991
1991
|
own: {}
|
|
1992
1992
|
},
|
|
1993
1993
|
inputs: []
|
|
1994
|
-
},
|
|
1994
|
+
}, V(n, t.$filter);
|
|
1995
1995
|
var r = "", i;
|
|
1996
|
-
if (this.stage = "assign", i =
|
|
1996
|
+
if (this.stage = "assign", i = te(n)) {
|
|
1997
1997
|
this.state.computing = "assign";
|
|
1998
1998
|
var o = this.nextId();
|
|
1999
1999
|
this.recurse(i, o), this.return_(o), r = "fn.assign=" + this.generateFunction("assign", "s,v,l");
|
|
2000
2000
|
}
|
|
2001
|
-
var s =
|
|
2001
|
+
var s = H(n.body);
|
|
2002
2002
|
t.stage = "inputs", d(s, function(e, n) {
|
|
2003
2003
|
var r = "fn" + n;
|
|
2004
2004
|
t.state[r] = {
|
|
@@ -2009,7 +2009,7 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
2009
2009
|
var i = t.nextId();
|
|
2010
2010
|
t.recurse(e, i), t.return_(i), t.state.inputs.push(r), e.watchId = n;
|
|
2011
2011
|
}), this.state.computing = "fn", this.stage = "main", this.recurse(n);
|
|
2012
|
-
var c = "\"" + this.USE + " " + this.STRICT + "\";\n" + this.filterPrefix() + "var fn=" + this.generateFunction("fn", "s,l,a,i") + r + this.watchFns() + "return fn;", l = Function("$filter", "getStringValue", "ifDefined", "plus", c)(this.$filter, N,
|
|
2012
|
+
var c = "\"" + this.USE + " " + this.STRICT + "\";\n" + this.filterPrefix() + "var fn=" + this.generateFunction("fn", "s,l,a,i") + r + this.watchFns() + "return fn;", l = Function("$filter", "getStringValue", "ifDefined", "plus", c)(this.$filter, N, R, z), u = function(e, t, n, r) {
|
|
2013
2013
|
return a(function() {
|
|
2014
2014
|
return l(e, t, n, r);
|
|
2015
2015
|
});
|
|
@@ -2018,7 +2018,7 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
2018
2018
|
return a(function() {
|
|
2019
2019
|
return l.assign(e, t, n);
|
|
2020
2020
|
});
|
|
2021
|
-
}, u.inputs = l.inputs, this.state = this.stage = void 0, u.ast = n, u.literal =
|
|
2021
|
+
}, u.inputs = l.inputs, this.state = this.stage = void 0, u.ast = n, u.literal = ne(n), u.constant = U(n), u;
|
|
2022
2022
|
},
|
|
2023
2023
|
USE: "use",
|
|
2024
2024
|
STRICT: "strict",
|
|
@@ -2050,35 +2050,35 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
2050
2050
|
return;
|
|
2051
2051
|
}
|
|
2052
2052
|
switch (e.type) {
|
|
2053
|
-
case
|
|
2053
|
+
case L.Program:
|
|
2054
2054
|
d(e.body, function(t, n) {
|
|
2055
2055
|
c.recurse(t.expression, void 0, void 0, function(e) {
|
|
2056
2056
|
s = e;
|
|
2057
2057
|
}), n === e.body.length - 1 ? c.return_(s) : c.current().body.push(s, ";");
|
|
2058
2058
|
});
|
|
2059
2059
|
break;
|
|
2060
|
-
case
|
|
2060
|
+
case L.Literal:
|
|
2061
2061
|
u = this.escape(e.value), this.assign(t, u), r(t || u);
|
|
2062
2062
|
break;
|
|
2063
|
-
case
|
|
2063
|
+
case L.UnaryExpression:
|
|
2064
2064
|
this.recurse(e.argument, void 0, void 0, function(e) {
|
|
2065
2065
|
s = e;
|
|
2066
2066
|
}), u = e.operator + "(" + this.ifDefined(s, 0) + ")", this.assign(t, u), r(u);
|
|
2067
2067
|
break;
|
|
2068
|
-
case
|
|
2068
|
+
case L.BinaryExpression:
|
|
2069
2069
|
this.recurse(e.left, void 0, void 0, function(e) {
|
|
2070
2070
|
o = e;
|
|
2071
2071
|
}), this.recurse(e.right, void 0, void 0, function(e) {
|
|
2072
2072
|
s = e;
|
|
2073
2073
|
}), u = e.operator === "+" ? this.plus(o, s) : e.operator === "-" ? this.ifDefined(o, 0) + e.operator + this.ifDefined(s, 0) : "(" + o + ")" + e.operator + "(" + s + ")", this.assign(t, u), r(u);
|
|
2074
2074
|
break;
|
|
2075
|
-
case
|
|
2075
|
+
case L.LogicalExpression:
|
|
2076
2076
|
t = t || this.nextId(), c.recurse(e.left, t), e.operator === "??" ? c.if_(c.or_(c.isNull(t), "typeof " + t + " === 'undefined'"), c.lazyRecurse(e.right, t)) : c.if_(e.operator === "&&" ? t : c.not(t), c.lazyRecurse(e.right, t)), r(t);
|
|
2077
2077
|
break;
|
|
2078
|
-
case
|
|
2078
|
+
case L.ConditionalExpression:
|
|
2079
2079
|
t = t || this.nextId(), c.recurse(e.test, t), c.if_(t, c.lazyRecurse(e.alternate, t), c.lazyRecurse(e.consequent, t)), r(t);
|
|
2080
2080
|
break;
|
|
2081
|
-
case
|
|
2081
|
+
case L.Identifier:
|
|
2082
2082
|
t = t || this.nextId();
|
|
2083
2083
|
var m = c.current().inAssignment;
|
|
2084
2084
|
n && (m ? n.context = this.assign(this.nextId(), "s") : n.context = c.stage === "inputs" ? "s" : this.assign(this.nextId(), this.getHasOwnProperty("l", e.name) + "?l:s"), n.computed = !1, n.name = e.name), c.if_(c.stage === "inputs" || c.not(c.getHasOwnProperty("l", e.name)), function() {
|
|
@@ -2092,17 +2092,17 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
2092
2092
|
c.if_(c.hasOwnProperty_("l", e.name), c.lazyAssign(t, c.nonComputedMember("l", e.name)));
|
|
2093
2093
|
}), r(t);
|
|
2094
2094
|
break;
|
|
2095
|
-
case
|
|
2095
|
+
case L.MemberExpression:
|
|
2096
2096
|
o = n && (n.context = this.nextId()) || this.nextId(), t = t || this.nextId(), c.recurse(e.object, o, void 0, function() {
|
|
2097
2097
|
var a = null, l = c.current().inAssignment;
|
|
2098
|
-
e.computed ? (s = c.nextId(), a = l || c.state.computing === "assign" ? c.unsafeComputedMember(o, s) : c.computedMember(o, s)) : (a = l || c.state.computing === "assign" ? c.unsafeNonComputedMember(o, e.property.name) : c.nonComputedMember(o, e.property.name), s = e.property.name), e.computed && e.property.type ===
|
|
2099
|
-
e.computed ? (e.property.type !==
|
|
2098
|
+
e.computed ? (s = c.nextId(), a = l || c.state.computing === "assign" ? c.unsafeComputedMember(o, s) : c.computedMember(o, s)) : (a = l || c.state.computing === "assign" ? c.unsafeNonComputedMember(o, e.property.name) : c.nonComputedMember(o, e.property.name), s = e.property.name), e.computed && e.property.type === L.Literal && c.recurse(e.property, s), c.if_(c.and_(c.notNull(o), c.or_(c.isNull(a), c.hasOwnProperty_(o, s, e.computed))), function() {
|
|
2099
|
+
e.computed ? (e.property.type !== L.Literal && c.recurse(e.property, s), i && i !== 1 && c.if_(c.not(a), c.lazyAssign(a, "{}")), c.assign(t, a), n && (n.computed = !0, n.name = s)) : (i && i !== 1 && c.if_(c.isNull(a), c.lazyAssign(a, "{}")), c.assign(t, a), n && (n.computed = !1, n.name = e.property.name));
|
|
2100
2100
|
}, function() {
|
|
2101
2101
|
c.assign(t, "undefined");
|
|
2102
2102
|
}), r(t);
|
|
2103
2103
|
}, !!i);
|
|
2104
2104
|
break;
|
|
2105
|
-
case
|
|
2105
|
+
case L.CallExpression:
|
|
2106
2106
|
t = t || this.nextId(), e.filter ? (s = c.filter(e.callee.name), l = [], d(e.arguments, function(e) {
|
|
2107
2107
|
var t = c.nextId();
|
|
2108
2108
|
c.recurse(e, t), l.push(t);
|
|
@@ -2118,38 +2118,38 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
2118
2118
|
}), r(t);
|
|
2119
2119
|
}));
|
|
2120
2120
|
break;
|
|
2121
|
-
case
|
|
2121
|
+
case L.AssignmentExpression:
|
|
2122
2122
|
s = this.nextId(), o = {}, c.current().inAssignment = !0, this.recurse(e.left, void 0, o, function() {
|
|
2123
2123
|
c.if_(c.and_(c.notNull(o.context), c.or_(c.hasOwnProperty_(o.context, o.name), c.isNull(c.member(o.context, o.name, o.computed)))), function() {
|
|
2124
2124
|
c.recurse(e.right, s), u = c.member(o.context, o.name, o.computed) + e.operator + s, c.assign(t, u), r(t || u);
|
|
2125
2125
|
}), c.current().inAssignment = !1, c.recurse(e.right, s), c.current().inAssignment = !0;
|
|
2126
2126
|
}, 1), c.current().inAssignment = !1;
|
|
2127
2127
|
break;
|
|
2128
|
-
case
|
|
2128
|
+
case L.ArrayExpression:
|
|
2129
2129
|
l = [], d(e.elements, function(t) {
|
|
2130
2130
|
c.recurse(t, e.constant ? void 0 : c.nextId(), void 0, function(e) {
|
|
2131
2131
|
l.push(e);
|
|
2132
2132
|
});
|
|
2133
2133
|
}), u = "[" + l.join(",") + "]", this.assign(t, u), r(t || u);
|
|
2134
2134
|
break;
|
|
2135
|
-
case
|
|
2135
|
+
case L.ObjectExpression:
|
|
2136
2136
|
l = [], f = !1, d(e.properties, function(e) {
|
|
2137
2137
|
e.computed && (f = !0);
|
|
2138
2138
|
}), f ? (t = t || this.nextId(), this.assign(t, "{}"), d(e.properties, function(e) {
|
|
2139
|
-
e.computed ? (o = c.nextId(), c.recurse(e.key, o)) : o = e.key.type ===
|
|
2139
|
+
e.computed ? (o = c.nextId(), c.recurse(e.key, o)) : o = e.key.type === L.Identifier ? e.key.name : "" + e.key.value, s = c.nextId(), c.recurse(e.value, s), c.assign(c.unsafeMember(t, o, e.computed), s);
|
|
2140
2140
|
})) : (d(e.properties, function(t) {
|
|
2141
2141
|
c.recurse(t.value, e.constant ? void 0 : c.nextId(), void 0, function(e) {
|
|
2142
|
-
l.push(c.escape(t.key.type ===
|
|
2142
|
+
l.push(c.escape(t.key.type === L.Identifier ? t.key.name : "" + t.key.value) + ":" + e);
|
|
2143
2143
|
});
|
|
2144
2144
|
}), u = "{" + l.join(",") + "}", this.assign(t, u)), r(t || u);
|
|
2145
2145
|
break;
|
|
2146
|
-
case
|
|
2146
|
+
case L.ThisExpression:
|
|
2147
2147
|
this.assign(t, "s"), r(t || "s");
|
|
2148
2148
|
break;
|
|
2149
|
-
case
|
|
2149
|
+
case L.LocalsExpression:
|
|
2150
2150
|
this.assign(t, "l"), r(t || "l");
|
|
2151
2151
|
break;
|
|
2152
|
-
case
|
|
2152
|
+
case L.NGValueParameter:
|
|
2153
2153
|
this.assign(t, "v"), r(t || "v");
|
|
2154
2154
|
break;
|
|
2155
2155
|
}
|
|
@@ -2253,16 +2253,16 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
2253
2253
|
return this.state[this.state.computing];
|
|
2254
2254
|
}
|
|
2255
2255
|
};
|
|
2256
|
-
function
|
|
2256
|
+
function G(e, t) {
|
|
2257
2257
|
this.astBuilder = e, this.$filter = t;
|
|
2258
2258
|
}
|
|
2259
|
-
|
|
2259
|
+
G.prototype = {
|
|
2260
2260
|
compile: function(e) {
|
|
2261
2261
|
var t = this, n = this.astBuilder.ast(e);
|
|
2262
|
-
|
|
2262
|
+
V(n, t.$filter);
|
|
2263
2263
|
var r, i;
|
|
2264
|
-
(r =
|
|
2265
|
-
var o =
|
|
2264
|
+
(r = te(n)) && (i = this.recurse(r));
|
|
2265
|
+
var o = H(n.body), s;
|
|
2266
2266
|
o && (s = [], d(o, function(e, n) {
|
|
2267
2267
|
var r = t.recurse(e);
|
|
2268
2268
|
e.input = r, s.push(r), e.watchId = n;
|
|
@@ -2289,20 +2289,20 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
2289
2289
|
return a(function() {
|
|
2290
2290
|
return l.assign(e, t, n);
|
|
2291
2291
|
});
|
|
2292
|
-
}, s && (u.inputs = s), u.ast = n, u.literal =
|
|
2292
|
+
}, s && (u.inputs = s), u.ast = n, u.literal = ne(n), u.constant = U(n), u;
|
|
2293
2293
|
},
|
|
2294
2294
|
recurse: function(e, t, n) {
|
|
2295
2295
|
var r, i, a = this, o;
|
|
2296
2296
|
if (e.input) return this.inputs(e.input, e.watchId);
|
|
2297
2297
|
switch (e.type) {
|
|
2298
|
-
case
|
|
2299
|
-
case
|
|
2300
|
-
case
|
|
2301
|
-
case
|
|
2302
|
-
case
|
|
2303
|
-
case
|
|
2304
|
-
case
|
|
2305
|
-
case
|
|
2298
|
+
case L.Literal: return this.value(e.value, t);
|
|
2299
|
+
case L.UnaryExpression: return i = this.recurse(e.argument), this["unary" + e.operator](i, t);
|
|
2300
|
+
case L.BinaryExpression: return r = this.recurse(e.left), i = this.recurse(e.right), this["binary" + e.operator](r, i, t);
|
|
2301
|
+
case L.LogicalExpression: return r = this.recurse(e.left), i = this.recurse(e.right), this["binary" + e.operator](r, i, t);
|
|
2302
|
+
case L.ConditionalExpression: return this["ternary?:"](this.recurse(e.test), this.recurse(e.alternate), this.recurse(e.consequent), t);
|
|
2303
|
+
case L.Identifier: return a.identifier(e.name, t, n);
|
|
2304
|
+
case L.MemberExpression: return r = this.recurse(e.object, !1, !!n), e.computed || (i = e.property.name), e.computed && (i = this.recurse(e.property)), e.computed ? this.computedMember(r, i, t, n) : this.nonComputedMember(r, i, t, n);
|
|
2305
|
+
case L.CallExpression: return o = [], d(e.arguments, function(e) {
|
|
2306
2306
|
o.push(a.recurse(e));
|
|
2307
2307
|
}), e.filter && (i = this.$filter(e.callee.name)), e.filter || (i = this.recurse(e.callee, !0)), e.filter ? function(e, n, r, a) {
|
|
2308
2308
|
for (var s = [], c = 0; c < o.length; ++c) s.push(o[c](e, n, r, a));
|
|
@@ -2320,23 +2320,23 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
2320
2320
|
}
|
|
2321
2321
|
return t ? { value: c } : c;
|
|
2322
2322
|
};
|
|
2323
|
-
case
|
|
2323
|
+
case L.AssignmentExpression: return r = this.recurse(e.left, !0, 1), i = this.recurse(e.right), function(e, n, a, o) {
|
|
2324
2324
|
var s = r(e, !1, a, o), c = i(e, n, a, o);
|
|
2325
2325
|
return s.context[s.name] = c, t ? { value: c } : c;
|
|
2326
2326
|
};
|
|
2327
|
-
case
|
|
2327
|
+
case L.ArrayExpression: return o = [], d(e.elements, function(e) {
|
|
2328
2328
|
o.push(a.recurse(e));
|
|
2329
2329
|
}), function(e, n, r, i) {
|
|
2330
2330
|
for (var a = [], s = 0; s < o.length; ++s) a.push(o[s](e, n, r, i));
|
|
2331
2331
|
return t ? { value: a } : a;
|
|
2332
2332
|
};
|
|
2333
|
-
case
|
|
2333
|
+
case L.ObjectExpression: return o = [], d(e.properties, function(e) {
|
|
2334
2334
|
e.computed ? o.push({
|
|
2335
2335
|
key: a.recurse(e.key),
|
|
2336
2336
|
computed: !0,
|
|
2337
2337
|
value: a.recurse(e.value)
|
|
2338
2338
|
}) : o.push({
|
|
2339
|
-
key: e.key.type ===
|
|
2339
|
+
key: e.key.type === L.Identifier ? e.key.name : "" + e.key.value,
|
|
2340
2340
|
computed: !1,
|
|
2341
2341
|
value: a.recurse(e.value)
|
|
2342
2342
|
});
|
|
@@ -2344,13 +2344,13 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
2344
2344
|
for (var a = {}, s = 0; s < o.length; ++s) o[s].computed ? a[o[s].key(e, n, r, i)] = o[s].value(e, n, r, i) : a[o[s].key] = o[s].value(e, n, r, i);
|
|
2345
2345
|
return t ? { value: a } : a;
|
|
2346
2346
|
};
|
|
2347
|
-
case
|
|
2347
|
+
case L.ThisExpression: return function(e) {
|
|
2348
2348
|
return t ? { value: e } : e;
|
|
2349
2349
|
};
|
|
2350
|
-
case
|
|
2350
|
+
case L.LocalsExpression: return function(e, n) {
|
|
2351
2351
|
return t ? { value: n } : n;
|
|
2352
2352
|
};
|
|
2353
|
-
case
|
|
2353
|
+
case L.NGValueParameter: return function(e, n, r) {
|
|
2354
2354
|
return t ? { value: r } : r;
|
|
2355
2355
|
};
|
|
2356
2356
|
}
|
|
@@ -2375,7 +2375,7 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
2375
2375
|
},
|
|
2376
2376
|
"binary+": function(e, t, n) {
|
|
2377
2377
|
return function(r, i, a, o) {
|
|
2378
|
-
var s =
|
|
2378
|
+
var s = z(e(r, i, a, o), t(r, i, a, o));
|
|
2379
2379
|
return n ? { value: s } : s;
|
|
2380
2380
|
};
|
|
2381
2381
|
},
|
|
@@ -2527,17 +2527,17 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
2527
2527
|
/**
|
|
2528
2528
|
* @constructor
|
|
2529
2529
|
*/
|
|
2530
|
-
var
|
|
2531
|
-
this.lexer = e, this.$filter = t, n = n || {}, n.handleThis = n.handleThis == null ? !0 : n.handleThis, this.options = n, this.ast = new
|
|
2530
|
+
var K = function(e, t, n) {
|
|
2531
|
+
this.lexer = e, this.$filter = t, n = n || {}, n.handleThis = n.handleThis == null ? !0 : n.handleThis, this.options = n, this.ast = new L(e, n), this.ast.selfReferential = { $locals: { type: L.LocalsExpression } }, n.handleThis && (this.ast.selfReferential.this = { type: L.ThisExpression }), this.astCompiler = n.csp ? new G(this.ast, t) : new W(this.ast, t);
|
|
2532
2532
|
};
|
|
2533
|
-
|
|
2534
|
-
constructor:
|
|
2533
|
+
K.prototype = {
|
|
2534
|
+
constructor: K,
|
|
2535
2535
|
parse: function(e) {
|
|
2536
2536
|
return this.astCompiler.compile(e);
|
|
2537
2537
|
}
|
|
2538
|
-
}, e.Lexer =
|
|
2539
|
-
})),
|
|
2540
|
-
var t =
|
|
2538
|
+
}, e.Lexer = I, e.Parser = K;
|
|
2539
|
+
})), Se = (/* @__PURE__ */ s(((e) => {
|
|
2540
|
+
var t = xe(), n = {}, r = t.Lexer, i = t.Parser;
|
|
2541
2541
|
function a(e) {
|
|
2542
2542
|
return e = e || {}, e.filters && (e.cache = e.cache || {}), e.cache = e.cache || s.cache, e.filters = e.filters || n, e;
|
|
2543
2543
|
}
|
|
@@ -2575,7 +2575,7 @@ var Ce = /* @__PURE__ */ s(((e) => {
|
|
|
2575
2575
|
s.cache = Object.create(null), e.compile = s;
|
|
2576
2576
|
})))();
|
|
2577
2577
|
/** Cleans deeds the way puzzmo.com's PlayGameIframe and the API's `getDeedsFromCompletion` do, collecting what was dropped. */
|
|
2578
|
-
const
|
|
2578
|
+
const Ce = (e, t) => {
|
|
2579
2579
|
let n = [];
|
|
2580
2580
|
e !== void 0 && !Array.isArray(e) && n.push("deeds is not an array, the host ignores it");
|
|
2581
2581
|
let r = [];
|
|
@@ -2609,17 +2609,17 @@ const Te = (e, t) => {
|
|
|
2609
2609
|
})),
|
|
2610
2610
|
warnings: n
|
|
2611
2611
|
};
|
|
2612
|
-
},
|
|
2612
|
+
}, we = (e) => {
|
|
2613
2613
|
let t = {};
|
|
2614
|
-
for (let n of e) n.value !== void 0 && (t[
|
|
2614
|
+
for (let n of e) n.value !== void 0 && (t[De(n.id)] = n.value);
|
|
2615
2615
|
return t;
|
|
2616
|
-
},
|
|
2616
|
+
}, Te = (e, t) => {
|
|
2617
2617
|
try {
|
|
2618
|
-
if (e.filterExp && !(0,
|
|
2618
|
+
if (e.filterExp && !(0, Se.compile)(e.filterExp)(t) || !e.incrementExp) return {
|
|
2619
2619
|
complete: !1,
|
|
2620
2620
|
value: 0
|
|
2621
2621
|
};
|
|
2622
|
-
let n = (0,
|
|
2622
|
+
let n = (0, Se.compile)(e.incrementExp)(t);
|
|
2623
2623
|
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}`);
|
|
2624
2624
|
let r = Math.floor(n);
|
|
2625
2625
|
return {
|
|
@@ -2633,17 +2633,17 @@ const Te = (e, t) => {
|
|
|
2633
2633
|
error: e.message
|
|
2634
2634
|
};
|
|
2635
2635
|
}
|
|
2636
|
-
},
|
|
2636
|
+
}, Ee = (e) => {
|
|
2637
2637
|
let { items: t, scope: n, mode: r } = e, i = Math.min(Math.max(e.index, 0), t.length), a;
|
|
2638
|
-
for (; i < t.length && (a =
|
|
2638
|
+
for (; i < t.length && (a = Te(t[i], n), !(!a.complete || r === "checkpoint" && !t[i].liveUpdate)); i++);
|
|
2639
2639
|
return {
|
|
2640
2640
|
index: i,
|
|
2641
2641
|
head: i < t.length ? a : void 0
|
|
2642
2642
|
};
|
|
2643
2643
|
};
|
|
2644
|
-
var
|
|
2644
|
+
var De = (e) => e.replace(/-./g, (e) => e[1].toUpperCase());
|
|
2645
2645
|
/** A minimal take on puzzmo.com's tutorial checklist, driven by deeds from checkpoints and completion. */
|
|
2646
|
-
function
|
|
2646
|
+
function Oe(e) {
|
|
2647
2647
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = null, i = 0, a, o = [], s = (e) => {
|
|
2648
2648
|
var t;
|
|
2649
2649
|
return `simulator-checklist:${(t = r) == null ? "game" : t}:${e}`;
|
|
@@ -2667,15 +2667,15 @@ function Ae(e) {
|
|
|
2667
2667
|
t.liveUpdate ? "liveUpdate: checkpoints + completion" : "completion only"
|
|
2668
2668
|
].filter(Boolean).join("\n");
|
|
2669
2669
|
return `${e.instructionsVisibleFromItemIndex === r && r > 0 ? "<div class=\"checklist-divider\"><span>full instructions unlock</span></div>" : ""}
|
|
2670
|
-
<div class="checklist-item ${o}" title="${
|
|
2670
|
+
<div class="checklist-item ${o}" title="${Y(f)}">
|
|
2671
2671
|
<div class="checklist-row">
|
|
2672
2672
|
<span class="checklist-tick">${o === "done" ? "■" : "□"}</span>
|
|
2673
|
-
<span class="checklist-title">${
|
|
2673
|
+
<span class="checklist-title">${Y((a = t.title) == null ? `Step ${r + 1}` : a)}</span>
|
|
2674
2674
|
${d ? `<span class="checklist-count">${d}</span>` : ""}
|
|
2675
|
-
${l ? `<button class="checklist-help${c ? " open" : ""}" data-help="${
|
|
2675
|
+
${l ? `<button class="checklist-help${c ? " open" : ""}" data-help="${Y(s)}">?</button>` : ""}
|
|
2676
2676
|
</div>
|
|
2677
|
-
${o === "active" && t.subtitle ? `<div class="checklist-subtitle">${
|
|
2678
|
-
${l && c ? `<pre class="checklist-expand">${
|
|
2677
|
+
${o === "active" && t.subtitle ? `<div class="checklist-subtitle">${Y(t.subtitle)}</div>` : ""}
|
|
2678
|
+
${l && c ? `<pre class="checklist-expand">${Y(t.expandMD)}</pre>` : ""}
|
|
2679
2679
|
</div>`;
|
|
2680
2680
|
}, d = (e) => {
|
|
2681
2681
|
var n, r, i, s;
|
|
@@ -2685,24 +2685,24 @@ function Ae(e) {
|
|
|
2685
2685
|
<div class="checklist-header">
|
|
2686
2686
|
<span class="simulator-label">Checklist</span>
|
|
2687
2687
|
<span class="checklist-progress${d === l ? " complete" : ""}">${d}/${l}</span>
|
|
2688
|
-
<button class="simulator-btn subtle small" data-reset="${
|
|
2688
|
+
<button class="simulator-btn subtle small" data-reset="${Y(e.stableID)}">Reset</button>
|
|
2689
2689
|
</div>
|
|
2690
2690
|
<div class="checklist-items">
|
|
2691
2691
|
${e.items.map((t, n) => u(e, t, n, c)).join("")}
|
|
2692
2692
|
</div>
|
|
2693
|
-
${a ? `<div class="checklist-footer">last eval: ${
|
|
2694
|
-
${f ? `<div class="checklist-error">${
|
|
2695
|
-
${o.map((e) => `<div class="checklist-error">${
|
|
2693
|
+
${a ? `<div class="checklist-footer">last eval: ${Y(a)}</div>` : ""}
|
|
2694
|
+
${f ? `<div class="checklist-error">${Y(f)}</div>` : ""}
|
|
2695
|
+
${o.map((e) => `<div class="checklist-error">${Y(e)}</div>`).join("")}
|
|
2696
2696
|
</div>`;
|
|
2697
2697
|
}, f = () => 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(d).join(""), p = (e) => {
|
|
2698
2698
|
let t = e.getElement("#simulator-checklist-list");
|
|
2699
2699
|
t && (t.innerHTML = f());
|
|
2700
2700
|
}, m = (n, r, s, c) => {
|
|
2701
|
-
let u = 0, d =
|
|
2701
|
+
let u = 0, d = Ce(r, s), f = we(d.deeds);
|
|
2702
2702
|
a = c, o = d.warnings;
|
|
2703
2703
|
for (let n of e) {
|
|
2704
2704
|
var m, h;
|
|
2705
|
-
let e = (m = (h = t.get(n.stableID)) == null ? void 0 : h.index) == null ? 0 : m, r =
|
|
2705
|
+
let e = (m = (h = t.get(n.stableID)) == null ? void 0 : h.index) == null ? 0 : m, r = Ee({
|
|
2706
2706
|
items: n.items,
|
|
2707
2707
|
index: e,
|
|
2708
2708
|
scope: f,
|
|
@@ -2740,9 +2740,9 @@ function Ae(e) {
|
|
|
2740
2740
|
}
|
|
2741
2741
|
};
|
|
2742
2742
|
}
|
|
2743
|
-
var
|
|
2743
|
+
var Y = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
2744
2744
|
/** Find thumbnail function on globalThis (looks for functions ending in "Thumbnail") */
|
|
2745
|
-
function
|
|
2745
|
+
function ke() {
|
|
2746
2746
|
let e = globalThis;
|
|
2747
2747
|
for (let t of Object.keys(e)) if (t.endsWith("Thumbnail") && typeof e[t] == "function") return {
|
|
2748
2748
|
name: t,
|
|
@@ -2751,23 +2751,23 @@ function je() {
|
|
|
2751
2751
|
return null;
|
|
2752
2752
|
}
|
|
2753
2753
|
/** The bundle's `getShareString` (if any), exposed to the sim via vite.ts's bundle loader. */
|
|
2754
|
-
function
|
|
2754
|
+
function Ae() {
|
|
2755
2755
|
let e = globalThis.getShareString;
|
|
2756
2756
|
return typeof e == "function" ? e : null;
|
|
2757
2757
|
}
|
|
2758
|
-
function
|
|
2758
|
+
function je(e) {
|
|
2759
2759
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
2760
2760
|
}
|
|
2761
|
-
function
|
|
2761
|
+
function Me() {
|
|
2762
2762
|
let e = /* @__PURE__ */ new Date();
|
|
2763
2763
|
return `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`;
|
|
2764
2764
|
}
|
|
2765
|
-
function
|
|
2765
|
+
function Ne(e) {
|
|
2766
2766
|
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
2767
2767
|
}
|
|
2768
2768
|
/** Shown when Preview Kind = Text but the bundle doesn't export `getShareString`. */
|
|
2769
|
-
var
|
|
2770
|
-
function
|
|
2769
|
+
var Pe = "\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";
|
|
2770
|
+
function Fe() {
|
|
2771
2771
|
return {
|
|
2772
2772
|
id: "thumb",
|
|
2773
2773
|
label: "Thumb",
|
|
@@ -2789,12 +2789,12 @@ function Le() {
|
|
|
2789
2789
|
o == null || o.querySelectorAll(".simulator-segmented-btn").forEach((t) => {
|
|
2790
2790
|
t.addEventListener("click", () => {
|
|
2791
2791
|
let n = t.dataset.previewKind;
|
|
2792
|
-
!n || n === e.state.previewKind || (e.state.previewKind = n,
|
|
2792
|
+
!n || n === e.state.previewKind || (e.state.previewKind = n, V(n), c(), s(), e.updateThumbnail());
|
|
2793
2793
|
});
|
|
2794
|
-
}), n && (e.state.renderHost || (e.state.renderHost = "game",
|
|
2795
|
-
e.state.renderHost = n.value,
|
|
2796
|
-
})), r && (e.state.renderContext || (e.state.renderContext = "preview",
|
|
2797
|
-
e.state.renderContext = r.value,
|
|
2794
|
+
}), n && (e.state.renderHost || (e.state.renderHost = "game", B(e.state.renderHost)), n.value = e.state.renderHost || "game", n.addEventListener("change", () => {
|
|
2795
|
+
e.state.renderHost = n.value, B(e.state.renderHost), s(), e.updateThumbnail();
|
|
2796
|
+
})), r && (e.state.renderContext || (e.state.renderContext = "preview", H(e.state.renderContext)), r.value = e.state.renderContext || "preview", r.addEventListener("change", () => {
|
|
2797
|
+
e.state.renderContext = r.value, H(e.state.renderContext), e.updateThumbnail();
|
|
2798
2798
|
})), c(), s();
|
|
2799
2799
|
},
|
|
2800
2800
|
onActivate(e) {
|
|
@@ -2803,26 +2803,26 @@ function Le() {
|
|
|
2803
2803
|
updatePreview: (e) => {
|
|
2804
2804
|
let t = e.getElement("#simulator-thumb-preview"), n = e.getElement("#simulator-thumb-fn");
|
|
2805
2805
|
if (t == null || t.style.setProperty("--sim-thumb-bg", e.state.selectedTheme.g_bg), e.state.previewKind === "text") {
|
|
2806
|
-
let s =
|
|
2806
|
+
let s = Ae();
|
|
2807
2807
|
if (!s) {
|
|
2808
|
-
t && (t.innerHTML =
|
|
2808
|
+
t && (t.innerHTML = Pe), n && (n.textContent = "");
|
|
2809
2809
|
return;
|
|
2810
2810
|
}
|
|
2811
2811
|
n && (n.textContent = "Using: getShareString()");
|
|
2812
2812
|
try {
|
|
2813
2813
|
var r, i, a, o;
|
|
2814
|
-
let n = (r = e.gameSlug) == null ? "game" : r, c = s((i = e.state.currentInputStr) == null ? "" : i,
|
|
2814
|
+
let n = (r = e.gameSlug) == null ? "game" : r, c = s((i = e.state.currentInputStr) == null ? "" : i, Ne(n), {
|
|
2815
2815
|
puzzleString: (a = e.state.puzzleData) == null ? "" : a,
|
|
2816
|
-
dateKey:
|
|
2816
|
+
dateKey: Me(),
|
|
2817
2817
|
gameplaySlug: `simulator:${n}`
|
|
2818
2818
|
}), l = (o = c == null ? void 0 : c.str) == null ? "" : o;
|
|
2819
|
-
t && (t.innerHTML = `<pre class="simulator-share-preview" style="color: ${e.state.selectedTheme.fg}">${
|
|
2819
|
+
t && (t.innerHTML = `<pre class="simulator-share-preview" style="color: ${e.state.selectedTheme.fg}">${je(l)}</pre>`);
|
|
2820
2820
|
} catch (e) {
|
|
2821
2821
|
console.error("Simulator: Share string error", e), t && (t.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
|
|
2822
2822
|
}
|
|
2823
2823
|
return;
|
|
2824
2824
|
}
|
|
2825
|
-
let s =
|
|
2825
|
+
let s = ke();
|
|
2826
2826
|
if (!s) {
|
|
2827
2827
|
t && (t.innerHTML = "<span class=\"simulator-empty\">No thumbnail function found</span>"), n && (n.textContent = "");
|
|
2828
2828
|
return;
|
|
@@ -2836,7 +2836,7 @@ function Le() {
|
|
|
2836
2836
|
strict: !0,
|
|
2837
2837
|
renderHost: e.state.renderHost,
|
|
2838
2838
|
renderContext: e.state.renderContext
|
|
2839
|
-
}, { svg: i } =
|
|
2839
|
+
}, { svg: i } = ae(s.fn(n, e.state.currentInputStr, r));
|
|
2840
2840
|
t && (t.innerHTML = i);
|
|
2841
2841
|
} catch (e) {
|
|
2842
2842
|
console.error("Simulator: Thumbnail error", e), t && (t.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
|
|
@@ -2844,7 +2844,7 @@ function Le() {
|
|
|
2844
2844
|
}
|
|
2845
2845
|
};
|
|
2846
2846
|
}
|
|
2847
|
-
var
|
|
2847
|
+
var X = {
|
|
2848
2848
|
bounds: "#ffd700",
|
|
2849
2849
|
grid: "rgba(96, 165, 250, 0.35)",
|
|
2850
2850
|
box: "rgba(34, 211, 238, 0.85)",
|
|
@@ -2857,10 +2857,10 @@ var J = {
|
|
|
2857
2857
|
labelBackground: "rgba(15, 15, 26, 0.8)"
|
|
2858
2858
|
};
|
|
2859
2859
|
/** Draws the overlay over the frame the board just drew, in its canvas's device pixels */
|
|
2860
|
-
const
|
|
2860
|
+
const Ie = (e, t) => {
|
|
2861
2861
|
let { ctx: n, scale: r, scene: i, nodes: a } = e, o = t.devicePixelRatio, s = ([e, t]) => [e * r, t * r];
|
|
2862
2862
|
if (n.save(), n.lineWidth = o, t.grid && i.grid && i.width / i.grid + i.height / i.grid <= 400) {
|
|
2863
|
-
n.strokeStyle =
|
|
2863
|
+
n.strokeStyle = X.grid, n.beginPath();
|
|
2864
2864
|
for (let e = i.grid; e < i.width; e += i.grid) {
|
|
2865
2865
|
let t = Math.round(e * r) + o / 2;
|
|
2866
2866
|
n.moveTo(t, 0), n.lineTo(t, i.height * r);
|
|
@@ -2871,55 +2871,55 @@ const Re = (e, t) => {
|
|
|
2871
2871
|
}
|
|
2872
2872
|
n.stroke();
|
|
2873
2873
|
}
|
|
2874
|
-
t.bounds && (n.strokeStyle =
|
|
2874
|
+
t.bounds && (n.strokeStyle = X.bounds, n.setLineDash([4 * o, 3 * o]), n.strokeRect(o / 2, o / 2, i.width * r - o, i.height * r - o), n.setLineDash([]));
|
|
2875
2875
|
for (let e of a) {
|
|
2876
2876
|
let r = e.sprite ? t.boxOf(e.sprite) : void 0, i = e.key === t.hovered, a = !!e.sprite && e.sprite === t.highlighted;
|
|
2877
2877
|
if (r && (t.boxes || i || a)) {
|
|
2878
|
-
let t =
|
|
2879
|
-
n.strokeStyle = i ?
|
|
2878
|
+
let t = Le(e.matrix, r).map(s);
|
|
2879
|
+
n.strokeStyle = i ? X.hovered : a ? X.highlighted : e.exiting ? X.exiting : X.box, n.lineWidth = (i || a ? 2 : 1) * o, n.setLineDash(e.alpha <= 0 ? [3 * o, 3 * o] : []), n.beginPath(), t.forEach(([e, t], r) => r ? n.lineTo(e, t) : n.moveTo(e, t)), n.closePath(), n.stroke(), n.setLineDash([]), n.lineWidth = o;
|
|
2880
2880
|
}
|
|
2881
2881
|
if (t.anchors) {
|
|
2882
|
-
let [t, i] = s(
|
|
2883
|
-
r ? (n.fillStyle =
|
|
2882
|
+
let [t, i] = s(ze(e.matrix, [0, 0]));
|
|
2883
|
+
r ? (n.fillStyle = X.anchor, n.fillRect(t - 1.5 * o, i - 1.5 * o, 3 * o, 3 * o)) : (n.strokeStyle = X.group, n.beginPath(), n.moveTo(t, i - 4 * o), n.lineTo(t + 4 * o, i), n.lineTo(t, i + 4 * o), n.lineTo(t - 4 * o, i), n.closePath(), n.stroke());
|
|
2884
2884
|
}
|
|
2885
2885
|
}
|
|
2886
2886
|
if (t.keys) {
|
|
2887
2887
|
n.font = `${9 * o}px Menlo, Monaco, monospace`, n.textBaseline = "top";
|
|
2888
2888
|
for (let e of a) {
|
|
2889
|
-
let r = e.sprite ? t.boxOf(e.sprite) : void 0, [i, a] = r ?
|
|
2890
|
-
n.fillStyle =
|
|
2889
|
+
let r = e.sprite ? t.boxOf(e.sprite) : void 0, [i, a] = r ? Ve(Le(e.matrix, r).map(s)) : s(ze(e.matrix, [0, 0])), c = n.measureText(e.key).width;
|
|
2890
|
+
n.fillStyle = X.labelBackground, n.fillRect(i, a, c + 4 * o, 11 * o), n.fillStyle = X.label, n.fillText(e.key, i + 2 * o, a + o);
|
|
2891
2891
|
}
|
|
2892
2892
|
}
|
|
2893
2893
|
n.restore();
|
|
2894
|
-
},
|
|
2894
|
+
}, Le = (e, t) => {
|
|
2895
2895
|
let [n, r] = t.anchor;
|
|
2896
2896
|
return [
|
|
2897
2897
|
[-n, -r],
|
|
2898
2898
|
[t.width - n, -r],
|
|
2899
2899
|
[t.width - n, t.height - r],
|
|
2900
2900
|
[-n, t.height - r]
|
|
2901
|
-
].map((t) =>
|
|
2902
|
-
},
|
|
2901
|
+
].map((t) => ze(e, t));
|
|
2902
|
+
}, Re = (e, t, n) => {
|
|
2903
2903
|
for (let r = e.length - 1; r >= 0; r--) {
|
|
2904
2904
|
let i = e[r];
|
|
2905
2905
|
if (!i.sprite || i.alpha <= 0) continue;
|
|
2906
|
-
let a = n(i.sprite), o = a &&
|
|
2906
|
+
let a = n(i.sprite), o = a && Be(i.matrix, t);
|
|
2907
2907
|
if (!a || !o) continue;
|
|
2908
2908
|
let s = o[0] + a.anchor[0], c = o[1] + a.anchor[1];
|
|
2909
2909
|
if (s >= 0 && c >= 0 && s <= a.width && c <= a.height) return i;
|
|
2910
2910
|
}
|
|
2911
2911
|
return null;
|
|
2912
2912
|
};
|
|
2913
|
-
var
|
|
2913
|
+
var ze = (e, [t, n]) => [e[0] * t + e[2] * n + e[4], e[1] * t + e[3] * n + e[5]], Be = (e, [t, n]) => {
|
|
2914
2914
|
let r = e[0] * e[3] - e[1] * e[2];
|
|
2915
2915
|
if (Math.abs(r) < 1e-12) return null;
|
|
2916
2916
|
let i = t - e[4], a = n - e[5];
|
|
2917
2917
|
return [(e[3] * i - e[2] * a) / r, (-e[1] * i + e[0] * a) / r];
|
|
2918
|
-
},
|
|
2918
|
+
}, Ve = (e) => [Math.min(...e.map((e) => e[0])), Math.min(...e.map((e) => e[1]))];
|
|
2919
2919
|
/** Runs a table capability the way Puzzmo's sandbox does, keeping every sprite and what each render did */
|
|
2920
|
-
const
|
|
2920
|
+
const He = (i, a = {}) => {
|
|
2921
2921
|
var o, s;
|
|
2922
|
-
let c = (o = a.rasterise) == null ?
|
|
2922
|
+
let c = (o = a.rasterise) == null ? Ke : o, l = (s = a.fontFaces) == null ? "" : s, u = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Set(), p = 0, m = !1, h = null, g = (e) => {
|
|
2923
2923
|
_.warnings.includes(e) || _.warnings.push(e);
|
|
2924
2924
|
}, _ = {
|
|
2925
2925
|
render: function() {
|
|
@@ -2946,7 +2946,7 @@ const We = (i, a = {}) => {
|
|
|
2946
2946
|
f.add(i);
|
|
2947
2947
|
let c;
|
|
2948
2948
|
try {
|
|
2949
|
-
c =
|
|
2949
|
+
c = Je(t);
|
|
2950
2950
|
} catch (e) {
|
|
2951
2951
|
return;
|
|
2952
2952
|
}
|
|
@@ -2955,7 +2955,7 @@ const We = (i, a = {}) => {
|
|
|
2955
2955
|
has: (e) => p.has(e) || x.has(e),
|
|
2956
2956
|
draw(t, n, r) {
|
|
2957
2957
|
if (E.has(t)) return T(t, n);
|
|
2958
|
-
let i =
|
|
2958
|
+
let i = Je(n);
|
|
2959
2959
|
h != null || (h = new OffscreenCanvas(1, 1)), h.width = Math.max(1, Math.ceil(i.width * a)), h.height = Math.max(1, Math.ceil(i.height * a));
|
|
2960
2960
|
let s = h.getContext("2d");
|
|
2961
2961
|
s.setTransform(a, 0, 0, a, 0, 0), r(s), x.set(t, { box: i }), S.push(e(e({
|
|
@@ -2969,7 +2969,7 @@ const We = (i, a = {}) => {
|
|
|
2969
2969
|
},
|
|
2970
2970
|
svg(e, t, n, r) {
|
|
2971
2971
|
if (E.has(e)) return T(e, t, String(n));
|
|
2972
|
-
let i =
|
|
2972
|
+
let i = Je(t), a = r ? String(r) : "", o = w.indexOf(a);
|
|
2973
2973
|
o < 0 && (o = w.push(a) - 1), x.set(e, {
|
|
2974
2974
|
box: i,
|
|
2975
2975
|
svg: String(n)
|
|
@@ -2986,7 +2986,7 @@ const We = (i, a = {}) => {
|
|
|
2986
2986
|
try {
|
|
2987
2987
|
O = structuredClone(O);
|
|
2988
2988
|
} catch (e) {
|
|
2989
|
-
throw Error(`The scene can't leave the sandbox: ${
|
|
2989
|
+
throw Error(`The scene can't leave the sandbox: ${Xe(e)}`);
|
|
2990
2990
|
}
|
|
2991
2991
|
o.raw = O, s = "sprites";
|
|
2992
2992
|
let k = performance.now(), A = C.length ? yield c(C, w, a, l) : [];
|
|
@@ -3014,7 +3014,7 @@ const We = (i, a = {}) => {
|
|
|
3014
3014
|
} catch (e) {
|
|
3015
3015
|
throw m = !0, o.error = {
|
|
3016
3016
|
phase: s,
|
|
3017
|
-
message:
|
|
3017
|
+
message: Xe(e),
|
|
3018
3018
|
stack: e instanceof Error ? e.stack : void 0
|
|
3019
3019
|
}, e;
|
|
3020
3020
|
} finally {
|
|
@@ -3051,7 +3051,7 @@ const We = (i, a = {}) => {
|
|
|
3051
3051
|
}
|
|
3052
3052
|
};
|
|
3053
3053
|
return _;
|
|
3054
|
-
},
|
|
3054
|
+
}, Ue = function() {
|
|
3055
3055
|
var e = t(function* (e) {
|
|
3056
3056
|
let t = [], n = [], r = Array.isArray(e) ? e.filter((e) => typeof e == "string") : [];
|
|
3057
3057
|
for (let e of r) {
|
|
@@ -3063,9 +3063,9 @@ const We = (i, a = {}) => {
|
|
|
3063
3063
|
let t = yield fetch(a(e));
|
|
3064
3064
|
if (!t.ok) throw Error(`the CDN answered ${t.status}`);
|
|
3065
3065
|
let r = yield t.arrayBuffer();
|
|
3066
|
-
document.fonts.add(yield new FontFace(e, r.slice(0)).load()), n.push(`@font-face{font-family:"${e.replace(/["\\]/g, "")}";src:url(data:font/woff2;base64,${
|
|
3066
|
+
document.fonts.add(yield new FontFace(e, r.slice(0)).load()), n.push(`@font-face{font-family:"${e.replace(/["\\]/g, "")}";src:url(data:font/woff2;base64,${Ye(r)})}`);
|
|
3067
3067
|
} catch (n) {
|
|
3068
|
-
t.push(`The font ${e} didn't load: ${
|
|
3068
|
+
t.push(`The font ${e} didn't load: ${Xe(n)}`);
|
|
3069
3069
|
}
|
|
3070
3070
|
}
|
|
3071
3071
|
return {
|
|
@@ -3078,24 +3078,24 @@ const We = (i, a = {}) => {
|
|
|
3078
3078
|
};
|
|
3079
3079
|
}();
|
|
3080
3080
|
/** At most this many sprites in one sheet, and a sheet no wider than this, as in the sandbox's frame */
|
|
3081
|
-
var
|
|
3081
|
+
var We = 64, Ge = 4096;
|
|
3082
3082
|
/**
|
|
3083
3083
|
* SVG sprites as bitmaps, many to one SVG sheet so each sheet decodes its fonts and shared definitions once. When a
|
|
3084
3084
|
* sheet won't decode, each of its sprites is tried alone so the error can name the broken ones.
|
|
3085
3085
|
*/
|
|
3086
|
-
const
|
|
3086
|
+
const Ke = function() {
|
|
3087
3087
|
var e = t(function* (e, t, n, r) {
|
|
3088
3088
|
var i;
|
|
3089
3089
|
let a = [], o = /* @__PURE__ */ new Map();
|
|
3090
3090
|
for (let t of e) o.set(t.defs, [...(i = o.get(t.defs)) == null ? [] : i, t]);
|
|
3091
|
-
for (let [e, i] of o) for (let o = 0; o < i.length; o +=
|
|
3092
|
-
let s = i.slice(o, o +
|
|
3091
|
+
for (let [e, i] of o) for (let o = 0; o < i.length; o += We) {
|
|
3092
|
+
let s = i.slice(o, o + We);
|
|
3093
3093
|
try {
|
|
3094
|
-
a.push(...yield
|
|
3094
|
+
a.push(...yield qe(s, t[e], n, r));
|
|
3095
3095
|
} catch (i) {
|
|
3096
3096
|
let a = [];
|
|
3097
|
-
for (let i of s) yield
|
|
3098
|
-
let o = a.length ? `${a.slice(0, 5).join(", ")} won't decode` :
|
|
3097
|
+
for (let i of s) yield qe([i], t[e], n, r).catch(() => a.push(i.id));
|
|
3098
|
+
let o = a.length ? `${a.slice(0, 5).join(", ")} won't decode` : Xe(i);
|
|
3099
3099
|
throw Error(`An SVG sprite couldn't be drawn: ${o}`);
|
|
3100
3100
|
}
|
|
3101
3101
|
}
|
|
@@ -3105,11 +3105,11 @@ const Je = function() {
|
|
|
3105
3105
|
return e.apply(this, arguments);
|
|
3106
3106
|
};
|
|
3107
3107
|
}();
|
|
3108
|
-
var
|
|
3108
|
+
var qe = function() {
|
|
3109
3109
|
var e = t(function* (e, t, n, r) {
|
|
3110
3110
|
let i = 0, a = 0, o = 0, s = 1, c = e.map((e) => {
|
|
3111
3111
|
let t = Math.max(1, Math.ceil(e.box.width * n)), r = Math.max(1, Math.ceil(e.box.height * n));
|
|
3112
|
-
i > 0 && i + t >
|
|
3112
|
+
i > 0 && i + t > Ge && (i = 0, a += o + 1, o = 0);
|
|
3113
3113
|
let c = {
|
|
3114
3114
|
sprite: e,
|
|
3115
3115
|
x: i,
|
|
@@ -3135,7 +3135,7 @@ var Ye = function() {
|
|
|
3135
3135
|
return function(t, n, r, i) {
|
|
3136
3136
|
return e.apply(this, arguments);
|
|
3137
3137
|
};
|
|
3138
|
-
}(),
|
|
3138
|
+
}(), Je = (e) => {
|
|
3139
3139
|
let t = e, n = Number(t == null ? void 0 : t.width), r = Number(t == null ? void 0 : t.height);
|
|
3140
3140
|
if (!(n > 0 && r > 0 && n < 1e4 && r < 1e4)) throw Error(`A sprite's box must have a positive width and height, got ${JSON.stringify(e)}`);
|
|
3141
3141
|
return {
|
|
@@ -3143,11 +3143,11 @@ var Ye = function() {
|
|
|
3143
3143
|
height: r,
|
|
3144
3144
|
anchor: Array.isArray(t.anchor) ? [Number(t.anchor[0]), Number(t.anchor[1])] : [n / 2, r / 2]
|
|
3145
3145
|
};
|
|
3146
|
-
},
|
|
3146
|
+
}, Ye = (e) => {
|
|
3147
3147
|
let t = new Uint8Array(e), n = "";
|
|
3148
3148
|
for (let e = 0; e < t.length; e += 32768) n += String.fromCharCode(...t.subarray(e, e + 32768));
|
|
3149
3149
|
return btoa(n);
|
|
3150
|
-
},
|
|
3150
|
+
}, Xe = (e) => e instanceof Error ? e.message : String(e), Ze = [
|
|
3151
3151
|
[
|
|
3152
3152
|
"bounds",
|
|
3153
3153
|
"Bounds",
|
|
@@ -3173,7 +3173,7 @@ var Ye = function() {
|
|
|
3173
3173
|
"Keys",
|
|
3174
3174
|
"Each node's key"
|
|
3175
3175
|
]
|
|
3176
|
-
],
|
|
3176
|
+
], Qe = {
|
|
3177
3177
|
render: "render threw",
|
|
3178
3178
|
sprites: "A sprite couldn't be made",
|
|
3179
3179
|
scene: "Puzzmo would refuse this scene"
|
|
@@ -3182,8 +3182,8 @@ var Ye = function() {
|
|
|
3182
3182
|
* The Pmmg tab, shown when the game has a pmmg bundle: its table board drawn by Puzzmo's own renderer as the game is
|
|
3183
3183
|
* played, with a debug overlay, every sprite it has made, and the scene it returned
|
|
3184
3184
|
*/
|
|
3185
|
-
function
|
|
3186
|
-
let n = S(), a, o = null, s = !1, c = null, l = null, u, d = [], f = [], p = null, m = !1, h = null, g = null, _ = null, v = "session", y = null, b = [],
|
|
3185
|
+
function $e(e) {
|
|
3186
|
+
let n = S(), a, o = null, s = !1, c = null, l = null, u, d = [], f = [], p = null, m = !1, h = null, g = null, _ = null, v = "session", y = null, b = !1, x = [], w = !1, T = (e) => a.getElement(`#sim-pmmg-${e}`), E = () => ({
|
|
3187
3187
|
bounds: n.bounds,
|
|
3188
3188
|
grid: n.grid,
|
|
3189
3189
|
boxes: n.boxes,
|
|
@@ -3193,19 +3193,19 @@ function tt(e) {
|
|
|
3193
3193
|
hovered: g,
|
|
3194
3194
|
highlighted: _,
|
|
3195
3195
|
devicePixelRatio: window.devicePixelRatio || 1
|
|
3196
|
-
}),
|
|
3196
|
+
}), D = () => ({
|
|
3197
3197
|
fidelity: n.fidelity,
|
|
3198
3198
|
backgroundStyle: n.backgroundStyle === "theme" ? void 0 : n.backgroundStyle
|
|
3199
|
-
}),
|
|
3200
|
-
if (
|
|
3199
|
+
}), O = () => {
|
|
3200
|
+
if (x.length) return x[x.length - 1];
|
|
3201
3201
|
let e = a.state.puzzleData;
|
|
3202
3202
|
return e === null ? null : {
|
|
3203
3203
|
puzzle: e,
|
|
3204
3204
|
input: a.state.currentInputStr
|
|
3205
3205
|
};
|
|
3206
|
-
},
|
|
3206
|
+
}, k = function() {
|
|
3207
3207
|
var n = t(function* () {
|
|
3208
|
-
c = null, s = !0,
|
|
3208
|
+
c = null, s = !0, F();
|
|
3209
3209
|
try {
|
|
3210
3210
|
var t;
|
|
3211
3211
|
let n = yield e(), r = (t = n == null ? void 0 : n.default) == null ? n : t, i = r == null ? void 0 : r.table;
|
|
@@ -3214,10 +3214,10 @@ function tt(e) {
|
|
|
3214
3214
|
return;
|
|
3215
3215
|
}
|
|
3216
3216
|
u = i.contract, d = Array.isArray(i.fonts) ? i.fonts.filter((e) => typeof e == "string") : [];
|
|
3217
|
-
let a = yield
|
|
3218
|
-
f = a.warnings, u !== 1 && f.push(`contract is ${JSON.stringify(u)}, and Puzzmo knows contract 1`), l =
|
|
3217
|
+
let a = yield Ue(i.fonts);
|
|
3218
|
+
f = a.warnings, u !== 1 && f.push(`contract is ${JSON.stringify(u)}, and Puzzmo knows contract 1`), l = He(i, { fontFaces: a.fontFaces }), l.onRender = () => F();
|
|
3219
3219
|
} catch (e) {
|
|
3220
|
-
c = `The pmmg bundle didn't load: ${
|
|
3220
|
+
c = `The pmmg bundle didn't load: ${nt(e)}`, o = null;
|
|
3221
3221
|
} finally {
|
|
3222
3222
|
s = !1;
|
|
3223
3223
|
}
|
|
@@ -3225,142 +3225,142 @@ function tt(e) {
|
|
|
3225
3225
|
return function() {
|
|
3226
3226
|
return n.apply(this, arguments);
|
|
3227
3227
|
};
|
|
3228
|
-
}(),
|
|
3228
|
+
}(), A = function() {
|
|
3229
3229
|
var e = t(function* () {
|
|
3230
3230
|
var e;
|
|
3231
|
-
yield (e = o) == null ? o =
|
|
3231
|
+
yield (e = o) == null ? o = k() : e, l && !p ? j(!1) : w && n.follow && M(), F();
|
|
3232
3232
|
});
|
|
3233
3233
|
return function() {
|
|
3234
3234
|
return e.apply(this, arguments);
|
|
3235
3235
|
};
|
|
3236
|
-
}(),
|
|
3237
|
-
let t =
|
|
3238
|
-
if (!l || !t || !n || !r) return
|
|
3236
|
+
}(), j = (e) => {
|
|
3237
|
+
let t = O(), n = T("canvas"), r = T("stage");
|
|
3238
|
+
if (!l || !t || !n || !r) return F();
|
|
3239
3239
|
p == null || p.dispose(), m = !1, h = null, g = null;
|
|
3240
3240
|
let o = new i(n, l, "simulator", () => {
|
|
3241
|
-
p === o && (m = !0,
|
|
3241
|
+
p === o && (m = !0, F());
|
|
3242
3242
|
});
|
|
3243
3243
|
p = o, o.onDrawn = (e) => {
|
|
3244
|
-
p === o && (h = e,
|
|
3245
|
-
}, o.resize(r.clientWidth, r.clientHeight), o.setLook(
|
|
3246
|
-
let s = e ?
|
|
3247
|
-
s && o.update(s), o.update(t),
|
|
3248
|
-
},
|
|
3249
|
-
let e =
|
|
3250
|
-
p && e && p.update(e),
|
|
3251
|
-
},
|
|
3252
|
-
let t =
|
|
3244
|
+
p === o && (h = e, Ie(e, E()));
|
|
3245
|
+
}, o.resize(r.clientWidth, r.clientHeight), o.setLook(D()), o.setTheme(a.state.selectedTheme);
|
|
3246
|
+
let s = e ? x[x.length - 2] : void 0;
|
|
3247
|
+
s && o.update(s), o.update(t), w = !1, F();
|
|
3248
|
+
}, M = () => {
|
|
3249
|
+
let e = O();
|
|
3250
|
+
p && e && p.update(e), w = !1;
|
|
3251
|
+
}, N = (e) => {
|
|
3252
|
+
let t = x[x.length - 1];
|
|
3253
3253
|
if (t && t.puzzle === e.puzzle && t.input === e.input) return;
|
|
3254
|
-
|
|
3254
|
+
x.push(e), x.length > 2 && x.shift();
|
|
3255
3255
|
let r = a.state.activeTab === "pmmg";
|
|
3256
|
-
r && l && !p ?
|
|
3257
|
-
}, N = () => {
|
|
3258
|
-
let e = w("replay");
|
|
3259
|
-
e && (e.disabled = !l || b.length < 2);
|
|
3256
|
+
r && l && !p ? j(!1) : n.follow && r && p ? p.update(e) : n.follow && (w = !0), P();
|
|
3260
3257
|
}, P = () => {
|
|
3258
|
+
let e = T("replay");
|
|
3259
|
+
e && (e.disabled = !l || x.length < 2);
|
|
3260
|
+
}, F = () => {
|
|
3261
3261
|
if (!a) return;
|
|
3262
|
-
|
|
3263
|
-
let e =
|
|
3264
|
-
e && (e.textContent = t ? ` ${l.spritesAt(t.update.pixelsPerUnit).length}` : ""), n.subtab === "sprites" &&
|
|
3265
|
-
},
|
|
3266
|
-
let e =
|
|
3262
|
+
I(), P(), L(), R();
|
|
3263
|
+
let e = T("sprite-count"), t = l == null ? void 0 : l.latest;
|
|
3264
|
+
e && (e.textContent = t ? ` ${l.spritesAt(t.update.pixelsPerUnit).length}` : ""), n.subtab === "sprites" && z(), n.subtab === "scene" && te();
|
|
3265
|
+
}, I = () => {
|
|
3266
|
+
let e = T("status");
|
|
3267
3267
|
if (!e) return;
|
|
3268
|
-
if (c) return void (e.innerHTML = `<span class="pmmg-error">${
|
|
3268
|
+
if (c) return void (e.innerHTML = `<span class="pmmg-error">${Q(c)}</span>`);
|
|
3269
3269
|
if (!l) return void (e.textContent = s ? "Loading the pmmg bundle…" : "Open this tab to load the pmmg bundle");
|
|
3270
|
-
let t = v === "table" ? "Drawing what neighbours see: the game's UPDATE_TABLE_GAME_STATE" : "Drawing the session's puzzle and saves, as the game hasn't sent UPDATE_TABLE_GAME_STATE (sdk.table.updateGameState)", n =
|
|
3270
|
+
let t = v === "table" ? "Drawing what neighbours see: the game's UPDATE_TABLE_GAME_STATE" : "Drawing the session's puzzle and saves, as the game hasn't sent UPDATE_TABLE_GAME_STATE (sdk.table.updateGameState)", n = O() ? "" : "<div class=\"pmmg-dim\">Waiting for the game's first state</div>";
|
|
3271
3271
|
e.innerHTML = `
|
|
3272
|
-
<div>table · contract ${
|
|
3273
|
-
<div class="pmmg-dim">${
|
|
3274
|
-
},
|
|
3272
|
+
<div>table · contract ${Q(String(u))} · fonts: ${Q(d.join(", ") || "none")}</div>
|
|
3273
|
+
<div class="pmmg-dim">${Q(t)}</div>${n}`;
|
|
3274
|
+
}, L = () => {
|
|
3275
3275
|
var e, t;
|
|
3276
|
-
let n =
|
|
3276
|
+
let n = T("stats"), r = l == null ? void 0 : l.latest;
|
|
3277
3277
|
if (!n) return;
|
|
3278
3278
|
if (!r) return void (n.textContent = "");
|
|
3279
3279
|
let i = r.scene, a = [i && [
|
|
3280
|
-
`${
|
|
3280
|
+
`${Z(i.width)}×${Z(i.height)} units`,
|
|
3281
3281
|
`${i.nodes.length} nodes`,
|
|
3282
3282
|
`${(e = (t = i.effects) == null ? void 0 : t.length) == null ? 0 : e} effects`,
|
|
3283
|
-
i.grid && `grid ${
|
|
3283
|
+
i.grid && `grid ${Z(i.grid)}`
|
|
3284
3284
|
], [
|
|
3285
|
-
`render #${r.render}: ${
|
|
3286
|
-
r.spritesMs && `${
|
|
3285
|
+
`render #${r.render}: ${Z(r.renderMs)} ms`,
|
|
3286
|
+
r.spritesMs && `${Z(r.spritesMs)} ms of SVG`,
|
|
3287
3287
|
`made ${r.made.length}`,
|
|
3288
|
-
`${
|
|
3288
|
+
`${Z(r.update.pixelsPerUnit)} px/unit`,
|
|
3289
3289
|
r.update.skipped && `${r.update.skipped} skipped`
|
|
3290
|
-
]].filter((e) => !!e).map((e) => e.filter(Boolean).join(" · ")).map((e) => `<div>${
|
|
3290
|
+
]].filter((e) => !!e).map((e) => e.filter(Boolean).join(" · ")).map((e) => `<div>${Q(e)}</div>`);
|
|
3291
3291
|
matchMedia("(prefers-reduced-motion: reduce)").matches && a.push("<div class=\"pmmg-dim\">Reduced motion is on, so changes show at once, as they do at the table</div>"), n.innerHTML = a.join("");
|
|
3292
|
-
},
|
|
3292
|
+
}, R = () => {
|
|
3293
3293
|
var e;
|
|
3294
|
-
let t =
|
|
3294
|
+
let t = T("problems");
|
|
3295
3295
|
if (!t) return;
|
|
3296
3296
|
let n = l == null ? void 0 : l.latest, r = [];
|
|
3297
3297
|
if (n != null && n.error) {
|
|
3298
3298
|
let e = n.error.stack && n.error.stack !== n.error.message ? n.error.stack : "";
|
|
3299
|
-
r.push(`<div class="pmmg-problem error"><b>${
|
|
3300
|
-
${e ? `<details><summary>Stack</summary><pre class="pmmg-json">${
|
|
3299
|
+
r.push(`<div class="pmmg-problem error"><b>${Qe[n.error.phase]}</b> ${Q(n.error.message)}
|
|
3300
|
+
${e ? `<details><summary>Stack</summary><pre class="pmmg-json">${Q(e)}</pre></details>` : ""}</div>`);
|
|
3301
3301
|
}
|
|
3302
|
-
m && r.push("<div class=\"pmmg-problem error\">The board stopped, as a neighbour's does after its renders fail. Redraw to start again.</div>");
|
|
3303
|
-
for (let t of [...f, ...(e = l == null ? void 0 : l.warnings) == null ? [] : e]) r.push(`<div class="pmmg-problem warn">${
|
|
3302
|
+
m && r.push("<div class=\"pmmg-problem error\">The board stopped, as a neighbour's does after its renders fail. Redraw to start again.</div>"), b && v === "session" && r.push("<div class=\"pmmg-problem warn\">The game has loaded but hasn't sent its table state, so at the table nobody sees this player until it does. Call <code>sdk.table.updateGameState(input, { puzzleString })</code> once the board is built, before <code>gameLoaded()</code>, not only after a move.</div>");
|
|
3303
|
+
for (let t of [...f, ...(e = l == null ? void 0 : l.warnings) == null ? [] : e]) r.push(`<div class="pmmg-problem warn">${Q(t)}</div>`);
|
|
3304
3304
|
l && r.push("<div class=\"pmmg-problem note\">The bundle runs in this page here. At the table it runs in a worker with no DOM and no network, so anything that reaches for window, document or fetch only works here.</div>"), t.innerHTML = r.join("");
|
|
3305
|
-
},
|
|
3305
|
+
}, z = () => {
|
|
3306
3306
|
var e, t;
|
|
3307
|
-
let n =
|
|
3307
|
+
let n = T("sprites"), i = T("sprite-summary");
|
|
3308
3308
|
if (!n || !i) return;
|
|
3309
3309
|
let a = l == null ? void 0 : l.latest;
|
|
3310
3310
|
if (!l || !a) {
|
|
3311
|
-
n.replaceChildren(), i.textContent = l ? "Nothing rendered yet" : "",
|
|
3311
|
+
n.replaceChildren(), i.textContent = l ? "Nothing rendered yet" : "", V([]);
|
|
3312
3312
|
return;
|
|
3313
3313
|
}
|
|
3314
|
-
let o = a.update.pixelsPerUnit, s = l.spritesAt(o).sort((e, t) => e.id.localeCompare(t.id)), c = a.scene ? r(a.scene) : null, u = ((e = (t =
|
|
3314
|
+
let o = a.update.pixelsPerUnit, s = l.spritesAt(o).sort((e, t) => e.id.localeCompare(t.id)), c = a.scene ? r(a.scene) : null, u = ((e = (t = T("filter")) == null ? void 0 : t.value) == null ? "" : e).trim().toLowerCase(), d = u ? s.filter((e) => e.id.toLowerCase().includes(u)) : s, f = c ? s.filter((e) => !c.has(e.id)).length : 0, p = l.resolutions().filter((e) => e !== o);
|
|
3315
3315
|
i.textContent = [
|
|
3316
|
-
`${s.length} at ${
|
|
3316
|
+
`${s.length} at ${Z(o)} px/unit`,
|
|
3317
3317
|
f && `${f} not in this scene`,
|
|
3318
|
-
p.length && `also made at ${p.map(
|
|
3318
|
+
p.length && `also made at ${p.map(Z).join(", ")}`,
|
|
3319
3319
|
u && `${d.length} match`
|
|
3320
|
-
].filter(Boolean).join(" · "), n.replaceChildren(...d.map((e) =>
|
|
3321
|
-
},
|
|
3320
|
+
].filter(Boolean).join(" · "), n.replaceChildren(...d.map((e) => B(e, c))), V(s);
|
|
3321
|
+
}, B = (e, t) => {
|
|
3322
3322
|
let n = document.createElement("button");
|
|
3323
|
-
n.type = "button", n.className = `pmmg-sprite${t && !t.has(e.id) ? " unused" : ""}${e.id === _ ? " selected" : ""}`, n.title = `${e.id}\n${
|
|
3323
|
+
n.type = "button", n.className = `pmmg-sprite${t && !t.has(e.id) ? " unused" : ""}${e.id === _ ? " selected" : ""}`, n.title = `${e.id}\n${Z(e.width)}×${Z(e.height)} units, ${e.kind}${t && !t.has(e.id) ? ", not in this scene" : ""}`;
|
|
3324
3324
|
let r = document.createElement("span");
|
|
3325
|
-
r.className = "pmmg-sprite-picture", r.append(
|
|
3325
|
+
r.className = "pmmg-sprite-picture", r.append(et(e, 72, 64));
|
|
3326
3326
|
let i = document.createElement("span");
|
|
3327
3327
|
i.className = "pmmg-sprite-id", i.textContent = e.id;
|
|
3328
3328
|
let a = document.createElement("span");
|
|
3329
|
-
return a.className = "pmmg-sprite-meta", a.textContent = `${
|
|
3330
|
-
},
|
|
3329
|
+
return a.className = "pmmg-sprite-meta", a.textContent = `${Z(e.width)}×${Z(e.height)} ${e.kind}`, n.append(r, i, a), n.addEventListener("click", () => ee(_ === e.id ? null : e.id)), n;
|
|
3330
|
+
}, V = (e) => {
|
|
3331
3331
|
var t, n;
|
|
3332
|
-
let r =
|
|
3332
|
+
let r = T("detail");
|
|
3333
3333
|
if (!r) return;
|
|
3334
3334
|
let i = _ ? e.find((e) => e.id === _) : void 0;
|
|
3335
3335
|
if (!i) return void (r.innerHTML = "");
|
|
3336
|
-
let a =
|
|
3336
|
+
let a = H(i.id);
|
|
3337
3337
|
r.innerHTML = `
|
|
3338
3338
|
<div class="pmmg-detail">
|
|
3339
3339
|
<div class="pmmg-detail-head">
|
|
3340
|
-
<span class="pmmg-detail-id">${
|
|
3340
|
+
<span class="pmmg-detail-id">${Q(i.id)}</span>
|
|
3341
3341
|
<button class="simulator-btn tiny" type="button" data-pmmg-deselect>Close</button>
|
|
3342
3342
|
</div>
|
|
3343
3343
|
<div class="pmmg-detail-picture"></div>
|
|
3344
3344
|
<dl class="pmmg-facts">
|
|
3345
3345
|
<dt>Kind</dt><dd>${i.kind === "svg" ? "SVG markup" : "Drawn on a canvas"}</dd>
|
|
3346
|
-
<dt>Box</dt><dd>${
|
|
3347
|
-
<dt>Pixels</dt><dd>${i.bitmap.width}×${i.bitmap.height} at ${
|
|
3346
|
+
<dt>Box</dt><dd>${Z(i.width)}×${Z(i.height)} units, anchor ${Z(i.anchor[0])}, ${Z(i.anchor[1])}</dd>
|
|
3347
|
+
<dt>Pixels</dt><dd>${i.bitmap.width}×${i.bitmap.height} at ${Z(i.pixelsPerUnit)} px/unit</dd>
|
|
3348
3348
|
<dt>Made</dt><dd>render #${i.render}</dd>
|
|
3349
|
-
<dt>Used by</dt><dd>${a.length ?
|
|
3349
|
+
<dt>Used by</dt><dd>${a.length ? Q(a.slice(0, 24).join(", ") + (a.length > 24 ? `, and ${a.length - 24} more` : "")) : "nothing in this scene"}</dd>
|
|
3350
3350
|
</dl>
|
|
3351
|
-
${i.svg ? `<details><summary>SVG, ${i.svg.length.toLocaleString()} characters</summary><pre class="pmmg-json">${
|
|
3352
|
-
</div>`, (t = r.querySelector(".pmmg-detail-picture")) == null || t.append(
|
|
3353
|
-
},
|
|
3351
|
+
${i.svg ? `<details><summary>SVG, ${i.svg.length.toLocaleString()} characters</summary><pre class="pmmg-json">${Q(i.svg)}</pre></details>` : ""}
|
|
3352
|
+
</div>`, (t = r.querySelector(".pmmg-detail-picture")) == null || t.append(et(i, 300, 160)), (n = r.querySelector("[data-pmmg-deselect]")) == null || n.addEventListener("click", () => ee(null));
|
|
3353
|
+
}, H = (e) => {
|
|
3354
3354
|
var t, n;
|
|
3355
3355
|
let r = l == null || (t = l.latest) == null ? void 0 : t.scene;
|
|
3356
3356
|
if (!r) return [];
|
|
3357
3357
|
let i = (t) => [t.enter, t.exit].some((t) => t == null ? void 0 : t.keyframes.some((t) => t.sprite === e)), a = r.nodes.filter((t) => t.sprite === e || i(t)).map((e) => e.key), o = ((n = r.effects) == null ? [] : n).filter((t) => t.keyframes.some((t) => t.sprite === e)).map((e) => `${e.key} (effect)`);
|
|
3358
3358
|
return [...a, ...o];
|
|
3359
|
-
},
|
|
3360
|
-
_ = e, n.subtab === "sprites" &&
|
|
3359
|
+
}, ee = (e) => {
|
|
3360
|
+
_ = e, n.subtab === "sprites" && z(), p == null || p.redraw();
|
|
3361
3361
|
}, te = () => {
|
|
3362
3362
|
var e;
|
|
3363
|
-
let t =
|
|
3363
|
+
let t = T("update"), n = T("scene"), r = l == null ? void 0 : l.latest;
|
|
3364
3364
|
if (!(!t || !n)) {
|
|
3365
3365
|
if (!r) {
|
|
3366
3366
|
t.textContent = "", n.textContent = l ? "Nothing rendered yet" : "";
|
|
@@ -3374,38 +3374,38 @@ function tt(e) {
|
|
|
3374
3374
|
`${r.update.skipped} skipped`,
|
|
3375
3375
|
`${r.update.fidelity} fidelity on ${r.update.backgroundStyle}`,
|
|
3376
3376
|
r.scene ? "as Puzzmo keeps it" : "as returned, since Puzzmo refused it"
|
|
3377
|
-
].join(" · "), n.textContent =
|
|
3377
|
+
].join(" · "), n.textContent = tt((e = r.scene) == null ? r.raw : e);
|
|
3378
3378
|
}
|
|
3379
3379
|
}, ne = () => {
|
|
3380
|
-
let e =
|
|
3380
|
+
let e = T("root");
|
|
3381
3381
|
e == null || e.querySelectorAll("[data-pmmg-subtab]").forEach((e) => {
|
|
3382
3382
|
e.classList.toggle("active", e.dataset.pmmgSubtab === n.subtab);
|
|
3383
3383
|
}), e == null || e.querySelectorAll("[data-pmmg-pane]").forEach((e) => {
|
|
3384
3384
|
e.classList.toggle("active", e.dataset.pmmgPane === n.subtab);
|
|
3385
|
-
}),
|
|
3386
|
-
},
|
|
3387
|
-
let t =
|
|
3385
|
+
}), F();
|
|
3386
|
+
}, U = (e) => {
|
|
3387
|
+
let t = T("canvas");
|
|
3388
3388
|
if (!t || !h) return null;
|
|
3389
3389
|
let n = t.getBoundingClientRect();
|
|
3390
3390
|
if (!n.width) return null;
|
|
3391
3391
|
let r = t.width / n.width;
|
|
3392
3392
|
return [(e.clientX - n.left) * r / h.scale, (e.clientY - n.top) * r / h.scale];
|
|
3393
|
-
},
|
|
3393
|
+
}, W = (e) => {
|
|
3394
3394
|
var t;
|
|
3395
|
-
let n =
|
|
3395
|
+
let n = T("hover");
|
|
3396
3396
|
if (!n) return;
|
|
3397
|
-
let r = e && h ?
|
|
3397
|
+
let r = e && h ? Re(h.nodes, e, (e) => l == null ? void 0 : l.anySprite(e)) : null, i = r ? h.scene.nodes.find((e) => e.key === r.key) : void 0, a = (t = r == null ? void 0 : r.key) == null ? null : t;
|
|
3398
3398
|
if (a !== g && (g = a, p == null || p.redraw()), !e) return void (n.textContent = "Hover the board to see a node, click one to pick its sprite");
|
|
3399
|
-
if (!r) return void (n.textContent = `${
|
|
3399
|
+
if (!r) return void (n.textContent = `${Z(e[0])}, ${Z(e[1])}`);
|
|
3400
3400
|
n.textContent = [
|
|
3401
3401
|
r.key,
|
|
3402
3402
|
r.sprite,
|
|
3403
|
-
i && `at ${
|
|
3404
|
-
(i == null ? void 0 : i.rotation) && `${
|
|
3405
|
-
(i == null ? void 0 : i.scale) && `scale ${i.scale.map(
|
|
3406
|
-
(i == null ? void 0 : i.opacity) !== void 0 && `opacity ${
|
|
3403
|
+
i && `at ${Z(i.x)}, ${Z(i.y)}`,
|
|
3404
|
+
(i == null ? void 0 : i.rotation) && `${Z(i.rotation)}°`,
|
|
3405
|
+
(i == null ? void 0 : i.scale) && `scale ${i.scale.map(Z).join(", ")}`,
|
|
3406
|
+
(i == null ? void 0 : i.opacity) !== void 0 && `opacity ${Z(i.opacity)}`,
|
|
3407
3407
|
(i == null ? void 0 : i.tint) && `tint ${i.tint}`,
|
|
3408
|
-
(i == null ? void 0 : i.brightness) !== void 0 && `brightness ${
|
|
3408
|
+
(i == null ? void 0 : i.brightness) !== void 0 && `brightness ${Z(i.brightness)}`,
|
|
3409
3409
|
(i == null ? void 0 : i.blend) && i.blend !== "normal" && i.blend,
|
|
3410
3410
|
(i == null ? void 0 : i.parent) && `in ${i.parent}`,
|
|
3411
3411
|
r.exiting && "exiting"
|
|
@@ -3449,7 +3449,7 @@ function tt(e) {
|
|
|
3449
3449
|
<div class="pmmg-stage" id="sim-pmmg-stage"><canvas class="pmmg-backdrop" id="sim-pmmg-canvas"></canvas></div>
|
|
3450
3450
|
<div class="pmmg-hover" id="sim-pmmg-hover">Hover the board to see a node, click one to pick its sprite</div>
|
|
3451
3451
|
<div class="pmmg-toggles">
|
|
3452
|
-
${
|
|
3452
|
+
${Ze.map(([e, t, n]) => `<label class="pmmg-check" title="${n}"><input type="checkbox" data-pmmg-pref="${e}" /> ${t}</label>`).join("")}
|
|
3453
3453
|
<select class="simulator-select pmmg-backdrop-select" id="sim-pmmg-backdrop" title="What's behind the board">
|
|
3454
3454
|
<option value="checker">Checker</option>
|
|
3455
3455
|
<option value="theme">Theme bg</option>
|
|
@@ -3479,7 +3479,7 @@ function tt(e) {
|
|
|
3479
3479
|
bind(e) {
|
|
3480
3480
|
var t, r, i, o;
|
|
3481
3481
|
a = e;
|
|
3482
|
-
let s =
|
|
3482
|
+
let s = T("root");
|
|
3483
3483
|
if (!s) return;
|
|
3484
3484
|
s.style.setProperty("--pmmg-theme-bg", a.state.selectedTheme.g_bg), s.querySelectorAll("[data-pmmg-subtab]").forEach((e) => {
|
|
3485
3485
|
e.addEventListener("click", () => {
|
|
@@ -3488,33 +3488,33 @@ function tt(e) {
|
|
|
3488
3488
|
}), s.querySelectorAll("[data-pmmg-pref]").forEach((e) => {
|
|
3489
3489
|
let t = e.dataset.pmmgPref;
|
|
3490
3490
|
e.checked = n[t], e.addEventListener("change", () => {
|
|
3491
|
-
n[t] = e.checked, C(n), t === "follow" && e.checked &&
|
|
3491
|
+
n[t] = e.checked, C(n), t === "follow" && e.checked && M(), p == null || p.redraw();
|
|
3492
3492
|
});
|
|
3493
3493
|
});
|
|
3494
|
-
let c =
|
|
3494
|
+
let c = T("backdrop");
|
|
3495
3495
|
c && (c.value = n.backdrop, c.addEventListener("change", () => {
|
|
3496
3496
|
n.backdrop = c.value, C(n), s.className = `pmmg-view pmmg-backdrop-${n.backdrop}`;
|
|
3497
3497
|
}));
|
|
3498
|
-
let u =
|
|
3498
|
+
let u = T("fidelity");
|
|
3499
3499
|
u && (u.value = n.fidelity, u.addEventListener("change", () => {
|
|
3500
|
-
n.fidelity = u.value, C(n), p == null || p.setLook(
|
|
3500
|
+
n.fidelity = u.value, C(n), p == null || p.setLook(D());
|
|
3501
3501
|
}));
|
|
3502
|
-
let d =
|
|
3502
|
+
let d = T("background-style");
|
|
3503
3503
|
d && (d.options[0].textContent = `Theme's (${a.state.selectedTheme.type})`, d.value = n.backgroundStyle, d.addEventListener("change", () => {
|
|
3504
|
-
n.backgroundStyle = d.value, C(n), p == null || p.setLook(
|
|
3505
|
-
})), (t =
|
|
3506
|
-
l == null || l.clear(),
|
|
3507
|
-
}), (o =
|
|
3508
|
-
let f =
|
|
3509
|
-
f == null || f.addEventListener("mousemove", (e) =>
|
|
3510
|
-
let t =
|
|
3511
|
-
n != null && n.sprite &&
|
|
3504
|
+
n.backgroundStyle = d.value, C(n), p == null || p.setLook(D());
|
|
3505
|
+
})), (t = T("replay")) == null || t.addEventListener("click", () => j(!0)), (r = T("redraw")) == null || r.addEventListener("click", () => j(!1)), (i = T("clear")) == null || i.addEventListener("click", () => {
|
|
3506
|
+
l == null || l.clear(), j(!1);
|
|
3507
|
+
}), (o = T("filter")) == null || o.addEventListener("input", () => z());
|
|
3508
|
+
let f = T("canvas");
|
|
3509
|
+
f == null || f.addEventListener("mousemove", (e) => W(U(e))), f == null || f.addEventListener("mouseleave", () => W(null)), f == null || f.addEventListener("click", (e) => {
|
|
3510
|
+
let t = U(e), n = t && h ? Re(h.nodes, t, (e) => l == null ? void 0 : l.anySprite(e)) : null;
|
|
3511
|
+
n != null && n.sprite && ee(_ === n.sprite ? null : n.sprite);
|
|
3512
3512
|
});
|
|
3513
|
-
let m =
|
|
3513
|
+
let m = T("stage");
|
|
3514
3514
|
m && new ResizeObserver(([e]) => p == null ? void 0 : p.resize(e.contentRect.width, e.contentRect.height)).observe(m), ne();
|
|
3515
3515
|
},
|
|
3516
3516
|
onActivate() {
|
|
3517
|
-
|
|
3517
|
+
A();
|
|
3518
3518
|
},
|
|
3519
3519
|
onMessage(e, t, n) {
|
|
3520
3520
|
if (e === "UPDATE_TABLE_GAME_STATE" && typeof (t == null ? void 0 : t.inputString) == "string") {
|
|
@@ -3522,23 +3522,23 @@ function tt(e) {
|
|
|
3522
3522
|
typeof t.puzzleString == "string" && (y = t.puzzleString);
|
|
3523
3523
|
let e = (r = y) == null ? n.state.puzzleData : r;
|
|
3524
3524
|
if (e === null) return;
|
|
3525
|
-
v !== "table" && (v = "table",
|
|
3525
|
+
v !== "table" && (v = "table", x.length = 0), N({
|
|
3526
3526
|
puzzle: e,
|
|
3527
3527
|
input: t.inputString
|
|
3528
|
-
});
|
|
3528
|
+
}), F();
|
|
3529
3529
|
} else if (e === "UPLOAD_NEW_GAME_STATE" && v === "session") {
|
|
3530
3530
|
var i, a;
|
|
3531
3531
|
let e = (i = t == null || (a = t.input) == null ? void 0 : a.boardState) == null ? t == null ? void 0 : t.boardState : i, r = n.state.puzzleData;
|
|
3532
|
-
typeof e == "string" && r !== null &&
|
|
3532
|
+
typeof e == "string" && r !== null && N({
|
|
3533
3533
|
puzzle: r,
|
|
3534
3534
|
input: e
|
|
3535
3535
|
});
|
|
3536
|
-
} else e === "READY_GAME_LOADED" && n.state.activeTab === "pmmg"
|
|
3536
|
+
} else e === "READY_GAME_LOADED" && (b = !0, n.state.activeTab === "pmmg" ? A() : F());
|
|
3537
3537
|
}
|
|
3538
3538
|
};
|
|
3539
3539
|
}
|
|
3540
3540
|
/** A sprite's picture on a canvas fitted inside a box, enlarged in whole pixels so its real pixels show, with its anchor */
|
|
3541
|
-
var
|
|
3541
|
+
var et = (e, t, n) => {
|
|
3542
3542
|
let r = window.devicePixelRatio || 1, { bitmap: i } = e, a = Math.min(t / (i.width / r), n / (i.height / r), 8), o = Math.max(1, i.width / r * a), s = Math.max(1, i.height / r * a), c = document.createElement("canvas");
|
|
3543
3543
|
c.className = "pmmg-backdrop", c.width = Math.max(1, Math.round(o * r)), c.height = Math.max(1, Math.round(s * r)), c.style.width = `${o}px`, c.style.height = `${s}px`;
|
|
3544
3544
|
let l = c.getContext("2d");
|
|
@@ -3549,16 +3549,16 @@ var nt = (e, t, n) => {
|
|
|
3549
3549
|
} catch (e) {}
|
|
3550
3550
|
let u = e.anchor[0] / e.width * c.width, d = e.anchor[1] / e.height * c.height, f = 4 * r;
|
|
3551
3551
|
return l.strokeStyle = "#f472b6", l.lineWidth = r, l.beginPath(), l.moveTo(u - f, d), l.lineTo(u + f, d), l.moveTo(u, d - f), l.lineTo(u, d + f), l.stroke(), c;
|
|
3552
|
-
},
|
|
3552
|
+
}, Z = (e) => Number.isInteger(e) ? String(e) : e.toFixed(2).replace(/\.?0+$/, ""), tt = (e) => {
|
|
3553
3553
|
try {
|
|
3554
3554
|
var t;
|
|
3555
3555
|
return (t = JSON.stringify(e, null, 2)) == null ? String(e) : t;
|
|
3556
3556
|
} catch (t) {
|
|
3557
3557
|
return String(e);
|
|
3558
3558
|
}
|
|
3559
|
-
},
|
|
3559
|
+
}, Q = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """), nt = (e) => e instanceof Error ? e.message : String(e);
|
|
3560
3560
|
/** Generate theme preview HTML showing key colors */
|
|
3561
|
-
function
|
|
3561
|
+
function rt(e) {
|
|
3562
3562
|
let t = [
|
|
3563
3563
|
e.key,
|
|
3564
3564
|
e.subBrand,
|
|
@@ -3569,7 +3569,7 @@ function at(e) {
|
|
|
3569
3569
|
].map((e) => `<div class="simulator-theme-preview-cell" style="background: ${e}"></div>`).join("");
|
|
3570
3570
|
return `<div class="simulator-theme-preview" style="background: ${e.g_bg}">${t}</div>`;
|
|
3571
3571
|
}
|
|
3572
|
-
function
|
|
3572
|
+
function it() {
|
|
3573
3573
|
return {
|
|
3574
3574
|
id: "theme",
|
|
3575
3575
|
label: "Theme",
|
|
@@ -3581,17 +3581,17 @@ function ot() {
|
|
|
3581
3581
|
t && c.forEach((n) => {
|
|
3582
3582
|
let r = document.createElement("div");
|
|
3583
3583
|
r.className = `simulator-theme-item${n.name === e.state.selectedTheme.name ? " selected" : ""}`, r.innerHTML = `
|
|
3584
|
-
${
|
|
3584
|
+
${rt(n)}
|
|
3585
3585
|
<div class="simulator-theme-name">${n.name}</div>
|
|
3586
3586
|
<div class="simulator-theme-type">${n.type}</div>
|
|
3587
3587
|
`, r.addEventListener("click", () => {
|
|
3588
|
-
console.log("Simulator: Theme changed, reloading...", n.name),
|
|
3588
|
+
console.log("Simulator: Theme changed, reloading...", n.name), I(n.name), window.location.reload();
|
|
3589
3589
|
}), t.appendChild(r);
|
|
3590
3590
|
});
|
|
3591
3591
|
}
|
|
3592
3592
|
};
|
|
3593
3593
|
}
|
|
3594
|
-
var
|
|
3594
|
+
var at = [
|
|
3595
3595
|
{
|
|
3596
3596
|
name: "app (desktop)",
|
|
3597
3597
|
context: [{
|
|
@@ -3638,8 +3638,8 @@ var st = [
|
|
|
3638
3638
|
* The bootstrap is only read at game boot, so applying a change persists it to localStorage and
|
|
3639
3639
|
* restarts (reloads) the page — the same flow as the Theme tab.
|
|
3640
3640
|
*/
|
|
3641
|
-
function
|
|
3642
|
-
let t = [...
|
|
3641
|
+
function ot(e = []) {
|
|
3642
|
+
let t = [...at, ...e];
|
|
3643
3643
|
return {
|
|
3644
3644
|
id: "host",
|
|
3645
3645
|
label: "Host",
|
|
@@ -3656,7 +3656,7 @@ function ct(e = []) {
|
|
|
3656
3656
|
<div class="host-note" id="host-source"></div>
|
|
3657
3657
|
<select class="simulator-select" id="host-presets">
|
|
3658
3658
|
<option value="">Preset…</option>
|
|
3659
|
-
${t.map((e, t) => `<option value="${t}">${
|
|
3659
|
+
${t.map((e, t) => `<option value="${t}">${st(e.name)}</option>`).join("")}
|
|
3660
3660
|
</select>
|
|
3661
3661
|
<textarea class="simulator-textarea" id="host-json" spellcheck="false"></textarea>
|
|
3662
3662
|
<div class="host-actions">
|
|
@@ -3693,42 +3693,42 @@ function ct(e = []) {
|
|
|
3693
3693
|
};
|
|
3694
3694
|
}
|
|
3695
3695
|
/** Minimal HTML-escape so preset names can't break the simulator markup. */
|
|
3696
|
-
function
|
|
3696
|
+
function st(e) {
|
|
3697
3697
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
3698
3698
|
}
|
|
3699
|
-
var
|
|
3700
|
-
localStorage.setItem(
|
|
3701
|
-
},
|
|
3699
|
+
var ct = "puzzmo_sim_api_mode", lt = "http://localhost:8911", ut = "https://api.puzzmo.com", dt = () => localStorage.getItem(ct) === "dev" ? "dev" : "prod", ft = (e) => {
|
|
3700
|
+
localStorage.setItem(ct, e);
|
|
3701
|
+
}, pt = null, mt = function() {
|
|
3702
3702
|
var e = t(function* () {
|
|
3703
|
-
if (
|
|
3703
|
+
if (pt !== null) return pt;
|
|
3704
3704
|
try {
|
|
3705
|
-
let e = new AbortController(), t = setTimeout(() => e.abort(), 1e3), n = yield fetch(`${
|
|
3706
|
-
return clearTimeout(t),
|
|
3705
|
+
let e = new AbortController(), t = setTimeout(() => e.abort(), 1e3), n = yield fetch(`${lt}/healthz`, { signal: e.signal });
|
|
3706
|
+
return clearTimeout(t), pt = n.ok, pt;
|
|
3707
3707
|
} catch (e) {
|
|
3708
|
-
return
|
|
3708
|
+
return pt = !1, !1;
|
|
3709
3709
|
}
|
|
3710
3710
|
});
|
|
3711
3711
|
return function() {
|
|
3712
3712
|
return e.apply(this, arguments);
|
|
3713
3713
|
};
|
|
3714
|
-
}(),
|
|
3715
|
-
apiURL:
|
|
3714
|
+
}(), ht = () => ({
|
|
3715
|
+
apiURL: dt() === "dev" ? lt : ut,
|
|
3716
3716
|
clientID: "protosdk:oauthclient",
|
|
3717
3717
|
redirectUri: `${window.location.origin}/oauth/callback`
|
|
3718
|
-
}),
|
|
3718
|
+
}), gt = () => {
|
|
3719
3719
|
let e = new Uint8Array(32);
|
|
3720
3720
|
return crypto.getRandomValues(e), Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
3721
|
-
},
|
|
3722
|
-
let e = localStorage.getItem(
|
|
3721
|
+
}, _t = "puzzmo_sim_oauth_token", vt = "puzzmo_sim_oauth_refresh_token", yt = (e) => localStorage.setItem(_t, e), bt = (e) => localStorage.setItem(vt, e), xt = () => {
|
|
3722
|
+
let e = localStorage.getItem(_t);
|
|
3723
3723
|
return e && `${e.substring(0, 20)}`, e;
|
|
3724
|
-
},
|
|
3725
|
-
localStorage.removeItem(
|
|
3726
|
-
},
|
|
3727
|
-
let e =
|
|
3724
|
+
}, St = () => localStorage.getItem(vt), Ct = () => {
|
|
3725
|
+
localStorage.removeItem(_t), localStorage.removeItem(vt);
|
|
3726
|
+
}, wt = () => {
|
|
3727
|
+
let e = ht(), t = gt();
|
|
3728
3728
|
sessionStorage.setItem("oauth_state", t), sessionStorage.setItem("oauth_return_url", window.location.href);
|
|
3729
3729
|
let n = new URL(`${e.apiURL}/oauth/auth`);
|
|
3730
3730
|
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();
|
|
3731
|
-
},
|
|
3731
|
+
}, Tt = (e) => {
|
|
3732
3732
|
try {
|
|
3733
3733
|
let t = e.split(".");
|
|
3734
3734
|
if (t.length !== 3) return !0;
|
|
@@ -3737,11 +3737,11 @@ var ut = "puzzmo_sim_api_mode", dt = "http://localhost:8911", ft = "https://api.
|
|
|
3737
3737
|
} catch (e) {
|
|
3738
3738
|
return !0;
|
|
3739
3739
|
}
|
|
3740
|
-
},
|
|
3740
|
+
}, Et = function() {
|
|
3741
3741
|
var e = t(function* () {
|
|
3742
|
-
let e =
|
|
3742
|
+
let e = St();
|
|
3743
3743
|
if (!e) return !1;
|
|
3744
|
-
let t =
|
|
3744
|
+
let t = ht();
|
|
3745
3745
|
try {
|
|
3746
3746
|
let n = new URLSearchParams({
|
|
3747
3747
|
grant_type: "refresh_token",
|
|
@@ -3755,9 +3755,9 @@ var ut = "puzzmo_sim_api_mode", dt = "http://localhost:8911", ft = "https://api.
|
|
|
3755
3755
|
if (!r.ok) return r.statusText, !1;
|
|
3756
3756
|
let i = yield r.json(), a = i.access_token || i.accessToken;
|
|
3757
3757
|
if (!a) return !1;
|
|
3758
|
-
|
|
3758
|
+
yt(a);
|
|
3759
3759
|
let o = i.refresh_token || i.refreshToken;
|
|
3760
|
-
return o &&
|
|
3760
|
+
return o && bt(o), !0;
|
|
3761
3761
|
} catch (e) {
|
|
3762
3762
|
return !1;
|
|
3763
3763
|
}
|
|
@@ -3765,9 +3765,9 @@ var ut = "puzzmo_sim_api_mode", dt = "http://localhost:8911", ft = "https://api.
|
|
|
3765
3765
|
return function() {
|
|
3766
3766
|
return e.apply(this, arguments);
|
|
3767
3767
|
};
|
|
3768
|
-
}(),
|
|
3768
|
+
}(), Dt = function() {
|
|
3769
3769
|
var e = t(function* (e, t) {
|
|
3770
|
-
let n =
|
|
3770
|
+
let n = ht(), r = sessionStorage.getItem("oauth_state");
|
|
3771
3771
|
if (!r || r !== t) return null;
|
|
3772
3772
|
sessionStorage.removeItem("oauth_state");
|
|
3773
3773
|
try {
|
|
@@ -3789,13 +3789,13 @@ var ut = "puzzmo_sim_api_mode", dt = "http://localhost:8911", ft = "https://api.
|
|
|
3789
3789
|
return function(t, n) {
|
|
3790
3790
|
return e.apply(this, arguments);
|
|
3791
3791
|
};
|
|
3792
|
-
}(),
|
|
3792
|
+
}(), Ot = function() {
|
|
3793
3793
|
var e = t(function* (e, t = {}) {
|
|
3794
|
-
let n =
|
|
3794
|
+
let n = ht(), r = xt();
|
|
3795
3795
|
if (!r) throw Error("Not authenticated");
|
|
3796
|
-
if (
|
|
3797
|
-
if (r =
|
|
3798
|
-
} else throw
|
|
3796
|
+
if (Tt(r)) if (yield Et()) {
|
|
3797
|
+
if (r = xt(), !r) throw Error("Token refresh succeeded but no token available");
|
|
3798
|
+
} else throw Ct(), Error("Session expired. Please log in again.");
|
|
3799
3799
|
let i = yield fetch(`${n.apiURL}/graphql`, {
|
|
3800
3800
|
method: "POST",
|
|
3801
3801
|
headers: {
|
|
@@ -3814,7 +3814,7 @@ var ut = "puzzmo_sim_api_mode", dt = "http://localhost:8911", ft = "https://api.
|
|
|
3814
3814
|
return function(t) {
|
|
3815
3815
|
return e.apply(this, arguments);
|
|
3816
3816
|
};
|
|
3817
|
-
}(),
|
|
3817
|
+
}(), kt = (e) => {
|
|
3818
3818
|
try {
|
|
3819
3819
|
let t = e.split(".");
|
|
3820
3820
|
return t.length, t.length === 3 ? JSON.parse(atob(t[1])) : null;
|
|
@@ -3822,15 +3822,15 @@ var ut = "puzzmo_sim_api_mode", dt = "http://localhost:8911", ft = "https://api.
|
|
|
3822
3822
|
return null;
|
|
3823
3823
|
}
|
|
3824
3824
|
};
|
|
3825
|
-
function
|
|
3825
|
+
function At() {
|
|
3826
3826
|
let e = !1;
|
|
3827
3827
|
return {
|
|
3828
3828
|
id: "auth",
|
|
3829
3829
|
label: "Auth",
|
|
3830
3830
|
render() {
|
|
3831
|
-
let e =
|
|
3831
|
+
let e = xt(), t = !!e, n = dt(), r = n === "dev" ? lt : ut, i = `<button class="simulator-btn tiny" id="auth-dev-toggle" style="display: none;">${n === "dev" ? "Using Dev" : "Dev"}</button>`;
|
|
3832
3832
|
if (t) {
|
|
3833
|
-
let t =
|
|
3833
|
+
let t = kt(e), n = t != null && t.exp ? (/* @__PURE__ */ new Date(t.exp * 1e3)).toLocaleString() : "Unknown", a = !!St(), o = a ? kt(St()) : null, s = o != null && o.exp ? (/* @__PURE__ */ new Date(o.exp * 1e3)).toLocaleString() : null;
|
|
3834
3834
|
return `
|
|
3835
3835
|
<div class="simulator-section">
|
|
3836
3836
|
<div class="simulator-section-title auth-title-row">
|
|
@@ -3871,7 +3871,7 @@ function jt() {
|
|
|
3871
3871
|
</div>
|
|
3872
3872
|
<p class="auth-description">
|
|
3873
3873
|
Login with your Puzzmo account to make authenticated API requests.
|
|
3874
|
-
${n === "dev" ? `<br><strong>Using local dev server:</strong> ${
|
|
3874
|
+
${n === "dev" ? `<br><strong>Using local dev server:</strong> ${lt}` : ""}
|
|
3875
3875
|
</p>
|
|
3876
3876
|
<div class="simulator-row">
|
|
3877
3877
|
<button class="simulator-btn primary" id="auth-login">Login with Puzzmo</button>
|
|
@@ -3882,21 +3882,21 @@ function jt() {
|
|
|
3882
3882
|
},
|
|
3883
3883
|
bind(n) {
|
|
3884
3884
|
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");
|
|
3885
|
-
e ?
|
|
3886
|
-
e && c && (c.style.display = "",
|
|
3885
|
+
e ? pt && c && (c.style.display = "", dt() === "dev" && c.classList.add("active")) : (e = !0, mt().then((e) => {
|
|
3886
|
+
e && c && (c.style.display = "", dt() === "dev" && c.classList.add("active"));
|
|
3887
3887
|
})), c == null || c.addEventListener("click", () => {
|
|
3888
|
-
|
|
3888
|
+
ft(dt() === "dev" ? "prod" : "dev"), Ct(), window.location.reload();
|
|
3889
3889
|
}), r == null || r.addEventListener("click", () => {
|
|
3890
|
-
|
|
3890
|
+
wt();
|
|
3891
3891
|
}), i == null || i.addEventListener("click", () => {
|
|
3892
|
-
|
|
3892
|
+
Ct(), window.location.reload();
|
|
3893
3893
|
}), a == null || a.addEventListener("click", t(function* () {
|
|
3894
|
-
a.disabled = !0, a.textContent = "Refreshing...", (yield
|
|
3894
|
+
a.disabled = !0, a.textContent = "Refreshing...", (yield Et()) ? window.location.reload() : (a.textContent = "Refresh Failed", a.disabled = !1);
|
|
3895
3895
|
})), o == null || o.addEventListener("click", t(function* () {
|
|
3896
3896
|
if (s) {
|
|
3897
3897
|
s.innerHTML = "<div class=\"loading\">Loading...</div>";
|
|
3898
3898
|
try {
|
|
3899
|
-
let t = yield
|
|
3899
|
+
let t = yield Ot("\n query {\n currentUser {\n id\n username\n usernameID\n name\n }\n }\n ");
|
|
3900
3900
|
if (t.errors) {
|
|
3901
3901
|
var e;
|
|
3902
3902
|
s.innerHTML = `<div class="error">Error: ${((e = t.errors[0]) == null ? void 0 : e.message) || "Unknown error"}</div>`;
|
|
@@ -3918,13 +3918,13 @@ function jt() {
|
|
|
3918
3918
|
if (n && r) {
|
|
3919
3919
|
let t = e.getElement("#auth-status");
|
|
3920
3920
|
t && (t.innerHTML = "<span class=\"indicator waiting\"></span><span>Exchanging code...</span>");
|
|
3921
|
-
let i = yield
|
|
3921
|
+
let i = yield Dt(n, r);
|
|
3922
3922
|
if (window.history.replaceState({}, "", window.location.pathname), i) {
|
|
3923
3923
|
let e = i.access_token || i.accessToken;
|
|
3924
3924
|
if (e) {
|
|
3925
|
-
|
|
3925
|
+
yt(e);
|
|
3926
3926
|
let t = i.refresh_token || i.refreshToken;
|
|
3927
|
-
t &&
|
|
3927
|
+
t && bt(t);
|
|
3928
3928
|
}
|
|
3929
3929
|
window.location.reload();
|
|
3930
3930
|
} else {
|
|
@@ -3936,9 +3936,9 @@ function jt() {
|
|
|
3936
3936
|
}
|
|
3937
3937
|
};
|
|
3938
3938
|
}
|
|
3939
|
-
var
|
|
3940
|
-
localStorage.removeItem(
|
|
3941
|
-
},
|
|
3939
|
+
var jt = "puzzmo_sim_api_mode", Mt = "http://localhost:8911", Nt = "https://api.puzzmo.com", Pt = "puzzmo_sim_oauth_token", Ft = "puzzmo_sim_oauth_refresh_token", It = () => localStorage.getItem(jt) === "dev" ? "dev" : "prod", Lt = () => localStorage.getItem(Pt), Rt = () => localStorage.getItem(Ft), zt = (e) => localStorage.setItem(Pt, e), Bt = (e) => localStorage.setItem(Ft, e), Vt = () => {
|
|
3940
|
+
localStorage.removeItem(Pt), localStorage.removeItem(Ft);
|
|
3941
|
+
}, Ht = (e) => {
|
|
3942
3942
|
try {
|
|
3943
3943
|
let t = e.split(".");
|
|
3944
3944
|
if (t.length !== 3) return !0;
|
|
@@ -3947,11 +3947,11 @@ var Mt = "puzzmo_sim_api_mode", Nt = "http://localhost:8911", Pt = "https://api.
|
|
|
3947
3947
|
} catch (e) {
|
|
3948
3948
|
return !0;
|
|
3949
3949
|
}
|
|
3950
|
-
},
|
|
3950
|
+
}, Ut = function() {
|
|
3951
3951
|
var e = t(function* () {
|
|
3952
|
-
let e =
|
|
3952
|
+
let e = Rt();
|
|
3953
3953
|
if (!e) return !1;
|
|
3954
|
-
let t =
|
|
3954
|
+
let t = It() === "dev" ? Mt : Nt;
|
|
3955
3955
|
try {
|
|
3956
3956
|
let n = new URLSearchParams({
|
|
3957
3957
|
grant_type: "refresh_token",
|
|
@@ -3965,9 +3965,9 @@ var Mt = "puzzmo_sim_api_mode", Nt = "http://localhost:8911", Pt = "https://api.
|
|
|
3965
3965
|
if (!r.ok) return !1;
|
|
3966
3966
|
let i = yield r.json(), a = i.access_token || i.accessToken;
|
|
3967
3967
|
if (!a) return !1;
|
|
3968
|
-
|
|
3968
|
+
zt(a);
|
|
3969
3969
|
let o = i.refresh_token || i.refreshToken;
|
|
3970
|
-
return o &&
|
|
3970
|
+
return o && Bt(o), !0;
|
|
3971
3971
|
} catch (e) {
|
|
3972
3972
|
return !1;
|
|
3973
3973
|
}
|
|
@@ -3975,13 +3975,13 @@ var Mt = "puzzmo_sim_api_mode", Nt = "http://localhost:8911", Pt = "https://api.
|
|
|
3975
3975
|
return function() {
|
|
3976
3976
|
return e.apply(this, arguments);
|
|
3977
3977
|
};
|
|
3978
|
-
}(),
|
|
3978
|
+
}(), Wt = function() {
|
|
3979
3979
|
var e = t(function* (e, t = {}) {
|
|
3980
|
-
let n =
|
|
3980
|
+
let n = It() === "dev" ? Mt : Nt, r = Lt();
|
|
3981
3981
|
if (!r) throw Error("Not authenticated");
|
|
3982
|
-
if (
|
|
3983
|
-
if (r =
|
|
3984
|
-
} else throw
|
|
3982
|
+
if (Ht(r)) if (yield Ut()) {
|
|
3983
|
+
if (r = Lt(), !r) throw Error("Token refresh succeeded but no token available");
|
|
3984
|
+
} else throw Vt(), Error("Session expired. Please log in again.");
|
|
3985
3985
|
let i = yield fetch(`${n}/graphql`, {
|
|
3986
3986
|
method: "POST",
|
|
3987
3987
|
headers: {
|
|
@@ -4000,19 +4000,19 @@ var Mt = "puzzmo_sim_api_mode", Nt = "http://localhost:8911", Pt = "https://api.
|
|
|
4000
4000
|
return function(t) {
|
|
4001
4001
|
return e.apply(this, arguments);
|
|
4002
4002
|
};
|
|
4003
|
-
}(),
|
|
4003
|
+
}(), 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", Kt = "\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", qt = (e, t) => {
|
|
4004
4004
|
let n = t - 1, r = Math.floor(n / 31), i = n % 31, a = [...e];
|
|
4005
4005
|
for (; a.length <= r;) a.push(0);
|
|
4006
4006
|
return a[r] = a[r] ^ 1 << i, a;
|
|
4007
4007
|
};
|
|
4008
|
-
const
|
|
4009
|
-
function
|
|
4008
|
+
const Jt = () => !!Lt();
|
|
4009
|
+
function Yt() {
|
|
4010
4010
|
let n = null, r = !1, i = null, a = function() {
|
|
4011
4011
|
var e = t(function* (e) {
|
|
4012
4012
|
r = !0, i = null;
|
|
4013
4013
|
try {
|
|
4014
4014
|
var t;
|
|
4015
|
-
let r = yield Gt
|
|
4015
|
+
let r = yield Wt(Gt, { slug: e });
|
|
4016
4016
|
if (r.errors) {
|
|
4017
4017
|
var a;
|
|
4018
4018
|
i = ((a = r.errors[0]) == null ? void 0 : a.message) || "Unknown error", n = null;
|
|
@@ -4029,10 +4029,10 @@ function Xt() {
|
|
|
4029
4029
|
}(), o = function() {
|
|
4030
4030
|
var r = t(function* (t) {
|
|
4031
4031
|
if (!n) return;
|
|
4032
|
-
let r =
|
|
4032
|
+
let r = qt(n.featuresArr, t);
|
|
4033
4033
|
try {
|
|
4034
4034
|
var i;
|
|
4035
|
-
let t = yield
|
|
4035
|
+
let t = yield Wt(Kt, {
|
|
4036
4036
|
gameSlug: n.slug,
|
|
4037
4037
|
input: { featuresArr: r }
|
|
4038
4038
|
});
|
|
@@ -4080,7 +4080,7 @@ function Xt() {
|
|
|
4080
4080
|
id: "features",
|
|
4081
4081
|
label: "Features",
|
|
4082
4082
|
render() {
|
|
4083
|
-
return
|
|
4083
|
+
return Jt() ? `
|
|
4084
4084
|
<div class="features-view-container">
|
|
4085
4085
|
<div class="simulator-section">
|
|
4086
4086
|
<div class="simulator-section-title">Game Features</div>
|
|
@@ -4121,7 +4121,7 @@ function Xt() {
|
|
|
4121
4121
|
e && (yield d(e));
|
|
4122
4122
|
})), i == null || i.addEventListener("keypress", (e) => {
|
|
4123
4123
|
e.key === "Enter" && (r == null || r.click());
|
|
4124
|
-
}), console.log("[FeaturesView] bind called, ctx.gameSlug:", e.gameSlug, "slugInput:", i), e.gameSlug && i && (i.value = e.gameSlug,
|
|
4124
|
+
}), console.log("[FeaturesView] bind called, ctx.gameSlug:", e.gameSlug, "slugInput:", i), e.gameSlug && i && (i.value = e.gameSlug, Jt() && !n && d(e.gameSlug)), u();
|
|
4125
4125
|
},
|
|
4126
4126
|
onActivate(e) {
|
|
4127
4127
|
let t = e.getElement("#simulator-tab-features");
|
|
@@ -4145,11 +4145,11 @@ function Xt() {
|
|
|
4145
4145
|
* tuning it needs to see it.
|
|
4146
4146
|
*/
|
|
4147
4147
|
/** Space the keys occupy. */
|
|
4148
|
-
var
|
|
4148
|
+
var Xt = 200, Zt = 24;
|
|
4149
4149
|
/** What the keyboard takes off the bottom of the game, and what the game must lay out without. */
|
|
4150
|
-
const
|
|
4150
|
+
const Qt = Xt + Zt;
|
|
4151
4151
|
/** Drag-cursor thresholds, from useKeyboardCursor in @puzzmo-com/keyboard. */
|
|
4152
|
-
var
|
|
4152
|
+
var $t = 6, en = 2.5, tn = 100, nn = (e, t) => e ? "14.7%" : t ? "17.85%" : "9.75%", rn = (e, t) => {
|
|
4153
4153
|
let n = e.replace("#", ""), r = n.length === 3 ? [...n].map((e) => e + e).join("") : n, i = parseInt(r, 16);
|
|
4154
4154
|
return r.length !== 6 || Number.isNaN(i) ? e : `rgba(${i >> 16 & 255}, ${i >> 8 & 255}, ${i & 255}, ${t})`;
|
|
4155
4155
|
}, an = (e) => e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<"), on = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
@@ -4157,7 +4157,7 @@ function sn(e) {
|
|
|
4157
4157
|
let { theme: t, sendToGame: n } = e, r = !1, i = null, a = null, o = document.createElement("style");
|
|
4158
4158
|
o.id = "sim-docked-kbd-page-style", o.textContent = `
|
|
4159
4159
|
html.sim-kbd-docked #simulator {
|
|
4160
|
-
bottom: ${
|
|
4160
|
+
bottom: ${Qt + 4}px;
|
|
4161
4161
|
}
|
|
4162
4162
|
`;
|
|
4163
4163
|
/** The element the game mounted into: `#root` per the SDK's page template, else the page's first element. */
|
|
@@ -4170,7 +4170,7 @@ function sn(e) {
|
|
|
4170
4170
|
let { height: t, maxHeight: n, position: r } = e.style;
|
|
4171
4171
|
c = () => {
|
|
4172
4172
|
e.style.height = t, e.style.maxHeight = n, e.style.position = r, c = null;
|
|
4173
|
-
}, e.style.height = `calc(100% - ${
|
|
4173
|
+
}, e.style.height = `calc(100% - ${Qt}px)`, e.style.maxHeight = `calc(100% - ${Qt}px)`, getComputedStyle(e).position === "static" && (e.style.position = "relative");
|
|
4174
4174
|
}, u = (e, n) => {
|
|
4175
4175
|
var r;
|
|
4176
4176
|
let i = n.disabled.includes(e), a = n.highlight.includes(e);
|
|
@@ -4185,7 +4185,7 @@ function sn(e) {
|
|
|
4185
4185
|
"overflow:hidden",
|
|
4186
4186
|
"background:transparent",
|
|
4187
4187
|
"pointer-events:none",
|
|
4188
|
-
`border:${i ? `1px dashed ${
|
|
4188
|
+
`border:${i ? `1px dashed ${rn(t.fg, .25)}` : a ? `2px solid ${rn(t.fg, .75)}` : `1px solid ${rn(t.fg, .4)}`}`,
|
|
4189
4189
|
ln((r = n.individualKeyStyles) == null || (r = r[e]) == null ? void 0 : r.background)
|
|
4190
4190
|
].filter(Boolean).join(";");
|
|
4191
4191
|
}, d = (e, n) => {
|
|
@@ -4195,14 +4195,14 @@ function sn(e) {
|
|
|
4195
4195
|
"letter-spacing:0.5px",
|
|
4196
4196
|
"text-transform:uppercase",
|
|
4197
4197
|
"white-space:nowrap",
|
|
4198
|
-
`color:${
|
|
4198
|
+
`color:${rn(t.fg, n.disabled.includes(e) ? .3 : .65)}`,
|
|
4199
4199
|
n.highlight.includes(e) ? "" : ln(n.keyStyles),
|
|
4200
4200
|
ln((r = n.individualKeyStyles) == null || (r = r[e]) == null ? void 0 : r.text)
|
|
4201
4201
|
].filter(Boolean).join(";");
|
|
4202
4202
|
}, f = (e, t) => {
|
|
4203
4203
|
var n, r;
|
|
4204
4204
|
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 = [
|
|
4205
|
-
`width:${
|
|
4205
|
+
`width:${nn(t.l.includes(e), t.xl.includes(e))}`,
|
|
4206
4206
|
`flex:${o ? "1 0 auto" : "0 1 auto"}`,
|
|
4207
4207
|
"height:100%",
|
|
4208
4208
|
"display:flex",
|
|
@@ -4220,7 +4220,7 @@ function sn(e) {
|
|
|
4220
4220
|
return `${n.map((t, n) => {
|
|
4221
4221
|
var i, a;
|
|
4222
4222
|
return `<div style="${`height:${r};display:flex;flex-direction:row;align-items:center;justify-content:${(i = (a = e.rowPositioning) == null ? void 0 : a[n]) == null ? "center" : i}`}">${[...t].map((t) => f(t, e)).join("")}</div>`;
|
|
4223
|
-
}).join("")}${`<div id="sim-docked-kbd-cursor" style="position:absolute;inset:0;z-index:1;background:${
|
|
4223
|
+
}).join("")}${`<div id="sim-docked-kbd-cursor" style="position:absolute;inset:0;z-index:1;background:${rn(t.fg, .12)};opacity:0;transition:opacity 0.1s ease-in-out;pointer-events:none"></div>`}`;
|
|
4224
4224
|
}, m = !1, h = [0, 0], g = null, _ = 0, v = null, y = null, b = (e) => {
|
|
4225
4225
|
let t = a == null ? void 0 : a.querySelector("#sim-docked-kbd-cursor");
|
|
4226
4226
|
t && (t.style.opacity = e ? "0.5" : "0");
|
|
@@ -4232,7 +4232,7 @@ function sn(e) {
|
|
|
4232
4232
|
}, C = (e) => {
|
|
4233
4233
|
y = S(e), a == null || a.setPointerCapture(e.pointerId);
|
|
4234
4234
|
}, w = (e) => {
|
|
4235
|
-
!(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, _ >=
|
|
4235
|
+
!(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, _ >= $t && Date.now() - v >= tn && (m = !0, b(!0))), m && g && (h = [h[0] + (e.clientX - g.clientX) * en, h[1] + (e.clientY - g.clientY) * en]), g = {
|
|
4236
4236
|
clientX: e.clientX,
|
|
4237
4237
|
clientY: e.clientY,
|
|
4238
4238
|
pointerId: e.pointerId
|
|
@@ -4245,10 +4245,10 @@ function sn(e) {
|
|
|
4245
4245
|
"left:0",
|
|
4246
4246
|
"right:0",
|
|
4247
4247
|
"bottom:0",
|
|
4248
|
-
`height:${
|
|
4248
|
+
`height:${Qt}px`,
|
|
4249
4249
|
"box-sizing:border-box",
|
|
4250
4250
|
"padding-top:8px",
|
|
4251
|
-
`padding-bottom:${
|
|
4251
|
+
`padding-bottom:${Zt}px`,
|
|
4252
4252
|
"display:flex",
|
|
4253
4253
|
"flex-direction:column",
|
|
4254
4254
|
"z-index:999998",
|
|
@@ -4256,7 +4256,7 @@ function sn(e) {
|
|
|
4256
4256
|
"user-select:none",
|
|
4257
4257
|
"-webkit-user-select:none",
|
|
4258
4258
|
`background:${t.a_bg}`,
|
|
4259
|
-
`border-top:1px solid ${
|
|
4259
|
+
`border-top:1px solid ${rn(t.fg, .2)}`
|
|
4260
4260
|
].join(";"), a.innerHTML = p(i), a.addEventListener("pointerdown", C), a.addEventListener("pointermove", w), a.addEventListener("pointerup", T), a.addEventListener("pointercancel", () => x()), a.addEventListener("contextmenu", (e) => e.preventDefault()), document.body.appendChild(a), o.isConnected || document.head.appendChild(o), document.documentElement.classList.add("sim-kbd-docked"), l());
|
|
4261
4261
|
}, D = () => {
|
|
4262
4262
|
a && (a.remove(), a = null, document.documentElement.classList.remove("sim-kbd-docked"), c == null || c(), x());
|
|
@@ -4309,7 +4309,7 @@ var un = (e, t) => {
|
|
|
4309
4309
|
return `<button class="${f}" data-key="${e}" style="${p}" ${s ? "disabled" : ""}><span style="${m}">${o}</span></button>`;
|
|
4310
4310
|
}, dn = (e) => `<div class="sim-kb">${e.layout.filter((e) => e != null).map((t) => `<div class="sim-kb-row">${[...t].map((t) => un(t, e)).join("")}</div>`).join("")}</div>`;
|
|
4311
4311
|
function fn() {
|
|
4312
|
-
let e = null, t = null, n = (t) => e ? t ? `<div class="sim-kb-empty">Shown under the game at production size, taking ${
|
|
4312
|
+
let e = null, t = null, n = (t) => e ? t ? `<div class="sim-kb-empty">Shown under the game at production size, taking ${Qt}px off the bottom.<br>Uncheck to preview the layout here instead.</div>` : dn(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>";
|
|
4313
4313
|
return {
|
|
4314
4314
|
id: "kbd",
|
|
4315
4315
|
label: "Kbd",
|
|
@@ -4628,19 +4628,19 @@ function wn(n = {}) {
|
|
|
4628
4628
|
slug: n.slug,
|
|
4629
4629
|
hasFixtures: !!n.fixtures
|
|
4630
4630
|
}), xn) return n.fixtures && (console.log("[Simulator] Instance already exists, updating fixtures"), xn.updateFixtures(n.fixtures)), xn;
|
|
4631
|
-
let c = (r = n.autoStart) == null ? !0 : r, l = n.fixtures ?
|
|
4632
|
-
|
|
4633
|
-
|
|
4631
|
+
let c = (r = n.autoStart) == null ? !0 : r, l = n.fixtures ? U(n.fixtures) : null, u = l ? Array.from(l.keys()).sort() : [], d = ve(), f = Fe(), p = [
|
|
4632
|
+
ie(),
|
|
4633
|
+
ue(),
|
|
4634
4634
|
d,
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4635
|
+
ye(),
|
|
4636
|
+
be(),
|
|
4637
|
+
Oe((i = (a = n.integrations) == null ? void 0 : a.checklists) == null ? [] : i),
|
|
4638
4638
|
f,
|
|
4639
|
-
...n.pmmgBundle ? [
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4639
|
+
...n.pmmgBundle ? [$e(n.pmmgBundle)] : [],
|
|
4640
|
+
it(),
|
|
4641
|
+
ot(n.hostContextPresets),
|
|
4642
|
+
At(),
|
|
4643
|
+
Yt(),
|
|
4644
4644
|
fn(),
|
|
4645
4645
|
mn(),
|
|
4646
4646
|
vn(),
|
|
@@ -4653,7 +4653,7 @@ function wn(n = {}) {
|
|
|
4653
4653
|
minimize: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><rect x=\"1\" y=\"4\" width=\"8\" height=\"2\"/></svg>",
|
|
4654
4654
|
expand: "<svg width=\"8\" height=\"8\" viewBox=\"0 0 8 8\" fill=\"currentColor\"><polygon points=\"1,1 7,4 1,7\"/></svg>"
|
|
4655
4655
|
}, _ = document.createElement("div");
|
|
4656
|
-
_.id = "simulator", _.dataset.puzzmoBuild =
|
|
4656
|
+
_.id = "simulator", _.dataset.puzzmoBuild = re, _.innerHTML = `
|
|
4657
4657
|
<style>
|
|
4658
4658
|
:root {
|
|
4659
4659
|
--sim-bg: #1a1a2e;
|
|
@@ -6355,20 +6355,20 @@ function wn(n = {}) {
|
|
|
6355
6355
|
n && (n.textContent = e), r && (r.className = `indicator ${t}`, r.textContent = i), b.className = t, b.textContent = i, x.textContent = e;
|
|
6356
6356
|
}, N = (e, t) => {
|
|
6357
6357
|
t && t !== "0" ? E.innerHTML = `${e}<span class="penalty">+${t}</span>` : E.textContent = e;
|
|
6358
|
-
},
|
|
6358
|
+
}, I = (e) => {
|
|
6359
6359
|
var t;
|
|
6360
|
-
h.activeTab = e, O.classList.remove("hidden"),
|
|
6360
|
+
h.activeTab = e, O.classList.remove("hidden"), F(e), D.querySelectorAll(".simulator-tab").forEach((t) => {
|
|
6361
6361
|
t.classList.toggle("active", t.getAttribute("data-tab") === e);
|
|
6362
6362
|
}), _.querySelectorAll(".simulator-tab-content").forEach((t) => {
|
|
6363
6363
|
t.classList.toggle("active", t.id === `simulator-tab-${e}`);
|
|
6364
6364
|
}), w.classList.toggle("active", e === "auth");
|
|
6365
6365
|
let n = p.find((t) => t.id === e);
|
|
6366
|
-
n == null || (t = n.onActivate) == null || t.call(n,
|
|
6367
|
-
},
|
|
6368
|
-
h.isCollapsed = e, v.classList.toggle("collapsed", e), P(e), e ? (O.classList.add("hidden"), D.querySelectorAll(".simulator-tab").forEach((e) => e.classList.remove("active"))) :
|
|
6369
|
-
},
|
|
6370
|
-
f.updatePreview(
|
|
6371
|
-
},
|
|
6366
|
+
n == null || (t = n.onActivate) == null || t.call(n, G);
|
|
6367
|
+
}, L = (e) => {
|
|
6368
|
+
h.isCollapsed = e, v.classList.toggle("collapsed", e), P(e), e ? (O.classList.add("hidden"), D.querySelectorAll(".simulator-tab").forEach((e) => e.classList.remove("active"))) : I(h.activeTab);
|
|
6369
|
+
}, R = () => {
|
|
6370
|
+
f.updatePreview(G);
|
|
6371
|
+
}, z = function() {
|
|
6372
6372
|
var e = t(function* () {
|
|
6373
6373
|
var e, t;
|
|
6374
6374
|
if (h.appliedPuzzleOverride !== null) return h.appliedPuzzleOverride;
|
|
@@ -6383,16 +6383,16 @@ function wn(n = {}) {
|
|
|
6383
6383
|
puzzle: i
|
|
6384
6384
|
}), h.originalPuzzle = a;
|
|
6385
6385
|
let o = k("#simulator-puzzle");
|
|
6386
|
-
return o && (o.value = h.originalPuzzle), h.activeTab === "thumb" &&
|
|
6386
|
+
return o && (o.value = h.originalPuzzle), h.activeTab === "thumb" && R(), h.puzzleData;
|
|
6387
6387
|
});
|
|
6388
6388
|
return function() {
|
|
6389
6389
|
return e.apply(this, arguments);
|
|
6390
6390
|
};
|
|
6391
|
-
}(),
|
|
6392
|
-
d.addLogEntry(e,
|
|
6393
|
-
}),
|
|
6394
|
-
|
|
6395
|
-
},
|
|
6391
|
+
}(), B = ee((e) => {
|
|
6392
|
+
d.addLogEntry(e, G);
|
|
6393
|
+
}), V = (e, t) => {
|
|
6394
|
+
te(e, t, B);
|
|
6395
|
+
}, H = (e) => {
|
|
6396
6396
|
var t;
|
|
6397
6397
|
let n = (t = e.buckets) != null && t.length ? e.buckets : u, r = n.find((e) => {
|
|
6398
6398
|
var t;
|
|
@@ -6414,48 +6414,48 @@ function wn(n = {}) {
|
|
|
6414
6414
|
puzzle: l.get(c).get(d.join("/"))
|
|
6415
6415
|
}
|
|
6416
6416
|
};
|
|
6417
|
-
},
|
|
6417
|
+
}, W = (e, t) => {
|
|
6418
6418
|
let n = _.querySelector(`[data-badge="${e}"]`);
|
|
6419
6419
|
n && (n.textContent = t && t > 0 ? String(t) : "");
|
|
6420
|
-
},
|
|
6420
|
+
}, G = {
|
|
6421
6421
|
state: h,
|
|
6422
6422
|
getElement: k,
|
|
6423
|
-
sendToGame:
|
|
6424
|
-
logMessage:
|
|
6425
|
-
loadPuzzle:
|
|
6423
|
+
sendToGame: V,
|
|
6424
|
+
logMessage: B.log,
|
|
6425
|
+
loadPuzzle: z,
|
|
6426
6426
|
updateStatus: M,
|
|
6427
6427
|
updateTimer: N,
|
|
6428
|
-
setCollapsed:
|
|
6429
|
-
switchTab:
|
|
6430
|
-
updateThumbnail:
|
|
6431
|
-
updateBadge:
|
|
6428
|
+
setCollapsed: L,
|
|
6429
|
+
switchTab: I,
|
|
6430
|
+
updateThumbnail: R,
|
|
6431
|
+
updateBadge: W,
|
|
6432
6432
|
fixtures: l,
|
|
6433
6433
|
fixtureCategories: u,
|
|
6434
6434
|
gameSlug: (s = n.slug) == null ? null : s
|
|
6435
6435
|
};
|
|
6436
|
-
console.log("[Simulator] Context created with gameSlug:",
|
|
6436
|
+
console.log("[Simulator] Context created with gameSlug:", G.gameSlug), p.forEach((e) => e.bind(G)), D.querySelectorAll(".simulator-tab").forEach((e) => {
|
|
6437
6437
|
e.addEventListener("click", () => {
|
|
6438
6438
|
let t = e.getAttribute("data-tab");
|
|
6439
|
-
|
|
6439
|
+
I(t), W(t, 0);
|
|
6440
6440
|
});
|
|
6441
6441
|
}), T.addEventListener("click", (e) => {
|
|
6442
|
-
e.stopPropagation(),
|
|
6442
|
+
e.stopPropagation(), L(!0);
|
|
6443
6443
|
}), S.addEventListener("click", (e) => {
|
|
6444
|
-
e.stopPropagation(), h.isPaused ? (
|
|
6444
|
+
e.stopPropagation(), h.isPaused ? (V("RESUME_GAME", {}), h.isPaused = !1, A(!1), M("Running", "ready")) : (V("PAUSE_GAME", {}), h.isPaused = !0, A(!0), M("Paused", "paused"));
|
|
6445
6445
|
let t = k("#simulator-pause");
|
|
6446
6446
|
t && (t.textContent = h.isPaused ? "Resume" : "Pause");
|
|
6447
6447
|
}), C.addEventListener("click", (e) => {
|
|
6448
|
-
e.stopPropagation(),
|
|
6448
|
+
e.stopPropagation(), V("RETRY_PUZZLE", {}), h.hasStarted = !1, h.isPaused = !1, A(!1), S.disabled = !0, M("Ready to retry", "ready");
|
|
6449
6449
|
let t = k("#simulator-pause"), n = k("#simulator-start");
|
|
6450
6450
|
t && (t.disabled = !0, t.textContent = "Pause"), n && (n.textContent = "Start");
|
|
6451
6451
|
}), w.addEventListener("click", (e) => {
|
|
6452
|
-
e.stopPropagation(), h.isCollapsed &&
|
|
6452
|
+
e.stopPropagation(), h.isCollapsed && L(!1), I("auth");
|
|
6453
6453
|
}), y.addEventListener("click", (e) => {
|
|
6454
|
-
h.isCollapsed && e.target !== T &&
|
|
6455
|
-
}), h.isCollapsed ||
|
|
6456
|
-
let
|
|
6457
|
-
(
|
|
6458
|
-
let
|
|
6454
|
+
h.isCollapsed && e.target !== T && L(!1);
|
|
6455
|
+
}), h.isCollapsed || I(h.activeTab);
|
|
6456
|
+
let K = new URLSearchParams(window.location.search);
|
|
6457
|
+
(K.has("code") || K.has("error")) && (L(!1), I("auth"));
|
|
6458
|
+
let ae = (t) => {
|
|
6459
6459
|
let r = n.slug ? e(e({}, Tn), {}, {
|
|
6460
6460
|
slug: n.slug,
|
|
6461
6461
|
stableSlug: n.slug
|
|
@@ -6501,13 +6501,13 @@ function wn(n = {}) {
|
|
|
6501
6501
|
hostContext: h.hostContext,
|
|
6502
6502
|
appRuntimeContract: "1.0"
|
|
6503
6503
|
};
|
|
6504
|
-
},
|
|
6504
|
+
}, oe = ["1.0", "1.1"], se = function() {
|
|
6505
6505
|
var r = t(function* (t) {
|
|
6506
6506
|
let r = n.session !== !1 || t === "1.0";
|
|
6507
6507
|
r ? n.session === !1 && console.warn("Simulator: `session: false` needs a game built on an SDK speaking runtime contract 1.1 or later") : console.log("Simulator: Sending READY_DATA without a session"), M(r ? "Loading puzzle..." : "Sending READY_DATA...", "waiting");
|
|
6508
6508
|
try {
|
|
6509
|
-
let n = e(e({},
|
|
6510
|
-
M("Sending READY_DATA...", "waiting"),
|
|
6509
|
+
let n = e(e({}, ae(r ? yield z() : null)), {}, { appRuntimeContract: t });
|
|
6510
|
+
M("Sending READY_DATA...", "waiting"), V("READY_DATA", n), M("Waiting for game to load...", "waiting");
|
|
6511
6511
|
} catch (e) {
|
|
6512
6512
|
M(`Error: ${e}`, "paused");
|
|
6513
6513
|
}
|
|
@@ -6515,23 +6515,23 @@ function wn(n = {}) {
|
|
|
6515
6515
|
return function(e) {
|
|
6516
6516
|
return r.apply(this, arguments);
|
|
6517
6517
|
};
|
|
6518
|
-
}(),
|
|
6518
|
+
}(), ce = () => {
|
|
6519
6519
|
console.log("Simulator: Game loaded, ready to start"), C.disabled = !1, p.forEach((e) => {
|
|
6520
6520
|
var t;
|
|
6521
|
-
return (t = e.onMessage) == null ? void 0 : t.call(e, "READY_GAME_LOADED", void 0,
|
|
6521
|
+
return (t = e.onMessage) == null ? void 0 : t.call(e, "READY_GAME_LOADED", void 0, G);
|
|
6522
6522
|
}), c && !h.hasStarted && setTimeout(() => {
|
|
6523
6523
|
let e = k("#simulator-start");
|
|
6524
6524
|
e == null || e.click(), S.disabled = !1, h.hasStarted = !0, M("Running", "ready");
|
|
6525
6525
|
}, 100);
|
|
6526
6526
|
};
|
|
6527
|
-
return
|
|
6527
|
+
return ne((e, t) => {
|
|
6528
6528
|
var n, r;
|
|
6529
6529
|
if (e === "READY") {
|
|
6530
|
-
console.log("Simulator: Received READY from game"),
|
|
6530
|
+
console.log("Simulator: Received READY from game"), se(oe.includes(t == null ? void 0 : t.runtimeContract) ? t.runtimeContract : "1.0");
|
|
6531
6531
|
return;
|
|
6532
6532
|
}
|
|
6533
6533
|
if (e === "READY_GAME_LOADED") {
|
|
6534
|
-
|
|
6534
|
+
ce();
|
|
6535
6535
|
return;
|
|
6536
6536
|
}
|
|
6537
6537
|
if (e === "TIMER_TICK") {
|
|
@@ -6548,11 +6548,11 @@ function wn(n = {}) {
|
|
|
6548
6548
|
}
|
|
6549
6549
|
p.forEach((n) => {
|
|
6550
6550
|
var r;
|
|
6551
|
-
return (r = n.onMessage) == null ? void 0 : r.call(n, e, t,
|
|
6551
|
+
return (r = n.onMessage) == null ? void 0 : r.call(n, e, t, G);
|
|
6552
6552
|
});
|
|
6553
6553
|
let i = (n = t == null || (r = t.input) == null ? void 0 : r.boardState) == null ? t == null ? void 0 : t.boardState : n;
|
|
6554
|
-
if (e === "UPLOAD_NEW_GAME_STATE" && i && (h.currentInputStr = i, h.activeTab === "thumb" &&
|
|
6555
|
-
|
|
6554
|
+
if (e === "UPLOAD_NEW_GAME_STATE" && i && (h.currentInputStr = i, h.activeTab === "thumb" && R(), console.log("Simulator: Game state uploaded", t)), e === "COMPLETE_REPEATABLE_RUN" && console.log("Simulator: Repeatable run completed", t), e === "START_REPEATABLE_ROUND" && console.log("Simulator: Repeatable round started", t), e === "RESUME_REPEATABLE_ROUND" && console.log("Simulator: Repeatable round resumed", t), e === "UPDATE_TABLE_GAME_STATE" && console.log("Simulator: Table game state", t), e === "REQUEST_PUZZLE") {
|
|
6555
|
+
V("PUZZLE_DATA", H(t));
|
|
6556
6556
|
return;
|
|
6557
6557
|
}
|
|
6558
6558
|
if (e === "UPDATE_GAME_USER_STATE" && typeof (t == null ? void 0 : t.state) == "string") {
|
|
@@ -6563,22 +6563,22 @@ function wn(n = {}) {
|
|
|
6563
6563
|
}, console.log("Simulator: Game user storage updated", t);
|
|
6564
6564
|
}
|
|
6565
6565
|
e === "GAME_COMPLETED" && (console.log("Simulator: Game completed!", t), S.disabled = !0, h.hasStarted = !1, M("Completed!", "complete"));
|
|
6566
|
-
},
|
|
6566
|
+
}, B), console.log("Simulator initialized"), xn = {
|
|
6567
6567
|
updateFixtures: (e) => {
|
|
6568
|
-
l =
|
|
6568
|
+
l = U(e), u = Array.from(l.keys()).sort(), G.fixtures = l, G.fixtureCategories = u;
|
|
6569
6569
|
let t = localStorage.getItem("simulator-fixture-category");
|
|
6570
6570
|
if (!h.selectedCategory || !u.includes(h.selectedCategory)) {
|
|
6571
6571
|
var n;
|
|
6572
6572
|
h.selectedCategory = t && u.includes(t) ? t : (n = u[0]) == null ? null : n;
|
|
6573
6573
|
}
|
|
6574
6574
|
let r = p.find((e) => e.id === "ctrl");
|
|
6575
|
-
r == null || r.bind(
|
|
6575
|
+
r == null || r.bind(G), console.log("Simulator: Fixtures updated", {
|
|
6576
6576
|
categories: u,
|
|
6577
6577
|
selectedCategory: h.selectedCategory
|
|
6578
6578
|
});
|
|
6579
6579
|
},
|
|
6580
|
-
sendToGame:
|
|
6581
|
-
loadPuzzle:
|
|
6580
|
+
sendToGame: V,
|
|
6581
|
+
loadPuzzle: z
|
|
6582
6582
|
}, xn;
|
|
6583
6583
|
}
|
|
6584
6584
|
/** The game the simulator stands in for, with placeholder IDs since nothing is stored */
|
|
@@ -6598,6 +6598,6 @@ var Tn = {
|
|
|
6598
6598
|
}
|
|
6599
6599
|
}
|
|
6600
6600
|
};
|
|
6601
|
-
export { vn as n,
|
|
6601
|
+
export { vn as n, re as r, wn as t };
|
|
6602
6602
|
|
|
6603
|
-
//# sourceMappingURL=createSimulator-
|
|
6603
|
+
//# sourceMappingURL=createSimulator-Dk_oznjb.js.map
|