@puzzmo/sdk 1.0.54 → 1.0.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{createSimulator-CB_nIwbm.cjs → createSimulator-CiUXlL22.cjs} +30 -12
- package/dist/createSimulator-CiUXlL22.cjs.map +1 -0
- package/dist/{createSimulator-bJ1qCLmt.js → createSimulator-CoVR6n2p.js} +186 -112
- package/dist/createSimulator-CoVR6n2p.js.map +1 -0
- package/dist/simulator/createSimulator.d.ts.map +1 -1
- package/dist/simulator/index.cjs +1 -1
- package/dist/simulator/index.d.ts +1 -0
- package/dist/simulator/index.d.ts.map +1 -1
- package/dist/simulator/index.js +2 -2
- package/dist/simulator/standalone.cjs +1 -1
- package/dist/simulator/standalone.js +1 -1
- package/dist/simulator/views/SoundView.d.ts +8 -0
- package/dist/simulator/views/SoundView.d.ts.map +1 -0
- package/dist/simulator/views/index.d.ts +1 -0
- package/dist/simulator/views/index.d.ts.map +1 -1
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/vite.cjs +1 -1
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.ts +10 -0
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +6 -5
- package/dist/vite.js.map +1 -1
- package/package.json +1 -1
- package/dist/createSimulator-CB_nIwbm.cjs.map +0 -1
- package/dist/createSimulator-bJ1qCLmt.js.map +0 -1
|
@@ -460,31 +460,31 @@ function C() {
|
|
|
460
460
|
function te(e) {
|
|
461
461
|
localStorage.setItem(r.collapsed, String(e));
|
|
462
462
|
}
|
|
463
|
-
function
|
|
463
|
+
function w(e) {
|
|
464
464
|
localStorage.setItem(r.tab, e);
|
|
465
465
|
}
|
|
466
|
-
function
|
|
466
|
+
function T(e) {
|
|
467
467
|
localStorage.setItem(r.theme, e);
|
|
468
468
|
}
|
|
469
|
-
function
|
|
469
|
+
function E(e) {
|
|
470
470
|
localStorage.setItem(r.fixtureCategory, e);
|
|
471
471
|
}
|
|
472
|
-
function
|
|
472
|
+
function D(e) {
|
|
473
473
|
localStorage.setItem(r.fixturePuzzle, e);
|
|
474
474
|
}
|
|
475
|
-
function
|
|
475
|
+
function O() {
|
|
476
476
|
localStorage.removeItem(r.fixturePuzzle);
|
|
477
477
|
}
|
|
478
|
-
function
|
|
478
|
+
function k(e) {
|
|
479
479
|
e ? localStorage.setItem(r.renderHost, e) : localStorage.removeItem(r.renderHost);
|
|
480
480
|
}
|
|
481
|
-
function
|
|
481
|
+
function A(e) {
|
|
482
482
|
localStorage.setItem(r.previewKind, e);
|
|
483
483
|
}
|
|
484
|
-
function
|
|
484
|
+
function j(e) {
|
|
485
485
|
e ? localStorage.setItem(r.renderContext, e) : localStorage.removeItem(r.renderContext);
|
|
486
486
|
}
|
|
487
|
-
function
|
|
487
|
+
function ne(e) {
|
|
488
488
|
let t = [];
|
|
489
489
|
return {
|
|
490
490
|
log(n, r, i) {
|
|
@@ -509,13 +509,13 @@ function re(e) {
|
|
|
509
509
|
}
|
|
510
510
|
};
|
|
511
511
|
}
|
|
512
|
-
function
|
|
512
|
+
function re(e, t, n) {
|
|
513
513
|
console.log("Simulator sending:", e, t), n == null || n.log(e, t, "out"), window.postMessage({
|
|
514
514
|
type: e,
|
|
515
515
|
data: t
|
|
516
516
|
}, "*");
|
|
517
517
|
}
|
|
518
|
-
function
|
|
518
|
+
function ie(e, t) {
|
|
519
519
|
let n = (n) => {
|
|
520
520
|
var r, i, a;
|
|
521
521
|
if (!(!(n == null || (r = n.data) == null) && r.type)) return;
|
|
@@ -525,7 +525,7 @@ function ae(e, t) {
|
|
|
525
525
|
return window.addEventListener("message", n), () => window.removeEventListener("message", n);
|
|
526
526
|
}
|
|
527
527
|
/** Parse fixture imports into a structured format: { category: { filename: data } } */
|
|
528
|
-
function
|
|
528
|
+
function ae(e) {
|
|
529
529
|
let t = /* @__PURE__ */ new Map();
|
|
530
530
|
console.log("Simulator: Parsing fixtures", Object.keys(e));
|
|
531
531
|
for (let [o, s] of Object.entries(e)) {
|
|
@@ -544,7 +544,7 @@ function oe(e) {
|
|
|
544
544
|
}), t;
|
|
545
545
|
}
|
|
546
546
|
/** Render fixture selector HTML */
|
|
547
|
-
function
|
|
547
|
+
function M(e, t) {
|
|
548
548
|
return e.length === 0 ? "" : `
|
|
549
549
|
<div class="simulator-fixtures">
|
|
550
550
|
<div class="simulator-field">
|
|
@@ -561,7 +561,7 @@ function j(e, t) {
|
|
|
561
561
|
`;
|
|
562
562
|
}
|
|
563
563
|
/** Update puzzle select options based on selected category */
|
|
564
|
-
function
|
|
564
|
+
function N(e, t, n, r) {
|
|
565
565
|
let i = t.get(n);
|
|
566
566
|
if (!i) return null;
|
|
567
567
|
let a = Array.from(i.keys()), o = r;
|
|
@@ -572,7 +572,7 @@ function M(e, t, n, r) {
|
|
|
572
572
|
return e.innerHTML = a.map((e) => `<option value="${e}" ${e === o ? "selected" : ""}>${e}</option>`).join(""), o;
|
|
573
573
|
}
|
|
574
574
|
/** Get puzzle data from fixtures */
|
|
575
|
-
function
|
|
575
|
+
function P(e, t, n) {
|
|
576
576
|
var r, i;
|
|
577
577
|
return !t || !n || (r = (i = e.get(t)) == null ? void 0 : i.get(n)) == null ? null : r;
|
|
578
578
|
}
|
|
@@ -584,8 +584,8 @@ function N(e, t, n) {
|
|
|
584
584
|
* `puzzmo games validate` greps build output for it — keep it in sync with the copy in
|
|
585
585
|
* packages/cli/src/util/lintDist.ts.
|
|
586
586
|
*/
|
|
587
|
-
const
|
|
588
|
-
function
|
|
587
|
+
const oe = "puzzmo-simulator-dev-only-do-not-ship";
|
|
588
|
+
function se() {
|
|
589
589
|
return {
|
|
590
590
|
id: "ctrl",
|
|
591
591
|
label: "Ctrl",
|
|
@@ -600,19 +600,19 @@ function ce() {
|
|
|
600
600
|
selectedCategory: e.state.selectedCategory,
|
|
601
601
|
selectedPuzzle: e.state.selectedPuzzle
|
|
602
602
|
}), e.fixtures && e.fixtureCategories.length > 0 && i) {
|
|
603
|
-
i.innerHTML =
|
|
603
|
+
i.innerHTML = M(e.fixtureCategories, e.state.selectedCategory);
|
|
604
604
|
let t = e.getElement("#simulator-fixture-category"), n = e.getElement("#simulator-fixture-puzzle");
|
|
605
605
|
if (t && n && e.state.selectedCategory) {
|
|
606
|
-
e.state.selectedPuzzle =
|
|
607
|
-
let r =
|
|
606
|
+
e.state.selectedPuzzle = N(n, e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
|
|
607
|
+
let r = P(e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
|
|
608
608
|
console.log("Simulator: Loading fixture puzzle", {
|
|
609
609
|
category: e.state.selectedCategory,
|
|
610
610
|
puzzle: e.state.selectedPuzzle,
|
|
611
611
|
hasPuzzleData: !!r
|
|
612
|
-
}), r && (e.state.appliedPuzzleOverride === null && (e.state.puzzleData = r, e.state.originalPuzzle = r), e.state.selectedCategory &&
|
|
613
|
-
console.log("Simulator: Category changed, reloading...", t.value), l(),
|
|
612
|
+
}), r && (e.state.appliedPuzzleOverride === null && (e.state.puzzleData = r, e.state.originalPuzzle = r), e.state.selectedCategory && E(e.state.selectedCategory), e.state.selectedPuzzle && D(e.state.selectedPuzzle)), t.addEventListener("change", () => {
|
|
613
|
+
console.log("Simulator: Category changed, reloading...", t.value), l(), E(t.value), O(), window.location.reload();
|
|
614
614
|
}), n.addEventListener("change", () => {
|
|
615
|
-
console.log("Simulator: Puzzle changed, reloading...", n.value), l(),
|
|
615
|
+
console.log("Simulator: Puzzle changed, reloading...", n.value), l(), D(n.value), window.location.reload();
|
|
616
616
|
});
|
|
617
617
|
}
|
|
618
618
|
}
|
|
@@ -638,10 +638,10 @@ function ce() {
|
|
|
638
638
|
* Inlined here (rather than shared with the rest of the monorepo) because the SDK ships to OSS and
|
|
639
639
|
* must stay self-contained.
|
|
640
640
|
*/
|
|
641
|
-
function
|
|
641
|
+
function F(e) {
|
|
642
642
|
var t;
|
|
643
643
|
if (typeof e != "string") return e;
|
|
644
|
-
let n = (t =
|
|
644
|
+
let n = (t = I(e)) == null ? {
|
|
645
645
|
width: 800,
|
|
646
646
|
height: 800
|
|
647
647
|
} : t;
|
|
@@ -652,7 +652,7 @@ function P(e) {
|
|
|
652
652
|
};
|
|
653
653
|
}
|
|
654
654
|
/** Reads an SVG's intrinsic size from its `viewBox` (preferred) or its `width`/`height` attributes. */
|
|
655
|
-
function
|
|
655
|
+
function I(e) {
|
|
656
656
|
var t, n, r, i;
|
|
657
657
|
let a = e.indexOf("<svg");
|
|
658
658
|
if (a === -1) return;
|
|
@@ -670,9 +670,9 @@ function F(e) {
|
|
|
670
670
|
height: u
|
|
671
671
|
};
|
|
672
672
|
}
|
|
673
|
-
var
|
|
673
|
+
var L = "simulator-saved-states";
|
|
674
674
|
/** Find thumbnail function on globalThis (looks for functions ending in "Thumbnail") */
|
|
675
|
-
function
|
|
675
|
+
function R() {
|
|
676
676
|
let e = globalThis;
|
|
677
677
|
for (let t of Object.keys(e)) if (t.endsWith("Thumbnail") && typeof e[t] == "function") return {
|
|
678
678
|
name: t,
|
|
@@ -681,8 +681,8 @@ function L() {
|
|
|
681
681
|
return null;
|
|
682
682
|
}
|
|
683
683
|
/** Generate a small thumbnail SVG for a given input string */
|
|
684
|
-
function
|
|
685
|
-
let n =
|
|
684
|
+
function ce(e, t) {
|
|
685
|
+
let n = R();
|
|
686
686
|
if (!n) return "";
|
|
687
687
|
try {
|
|
688
688
|
var r;
|
|
@@ -692,7 +692,7 @@ function R(e, t) {
|
|
|
692
692
|
strict: !0,
|
|
693
693
|
renderHost: "game"
|
|
694
694
|
};
|
|
695
|
-
return
|
|
695
|
+
return F(n.fn(i, t, a)).svg;
|
|
696
696
|
} catch (e) {
|
|
697
697
|
return "";
|
|
698
698
|
}
|
|
@@ -778,7 +778,7 @@ function le() {
|
|
|
778
778
|
inputStr: n.state.currentInputStr,
|
|
779
779
|
timestamp: Date.now()
|
|
780
780
|
};
|
|
781
|
-
e.push(t), localStorage.setItem(
|
|
781
|
+
e.push(t), localStorage.setItem(L, JSON.stringify(e)), p.value = "", U(n);
|
|
782
782
|
}), U(n);
|
|
783
783
|
},
|
|
784
784
|
onActivate(n) {
|
|
@@ -803,7 +803,7 @@ function le() {
|
|
|
803
803
|
}
|
|
804
804
|
function V() {
|
|
805
805
|
try {
|
|
806
|
-
let e = localStorage.getItem(
|
|
806
|
+
let e = localStorage.getItem(L);
|
|
807
807
|
return e ? JSON.parse(e) : [];
|
|
808
808
|
} catch (e) {
|
|
809
809
|
return [];
|
|
@@ -820,7 +820,7 @@ function H(e) {
|
|
|
820
820
|
let r = z.length - 1 - n, i = new Date(t.timestamp).toLocaleTimeString(), a = t.value.length > 60 ? t.value.slice(0, 60) + "..." : t.value;
|
|
821
821
|
return `
|
|
822
822
|
<div class="history-item" data-history-idx="${r}">
|
|
823
|
-
<div class="history-item-thumb">${
|
|
823
|
+
<div class="history-item-thumb">${ce(e, t.value)}</div>
|
|
824
824
|
<div class="history-item-content">
|
|
825
825
|
<div class="history-item-header">
|
|
826
826
|
<span class="history-item-num">#${r + 1}</span>
|
|
@@ -880,7 +880,7 @@ function U(e) {
|
|
|
880
880
|
}), t.querySelectorAll(".save-delete-btn").forEach((t) => {
|
|
881
881
|
t.addEventListener("click", (t) => {
|
|
882
882
|
let r = parseInt(t.target.getAttribute("data-save-idx") || "0"), i = n.filter((e, t) => t !== r);
|
|
883
|
-
localStorage.setItem(
|
|
883
|
+
localStorage.setItem(L, JSON.stringify(i)), U(e);
|
|
884
884
|
});
|
|
885
885
|
});
|
|
886
886
|
}
|
|
@@ -1071,12 +1071,12 @@ function Ce() {
|
|
|
1071
1071
|
o == null || o.querySelectorAll(".simulator-segmented-btn").forEach((t) => {
|
|
1072
1072
|
t.addEventListener("click", () => {
|
|
1073
1073
|
let n = t.dataset.previewKind;
|
|
1074
|
-
!n || n === e.state.previewKind || (e.state.previewKind = n,
|
|
1074
|
+
!n || n === e.state.previewKind || (e.state.previewKind = n, A(n), c(), s(), e.updateThumbnail());
|
|
1075
1075
|
});
|
|
1076
|
-
}), n && (e.state.renderHost || (e.state.renderHost = "game",
|
|
1077
|
-
e.state.renderHost = n.value,
|
|
1078
|
-
})), r && (e.state.renderContext || (e.state.renderContext = "preview",
|
|
1079
|
-
e.state.renderContext = r.value,
|
|
1076
|
+
}), n && (e.state.renderHost || (e.state.renderHost = "game", k(e.state.renderHost)), n.value = e.state.renderHost || "game", n.addEventListener("change", () => {
|
|
1077
|
+
e.state.renderHost = n.value, k(e.state.renderHost), s(), e.updateThumbnail();
|
|
1078
|
+
})), r && (e.state.renderContext || (e.state.renderContext = "preview", j(e.state.renderContext)), r.value = e.state.renderContext || "preview", r.addEventListener("change", () => {
|
|
1079
|
+
e.state.renderContext = r.value, j(e.state.renderContext), e.updateThumbnail();
|
|
1080
1080
|
})), c(), s();
|
|
1081
1081
|
},
|
|
1082
1082
|
onActivate(e) {
|
|
@@ -1118,7 +1118,7 @@ function Ce() {
|
|
|
1118
1118
|
strict: !0,
|
|
1119
1119
|
renderHost: e.state.renderHost,
|
|
1120
1120
|
renderContext: e.state.renderContext
|
|
1121
|
-
}, { svg: i } =
|
|
1121
|
+
}, { svg: i } = F(s.fn(n, e.state.currentInputStr, r));
|
|
1122
1122
|
t && (t.innerHTML = i);
|
|
1123
1123
|
} catch (e) {
|
|
1124
1124
|
console.error("Simulator: Thumbnail error", e), t && (t.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
|
|
@@ -1154,7 +1154,7 @@ function Te() {
|
|
|
1154
1154
|
<div class="simulator-theme-name">${n.name}</div>
|
|
1155
1155
|
<div class="simulator-theme-type">${n.type}</div>
|
|
1156
1156
|
`, r.addEventListener("click", () => {
|
|
1157
|
-
console.log("Simulator: Theme changed, reloading...", n.name),
|
|
1157
|
+
console.log("Simulator: Theme changed, reloading...", n.name), T(n.name), window.location.reload();
|
|
1158
1158
|
}), t.appendChild(r);
|
|
1159
1159
|
});
|
|
1160
1160
|
}
|
|
@@ -1817,17 +1817,17 @@ function bt(e) {
|
|
|
1817
1817
|
].join(";"), a.innerHTML = d(i), a.addEventListener("pointerdown", x), a.addEventListener("pointermove", ee), a.addEventListener("pointerup", S), a.addEventListener("pointercancel", () => y()), a.addEventListener("contextmenu", (e) => e.preventDefault()), document.body.appendChild(a), o.isConnected || document.head.appendChild(o), document.documentElement.classList.add("sim-kbd-docked"), l());
|
|
1818
1818
|
}, te = () => {
|
|
1819
1819
|
a && (a.remove(), a = null, document.documentElement.classList.remove("sim-kbd-docked"), c == null || c(), y());
|
|
1820
|
-
},
|
|
1820
|
+
}, w = () => {
|
|
1821
1821
|
if (!r || !i) return te();
|
|
1822
1822
|
if (!a) return C();
|
|
1823
1823
|
a.innerHTML = d(i), v(f);
|
|
1824
1824
|
};
|
|
1825
1825
|
return {
|
|
1826
1826
|
setEnabled(e) {
|
|
1827
|
-
r = e,
|
|
1827
|
+
r = e, w();
|
|
1828
1828
|
},
|
|
1829
1829
|
setConfig(e) {
|
|
1830
|
-
i = e,
|
|
1830
|
+
i = e, w();
|
|
1831
1831
|
}
|
|
1832
1832
|
};
|
|
1833
1833
|
}
|
|
@@ -2030,13 +2030,86 @@ function Dt(e) {
|
|
|
2030
2030
|
function Q(e) {
|
|
2031
2031
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
2032
2032
|
}
|
|
2033
|
+
/**
|
|
2034
|
+
* Sound tab — the host side of a game's audio. Games play their own sounds, so this is about the
|
|
2035
|
+
* parts the host owns: the sound-enabled gate (games boot muted, so this is what lets you hear
|
|
2036
|
+
* anything) and a log of the cues the game asked us for, with any haptic it wanted.
|
|
2037
|
+
*/
|
|
2038
|
+
function Ot() {
|
|
2039
|
+
let e = [], t = !0, n = () => e.length === 0 ? "<div class=\"sound-empty\">No sensory events yet. Play the game to hear from it.</div>" : e.map((e) => `<div class="sound-row"><span class="sound-id">${At(e.id)}</span>${e.haptic ? `<span class="sound-haptic">${At(e.haptic)}</span>` : ""}<span class="sound-time">${e.time}</span></div>`).join(""), r = (t) => {
|
|
2040
|
+
let r = t.getElement("#sound-events");
|
|
2041
|
+
r && (r.innerHTML = n()), t.updateBadge("sound", e.length);
|
|
2042
|
+
};
|
|
2043
|
+
return {
|
|
2044
|
+
id: "sound",
|
|
2045
|
+
label: "Sound",
|
|
2046
|
+
render() {
|
|
2047
|
+
return `
|
|
2048
|
+
<style>
|
|
2049
|
+
#simulator-tab-sound .sound-row { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; font-family: monospace; font-size: 11px; }
|
|
2050
|
+
#simulator-tab-sound .sound-id { color: var(--accent, #6cf); }
|
|
2051
|
+
#simulator-tab-sound .sound-haptic { opacity: 0.7; }
|
|
2052
|
+
#simulator-tab-sound .sound-time { opacity: 0.5; }
|
|
2053
|
+
#simulator-tab-sound .sound-empty { opacity: 0.5; font-size: 11px; padding: 4px 0; }
|
|
2054
|
+
#simulator-tab-sound .sound-controls { margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
|
|
2055
|
+
#simulator-tab-sound .sound-toggle { font-size: 11px; display: flex; align-items: center; gap: 4px; }
|
|
2056
|
+
</style>
|
|
2057
|
+
<div class="simulator-section">
|
|
2058
|
+
<div class="simulator-section-title">Sensory Events</div>
|
|
2059
|
+
<div class="sound-controls">
|
|
2060
|
+
<label class="sound-toggle"><input type="checkbox" id="sound-enabled" ${t ? "checked" : ""} /> Sound enabled</label>
|
|
2061
|
+
<button class="simulator-btn" id="sound-clear">Clear</button>
|
|
2062
|
+
</div>
|
|
2063
|
+
<div id="sound-events">${n()}</div>
|
|
2064
|
+
</div>
|
|
2065
|
+
`;
|
|
2066
|
+
},
|
|
2067
|
+
bind(n) {
|
|
2068
|
+
let i = n.getElement("#sound-clear");
|
|
2069
|
+
i == null || i.addEventListener("click", () => {
|
|
2070
|
+
e.length = 0, r(n);
|
|
2071
|
+
});
|
|
2072
|
+
let a = n.getElement("#sound-enabled");
|
|
2073
|
+
a == null || a.addEventListener("change", () => {
|
|
2074
|
+
t = !!a.checked, n.sendToGame("SOUND_ENABLED", { enabled: t });
|
|
2075
|
+
}), n.sendToGame("SOUND_ENABLED", { enabled: t });
|
|
2076
|
+
},
|
|
2077
|
+
onMessage(n, i, a) {
|
|
2078
|
+
var o;
|
|
2079
|
+
if (n === "READY_GAME_LOADED") {
|
|
2080
|
+
a.sendToGame("SOUND_ENABLED", { enabled: t });
|
|
2081
|
+
return;
|
|
2082
|
+
}
|
|
2083
|
+
if (n !== "SENSORY_EVENT") return;
|
|
2084
|
+
let s = typeof i == "string" ? i : (o = i == null ? void 0 : i.id) == null ? JSON.stringify(i) : o;
|
|
2085
|
+
e.unshift({
|
|
2086
|
+
id: s,
|
|
2087
|
+
haptic: typeof i == "string" || i == null ? void 0 : i.haptic,
|
|
2088
|
+
time: kt()
|
|
2089
|
+
}), e.length > 100 && e.pop(), r(a);
|
|
2090
|
+
}
|
|
2091
|
+
};
|
|
2092
|
+
}
|
|
2093
|
+
/** Current wall-clock time as HH:MM:SS, matching the simulator's message log formatting. */
|
|
2094
|
+
function kt() {
|
|
2095
|
+
return (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
|
|
2096
|
+
hour12: !1,
|
|
2097
|
+
hour: "2-digit",
|
|
2098
|
+
minute: "2-digit",
|
|
2099
|
+
second: "2-digit"
|
|
2100
|
+
});
|
|
2101
|
+
}
|
|
2102
|
+
/** Minimal HTML-escape so event ids can't break the simulator markup. */
|
|
2103
|
+
function At(e) {
|
|
2104
|
+
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
2105
|
+
}
|
|
2033
2106
|
var $ = null;
|
|
2034
2107
|
/** True when the game is embedded in the real Puzzmo app, which sets `?developer=true` on the iframe. */
|
|
2035
|
-
function
|
|
2108
|
+
function jt() {
|
|
2036
2109
|
return typeof window > "u" ? !1 : new URLSearchParams(window.location.search).has("developer");
|
|
2037
2110
|
}
|
|
2038
2111
|
/** Inert instance returned when the simulator declines to boot (the app is the host). */
|
|
2039
|
-
var
|
|
2112
|
+
var Mt = {
|
|
2040
2113
|
updateFixtures: () => {},
|
|
2041
2114
|
sendToGame: () => {},
|
|
2042
2115
|
loadPuzzle: function() {
|
|
@@ -2085,15 +2158,15 @@ var kt = {
|
|
|
2085
2158
|
* Fixtures are loaded as raw strings and passed to the game verbatim (any text format works; the game parses it).
|
|
2086
2159
|
* This will show dropdowns in the Ctrl tab to select category and puzzle.
|
|
2087
2160
|
*/
|
|
2088
|
-
function
|
|
2161
|
+
function Nt(e = {}) {
|
|
2089
2162
|
var n, r, i;
|
|
2090
|
-
if (
|
|
2163
|
+
if (jt()) return console.log("[Simulator] developer=true in URL — running inside the Puzzmo app, skipping simulator boot"), Mt;
|
|
2091
2164
|
if (console.log("[Simulator] createSimulator called with config:", {
|
|
2092
2165
|
slug: e.slug,
|
|
2093
2166
|
hasFixtures: !!e.fixtures
|
|
2094
2167
|
}), $) return e.fixtures && (console.log("[Simulator] Instance already exists, updating fixtures"), $.updateFixtures(e.fixtures)), $;
|
|
2095
|
-
let a = (n = e.autoStart) == null ? !0 : n, o = e.fixtures ?
|
|
2096
|
-
|
|
2168
|
+
let a = (n = e.autoStart) == null ? !0 : n, o = e.fixtures ? ae(e.fixtures) : null, s = o ? Array.from(o.keys()).sort() : [], c = me(), l = Ce(), u = [
|
|
2169
|
+
se(),
|
|
2097
2170
|
le(),
|
|
2098
2171
|
c,
|
|
2099
2172
|
he(),
|
|
@@ -2105,6 +2178,7 @@ function At(e = {}) {
|
|
|
2105
2178
|
dt(),
|
|
2106
2179
|
Ct(),
|
|
2107
2180
|
Tt(),
|
|
2181
|
+
Ot(),
|
|
2108
2182
|
...(r = e.views) == null ? [] : r
|
|
2109
2183
|
], d = u.map((e) => e.id), f = ee(e, s, d), p = {
|
|
2110
2184
|
pause: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><rect x=\"1\" y=\"1\" width=\"3\" height=\"8\"/><rect x=\"6\" y=\"1\" width=\"3\" height=\"8\"/></svg>",
|
|
@@ -2114,7 +2188,7 @@ function At(e = {}) {
|
|
|
2114
2188
|
minimize: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><rect x=\"1\" y=\"4\" width=\"8\" height=\"2\"/></svg>",
|
|
2115
2189
|
expand: "<svg width=\"8\" height=\"8\" viewBox=\"0 0 8 8\" fill=\"currentColor\"><polygon points=\"1,1 7,4 1,7\"/></svg>"
|
|
2116
2190
|
}, m = document.createElement("div");
|
|
2117
|
-
m.id = "simulator", m.dataset.puzzmoBuild =
|
|
2191
|
+
m.id = "simulator", m.dataset.puzzmoBuild = oe, m.innerHTML = `
|
|
2118
2192
|
<style>
|
|
2119
2193
|
:root {
|
|
2120
2194
|
--sim-bg: #1a1a2e;
|
|
@@ -3461,27 +3535,27 @@ function At(e = {}) {
|
|
|
3461
3535
|
</div>
|
|
3462
3536
|
</div>
|
|
3463
3537
|
`, document.body.appendChild(m);
|
|
3464
|
-
let h = m.querySelector("#simulator-panel"), g = m.querySelector("#simulator-header"), _ = m.querySelector("#simulator-header-indicator"), v = m.querySelector("#simulator-header-status-text"), y = m.querySelector("#simulator-header-pause"), b = m.querySelector("#simulator-header-retry"), x = m.querySelector("#simulator-header-settings"), S = m.querySelector("#simulator-toggle"), C = m.querySelector("#simulator-timer"),
|
|
3538
|
+
let h = m.querySelector("#simulator-panel"), g = m.querySelector("#simulator-header"), _ = m.querySelector("#simulator-header-indicator"), v = m.querySelector("#simulator-header-status-text"), y = m.querySelector("#simulator-header-pause"), b = m.querySelector("#simulator-header-retry"), x = m.querySelector("#simulator-header-settings"), S = m.querySelector("#simulator-toggle"), C = m.querySelector("#simulator-timer"), T = m.querySelector("#simulator-tabs"), E = m.querySelector("#simulator-content"), D = (e) => m.querySelector(e), O = (e) => {
|
|
3465
3539
|
y.innerHTML = e ? p.play : p.pause, y.title = e ? "Resume" : "Pause";
|
|
3466
|
-
}, O = (e, t) => {
|
|
3467
|
-
let n = E("#simulator-status .text"), r = E("#simulator-status .indicator"), i = t === "complete" ? "✓" : "";
|
|
3468
|
-
n && (n.textContent = e), r && (r.className = `indicator ${t}`, r.textContent = i), _.className = t, _.textContent = i, v.textContent = e;
|
|
3469
3540
|
}, k = (e, t) => {
|
|
3541
|
+
let n = D("#simulator-status .text"), r = D("#simulator-status .indicator"), i = t === "complete" ? "✓" : "";
|
|
3542
|
+
n && (n.textContent = e), r && (r.className = `indicator ${t}`, r.textContent = i), _.className = t, _.textContent = i, v.textContent = e;
|
|
3543
|
+
}, A = (e, t) => {
|
|
3470
3544
|
t && t !== "0" ? C.innerHTML = `${e}<span class="penalty">+${t}</span>` : C.textContent = e;
|
|
3471
|
-
},
|
|
3545
|
+
}, j = (e) => {
|
|
3472
3546
|
var t;
|
|
3473
|
-
f.activeTab = e,
|
|
3547
|
+
f.activeTab = e, E.classList.remove("hidden"), w(e), T.querySelectorAll(".simulator-tab").forEach((t) => {
|
|
3474
3548
|
t.classList.toggle("active", t.getAttribute("data-tab") === e);
|
|
3475
3549
|
}), m.querySelectorAll(".simulator-tab-content").forEach((t) => {
|
|
3476
3550
|
t.classList.toggle("active", t.id === `simulator-tab-${e}`);
|
|
3477
3551
|
}), x.classList.toggle("active", e === "auth");
|
|
3478
3552
|
let n = u.find((t) => t.id === e);
|
|
3479
|
-
n == null || (t = n.onActivate) == null || t.call(n,
|
|
3480
|
-
},
|
|
3481
|
-
f.isCollapsed = e, h.classList.toggle("collapsed", e), te(e), e ? (
|
|
3482
|
-
},
|
|
3483
|
-
l.updatePreview(
|
|
3484
|
-
},
|
|
3553
|
+
n == null || (t = n.onActivate) == null || t.call(n, R);
|
|
3554
|
+
}, M = (e) => {
|
|
3555
|
+
f.isCollapsed = e, h.classList.toggle("collapsed", e), te(e), e ? (E.classList.add("hidden"), T.querySelectorAll(".simulator-tab").forEach((e) => e.classList.remove("active"))) : j(f.activeTab);
|
|
3556
|
+
}, N = () => {
|
|
3557
|
+
l.updatePreview(R);
|
|
3558
|
+
}, P = function() {
|
|
3485
3559
|
var e = t(function* () {
|
|
3486
3560
|
var e, t;
|
|
3487
3561
|
if (f.appliedPuzzleOverride !== null) return f.appliedPuzzleOverride;
|
|
@@ -3495,57 +3569,57 @@ function At(e = {}) {
|
|
|
3495
3569
|
category: n,
|
|
3496
3570
|
puzzle: i
|
|
3497
3571
|
}), f.originalPuzzle = a;
|
|
3498
|
-
let c =
|
|
3499
|
-
return c && (c.value = f.originalPuzzle), f.activeTab === "thumb" &&
|
|
3572
|
+
let c = D("#simulator-puzzle");
|
|
3573
|
+
return c && (c.value = f.originalPuzzle), f.activeTab === "thumb" && N(), f.puzzleData;
|
|
3500
3574
|
});
|
|
3501
3575
|
return function() {
|
|
3502
3576
|
return e.apply(this, arguments);
|
|
3503
3577
|
};
|
|
3504
|
-
}(),
|
|
3505
|
-
c.addLogEntry(e,
|
|
3506
|
-
}),
|
|
3507
|
-
|
|
3508
|
-
},
|
|
3578
|
+
}(), F = ne((e) => {
|
|
3579
|
+
c.addLogEntry(e, R);
|
|
3580
|
+
}), I = (e, t) => {
|
|
3581
|
+
re(e, t, F);
|
|
3582
|
+
}, L = (e, t) => {
|
|
3509
3583
|
let n = m.querySelector(`[data-badge="${e}"]`);
|
|
3510
3584
|
n && (n.textContent = t && t > 0 ? String(t) : "");
|
|
3511
|
-
},
|
|
3585
|
+
}, R = {
|
|
3512
3586
|
state: f,
|
|
3513
|
-
getElement:
|
|
3514
|
-
sendToGame:
|
|
3515
|
-
logMessage:
|
|
3516
|
-
loadPuzzle:
|
|
3517
|
-
updateStatus:
|
|
3518
|
-
updateTimer:
|
|
3519
|
-
setCollapsed:
|
|
3520
|
-
switchTab:
|
|
3521
|
-
updateThumbnail:
|
|
3522
|
-
updateBadge:
|
|
3587
|
+
getElement: D,
|
|
3588
|
+
sendToGame: I,
|
|
3589
|
+
logMessage: F.log,
|
|
3590
|
+
loadPuzzle: P,
|
|
3591
|
+
updateStatus: k,
|
|
3592
|
+
updateTimer: A,
|
|
3593
|
+
setCollapsed: M,
|
|
3594
|
+
switchTab: j,
|
|
3595
|
+
updateThumbnail: N,
|
|
3596
|
+
updateBadge: L,
|
|
3523
3597
|
fixtures: o,
|
|
3524
3598
|
fixtureCategories: s,
|
|
3525
3599
|
gameSlug: (i = e.slug) == null ? null : i
|
|
3526
3600
|
};
|
|
3527
|
-
console.log("[Simulator] Context created with gameSlug:",
|
|
3601
|
+
console.log("[Simulator] Context created with gameSlug:", R.gameSlug), u.forEach((e) => e.bind(R)), T.querySelectorAll(".simulator-tab").forEach((e) => {
|
|
3528
3602
|
e.addEventListener("click", () => {
|
|
3529
3603
|
let t = e.getAttribute("data-tab");
|
|
3530
|
-
|
|
3604
|
+
j(t), L(t, 0);
|
|
3531
3605
|
});
|
|
3532
3606
|
}), S.addEventListener("click", (e) => {
|
|
3533
|
-
e.stopPropagation(),
|
|
3607
|
+
e.stopPropagation(), M(!0);
|
|
3534
3608
|
}), y.addEventListener("click", (e) => {
|
|
3535
|
-
e.stopPropagation(), f.isPaused ? (
|
|
3536
|
-
let t =
|
|
3609
|
+
e.stopPropagation(), f.isPaused ? (I("RESUME_GAME", {}), f.isPaused = !1, O(!1), k("Running", "ready")) : (I("PAUSE_GAME", {}), f.isPaused = !0, O(!0), k("Paused", "paused"));
|
|
3610
|
+
let t = D("#simulator-pause");
|
|
3537
3611
|
t && (t.textContent = f.isPaused ? "Resume" : "Pause");
|
|
3538
3612
|
}), b.addEventListener("click", (e) => {
|
|
3539
|
-
e.stopPropagation(),
|
|
3540
|
-
let t =
|
|
3613
|
+
e.stopPropagation(), I("RETRY_PUZZLE", {}), f.hasStarted = !1, f.isPaused = !1, O(!1), y.disabled = !0, k("Ready to retry", "ready");
|
|
3614
|
+
let t = D("#simulator-pause"), n = D("#simulator-start");
|
|
3541
3615
|
t && (t.disabled = !0, t.textContent = "Pause"), n && (n.textContent = "Start");
|
|
3542
3616
|
}), x.addEventListener("click", (e) => {
|
|
3543
|
-
e.stopPropagation(), f.isCollapsed &&
|
|
3617
|
+
e.stopPropagation(), f.isCollapsed && M(!1), j("auth");
|
|
3544
3618
|
}), g.addEventListener("click", (e) => {
|
|
3545
|
-
f.isCollapsed && e.target !== S &&
|
|
3546
|
-
}), f.isCollapsed ||
|
|
3547
|
-
let
|
|
3548
|
-
(
|
|
3619
|
+
f.isCollapsed && e.target !== S && M(!1);
|
|
3620
|
+
}), f.isCollapsed || j(f.activeTab);
|
|
3621
|
+
let ce = new URLSearchParams(window.location.search);
|
|
3622
|
+
(ce.has("code") || ce.has("error")) && (M(!1), j("auth"));
|
|
3549
3623
|
let z = (e) => ({
|
|
3550
3624
|
userState: {
|
|
3551
3625
|
gameSettings: { "proto-game": f.gameSettings },
|
|
@@ -3589,12 +3663,12 @@ function At(e = {}) {
|
|
|
3589
3663
|
appRuntimeContract: "1.0"
|
|
3590
3664
|
}), B = function() {
|
|
3591
3665
|
var e = t(function* () {
|
|
3592
|
-
|
|
3666
|
+
k("Loading puzzle...", "waiting");
|
|
3593
3667
|
try {
|
|
3594
|
-
let e = z(yield
|
|
3595
|
-
|
|
3668
|
+
let e = z(yield P());
|
|
3669
|
+
k("Sending READY_DATA...", "waiting"), I("READY_DATA", e), k("Waiting for game to load...", "waiting");
|
|
3596
3670
|
} catch (e) {
|
|
3597
|
-
|
|
3671
|
+
k(`Error: ${e}`, "paused");
|
|
3598
3672
|
}
|
|
3599
3673
|
});
|
|
3600
3674
|
return function() {
|
|
@@ -3603,13 +3677,13 @@ function At(e = {}) {
|
|
|
3603
3677
|
}(), V = () => {
|
|
3604
3678
|
console.log("Simulator: Game loaded, ready to start"), b.disabled = !1, u.forEach((e) => {
|
|
3605
3679
|
var t;
|
|
3606
|
-
return (t = e.onMessage) == null ? void 0 : t.call(e, "READY_GAME_LOADED", void 0,
|
|
3680
|
+
return (t = e.onMessage) == null ? void 0 : t.call(e, "READY_GAME_LOADED", void 0, R);
|
|
3607
3681
|
}), a && !f.hasStarted && setTimeout(() => {
|
|
3608
|
-
let e =
|
|
3609
|
-
e == null || e.click(), y.disabled = !1, f.hasStarted = !0,
|
|
3682
|
+
let e = D("#simulator-start");
|
|
3683
|
+
e == null || e.click(), y.disabled = !1, f.hasStarted = !0, k("Running", "ready");
|
|
3610
3684
|
}, 100);
|
|
3611
3685
|
};
|
|
3612
|
-
return
|
|
3686
|
+
return ie((e, t) => {
|
|
3613
3687
|
var n, r;
|
|
3614
3688
|
if (e === "READY") {
|
|
3615
3689
|
console.log("Simulator: Received READY from game"), B();
|
|
@@ -3622,7 +3696,7 @@ function At(e = {}) {
|
|
|
3622
3696
|
if (e === "TIMER_TICK") {
|
|
3623
3697
|
if (t != null && t.display) {
|
|
3624
3698
|
let [e, n] = t.display;
|
|
3625
|
-
|
|
3699
|
+
A(e, n);
|
|
3626
3700
|
}
|
|
3627
3701
|
return;
|
|
3628
3702
|
}
|
|
@@ -3633,28 +3707,28 @@ function At(e = {}) {
|
|
|
3633
3707
|
}
|
|
3634
3708
|
u.forEach((n) => {
|
|
3635
3709
|
var r;
|
|
3636
|
-
return (r = n.onMessage) == null ? void 0 : r.call(n, e, t,
|
|
3710
|
+
return (r = n.onMessage) == null ? void 0 : r.call(n, e, t, R);
|
|
3637
3711
|
});
|
|
3638
3712
|
let i = (n = t == null || (r = t.input) == null ? void 0 : r.boardState) == null ? t == null ? void 0 : t.boardState : n;
|
|
3639
|
-
e === "UPLOAD_NEW_GAME_STATE" && i && (f.currentInputStr = i, f.activeTab === "thumb" &&
|
|
3640
|
-
},
|
|
3713
|
+
e === "UPLOAD_NEW_GAME_STATE" && i && (f.currentInputStr = i, f.activeTab === "thumb" && N(), console.log("Simulator: Game state uploaded", t)), e === "GAME_COMPLETED" && (console.log("Simulator: Game completed!", t), y.disabled = !0, f.hasStarted = !1, k("Completed!", "complete"));
|
|
3714
|
+
}, F), console.log("Simulator initialized"), $ = {
|
|
3641
3715
|
updateFixtures: (e) => {
|
|
3642
|
-
o =
|
|
3716
|
+
o = ae(e), s = Array.from(o.keys()).sort(), R.fixtures = o, R.fixtureCategories = s;
|
|
3643
3717
|
let t = localStorage.getItem("simulator-fixture-category");
|
|
3644
3718
|
if (!f.selectedCategory || !s.includes(f.selectedCategory)) {
|
|
3645
3719
|
var n;
|
|
3646
3720
|
f.selectedCategory = t && s.includes(t) ? t : (n = s[0]) == null ? null : n;
|
|
3647
3721
|
}
|
|
3648
3722
|
let r = u.find((e) => e.id === "ctrl");
|
|
3649
|
-
r == null || r.bind(
|
|
3723
|
+
r == null || r.bind(R), console.log("Simulator: Fixtures updated", {
|
|
3650
3724
|
categories: s,
|
|
3651
3725
|
selectedCategory: f.selectedCategory
|
|
3652
3726
|
});
|
|
3653
3727
|
},
|
|
3654
|
-
sendToGame:
|
|
3655
|
-
loadPuzzle:
|
|
3728
|
+
sendToGame: I,
|
|
3729
|
+
loadPuzzle: P
|
|
3656
3730
|
}, $;
|
|
3657
3731
|
}
|
|
3658
|
-
export {
|
|
3732
|
+
export { Ot as n, oe as r, Nt as t };
|
|
3659
3733
|
|
|
3660
|
-
//# sourceMappingURL=createSimulator-
|
|
3734
|
+
//# sourceMappingURL=createSimulator-CoVR6n2p.js.map
|