@puzzmo/sdk 1.0.54 → 1.0.56
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-bJ1qCLmt.js → createSimulator-B6T0o88B.js} +184 -112
- package/dist/createSimulator-B6T0o88B.js.map +1 -0
- package/dist/{createSimulator-CB_nIwbm.cjs → createSimulator-BqKldPIq.cjs} +30 -12
- package/dist/createSimulator-BqKldPIq.cjs.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,84 @@ 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 cues 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">Cues</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
|
+
n === "SENSORY_EVENT" && (e.unshift({
|
|
2084
|
+
id: (o = i == null ? void 0 : i.id) == null ? JSON.stringify(i) : o,
|
|
2085
|
+
haptic: i == null ? void 0 : i.haptic,
|
|
2086
|
+
time: kt()
|
|
2087
|
+
}), e.length > 100 && e.pop(), r(a));
|
|
2088
|
+
}
|
|
2089
|
+
};
|
|
2090
|
+
}
|
|
2091
|
+
/** Current wall-clock time as HH:MM:SS, matching the simulator's message log formatting. */
|
|
2092
|
+
function kt() {
|
|
2093
|
+
return (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
|
|
2094
|
+
hour12: !1,
|
|
2095
|
+
hour: "2-digit",
|
|
2096
|
+
minute: "2-digit",
|
|
2097
|
+
second: "2-digit"
|
|
2098
|
+
});
|
|
2099
|
+
}
|
|
2100
|
+
/** Minimal HTML-escape so event ids can't break the simulator markup. */
|
|
2101
|
+
function At(e) {
|
|
2102
|
+
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
2103
|
+
}
|
|
2033
2104
|
var $ = null;
|
|
2034
2105
|
/** True when the game is embedded in the real Puzzmo app, which sets `?developer=true` on the iframe. */
|
|
2035
|
-
function
|
|
2106
|
+
function jt() {
|
|
2036
2107
|
return typeof window > "u" ? !1 : new URLSearchParams(window.location.search).has("developer");
|
|
2037
2108
|
}
|
|
2038
2109
|
/** Inert instance returned when the simulator declines to boot (the app is the host). */
|
|
2039
|
-
var
|
|
2110
|
+
var Mt = {
|
|
2040
2111
|
updateFixtures: () => {},
|
|
2041
2112
|
sendToGame: () => {},
|
|
2042
2113
|
loadPuzzle: function() {
|
|
@@ -2085,15 +2156,15 @@ var kt = {
|
|
|
2085
2156
|
* Fixtures are loaded as raw strings and passed to the game verbatim (any text format works; the game parses it).
|
|
2086
2157
|
* This will show dropdowns in the Ctrl tab to select category and puzzle.
|
|
2087
2158
|
*/
|
|
2088
|
-
function
|
|
2159
|
+
function Nt(e = {}) {
|
|
2089
2160
|
var n, r, i;
|
|
2090
|
-
if (
|
|
2161
|
+
if (jt()) return console.log("[Simulator] developer=true in URL — running inside the Puzzmo app, skipping simulator boot"), Mt;
|
|
2091
2162
|
if (console.log("[Simulator] createSimulator called with config:", {
|
|
2092
2163
|
slug: e.slug,
|
|
2093
2164
|
hasFixtures: !!e.fixtures
|
|
2094
2165
|
}), $) 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
|
-
|
|
2166
|
+
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 = [
|
|
2167
|
+
se(),
|
|
2097
2168
|
le(),
|
|
2098
2169
|
c,
|
|
2099
2170
|
he(),
|
|
@@ -2105,6 +2176,7 @@ function At(e = {}) {
|
|
|
2105
2176
|
dt(),
|
|
2106
2177
|
Ct(),
|
|
2107
2178
|
Tt(),
|
|
2179
|
+
Ot(),
|
|
2108
2180
|
...(r = e.views) == null ? [] : r
|
|
2109
2181
|
], d = u.map((e) => e.id), f = ee(e, s, d), p = {
|
|
2110
2182
|
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 +2186,7 @@ function At(e = {}) {
|
|
|
2114
2186
|
minimize: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><rect x=\"1\" y=\"4\" width=\"8\" height=\"2\"/></svg>",
|
|
2115
2187
|
expand: "<svg width=\"8\" height=\"8\" viewBox=\"0 0 8 8\" fill=\"currentColor\"><polygon points=\"1,1 7,4 1,7\"/></svg>"
|
|
2116
2188
|
}, m = document.createElement("div");
|
|
2117
|
-
m.id = "simulator", m.dataset.puzzmoBuild =
|
|
2189
|
+
m.id = "simulator", m.dataset.puzzmoBuild = oe, m.innerHTML = `
|
|
2118
2190
|
<style>
|
|
2119
2191
|
:root {
|
|
2120
2192
|
--sim-bg: #1a1a2e;
|
|
@@ -3461,27 +3533,27 @@ function At(e = {}) {
|
|
|
3461
3533
|
</div>
|
|
3462
3534
|
</div>
|
|
3463
3535
|
`, 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"),
|
|
3536
|
+
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
3537
|
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
3538
|
}, k = (e, t) => {
|
|
3539
|
+
let n = D("#simulator-status .text"), r = D("#simulator-status .indicator"), i = t === "complete" ? "✓" : "";
|
|
3540
|
+
n && (n.textContent = e), r && (r.className = `indicator ${t}`, r.textContent = i), _.className = t, _.textContent = i, v.textContent = e;
|
|
3541
|
+
}, A = (e, t) => {
|
|
3470
3542
|
t && t !== "0" ? C.innerHTML = `${e}<span class="penalty">+${t}</span>` : C.textContent = e;
|
|
3471
|
-
},
|
|
3543
|
+
}, j = (e) => {
|
|
3472
3544
|
var t;
|
|
3473
|
-
f.activeTab = e,
|
|
3545
|
+
f.activeTab = e, E.classList.remove("hidden"), w(e), T.querySelectorAll(".simulator-tab").forEach((t) => {
|
|
3474
3546
|
t.classList.toggle("active", t.getAttribute("data-tab") === e);
|
|
3475
3547
|
}), m.querySelectorAll(".simulator-tab-content").forEach((t) => {
|
|
3476
3548
|
t.classList.toggle("active", t.id === `simulator-tab-${e}`);
|
|
3477
3549
|
}), x.classList.toggle("active", e === "auth");
|
|
3478
3550
|
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
|
-
},
|
|
3551
|
+
n == null || (t = n.onActivate) == null || t.call(n, R);
|
|
3552
|
+
}, M = (e) => {
|
|
3553
|
+
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);
|
|
3554
|
+
}, N = () => {
|
|
3555
|
+
l.updatePreview(R);
|
|
3556
|
+
}, P = function() {
|
|
3485
3557
|
var e = t(function* () {
|
|
3486
3558
|
var e, t;
|
|
3487
3559
|
if (f.appliedPuzzleOverride !== null) return f.appliedPuzzleOverride;
|
|
@@ -3495,57 +3567,57 @@ function At(e = {}) {
|
|
|
3495
3567
|
category: n,
|
|
3496
3568
|
puzzle: i
|
|
3497
3569
|
}), f.originalPuzzle = a;
|
|
3498
|
-
let c =
|
|
3499
|
-
return c && (c.value = f.originalPuzzle), f.activeTab === "thumb" &&
|
|
3570
|
+
let c = D("#simulator-puzzle");
|
|
3571
|
+
return c && (c.value = f.originalPuzzle), f.activeTab === "thumb" && N(), f.puzzleData;
|
|
3500
3572
|
});
|
|
3501
3573
|
return function() {
|
|
3502
3574
|
return e.apply(this, arguments);
|
|
3503
3575
|
};
|
|
3504
|
-
}(),
|
|
3505
|
-
c.addLogEntry(e,
|
|
3506
|
-
}),
|
|
3507
|
-
|
|
3508
|
-
},
|
|
3576
|
+
}(), F = ne((e) => {
|
|
3577
|
+
c.addLogEntry(e, R);
|
|
3578
|
+
}), I = (e, t) => {
|
|
3579
|
+
re(e, t, F);
|
|
3580
|
+
}, L = (e, t) => {
|
|
3509
3581
|
let n = m.querySelector(`[data-badge="${e}"]`);
|
|
3510
3582
|
n && (n.textContent = t && t > 0 ? String(t) : "");
|
|
3511
|
-
},
|
|
3583
|
+
}, R = {
|
|
3512
3584
|
state: f,
|
|
3513
|
-
getElement:
|
|
3514
|
-
sendToGame:
|
|
3515
|
-
logMessage:
|
|
3516
|
-
loadPuzzle:
|
|
3517
|
-
updateStatus:
|
|
3518
|
-
updateTimer:
|
|
3519
|
-
setCollapsed:
|
|
3520
|
-
switchTab:
|
|
3521
|
-
updateThumbnail:
|
|
3522
|
-
updateBadge:
|
|
3585
|
+
getElement: D,
|
|
3586
|
+
sendToGame: I,
|
|
3587
|
+
logMessage: F.log,
|
|
3588
|
+
loadPuzzle: P,
|
|
3589
|
+
updateStatus: k,
|
|
3590
|
+
updateTimer: A,
|
|
3591
|
+
setCollapsed: M,
|
|
3592
|
+
switchTab: j,
|
|
3593
|
+
updateThumbnail: N,
|
|
3594
|
+
updateBadge: L,
|
|
3523
3595
|
fixtures: o,
|
|
3524
3596
|
fixtureCategories: s,
|
|
3525
3597
|
gameSlug: (i = e.slug) == null ? null : i
|
|
3526
3598
|
};
|
|
3527
|
-
console.log("[Simulator] Context created with gameSlug:",
|
|
3599
|
+
console.log("[Simulator] Context created with gameSlug:", R.gameSlug), u.forEach((e) => e.bind(R)), T.querySelectorAll(".simulator-tab").forEach((e) => {
|
|
3528
3600
|
e.addEventListener("click", () => {
|
|
3529
3601
|
let t = e.getAttribute("data-tab");
|
|
3530
|
-
|
|
3602
|
+
j(t), L(t, 0);
|
|
3531
3603
|
});
|
|
3532
3604
|
}), S.addEventListener("click", (e) => {
|
|
3533
|
-
e.stopPropagation(),
|
|
3605
|
+
e.stopPropagation(), M(!0);
|
|
3534
3606
|
}), y.addEventListener("click", (e) => {
|
|
3535
|
-
e.stopPropagation(), f.isPaused ? (
|
|
3536
|
-
let t =
|
|
3607
|
+
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"));
|
|
3608
|
+
let t = D("#simulator-pause");
|
|
3537
3609
|
t && (t.textContent = f.isPaused ? "Resume" : "Pause");
|
|
3538
3610
|
}), b.addEventListener("click", (e) => {
|
|
3539
|
-
e.stopPropagation(),
|
|
3540
|
-
let t =
|
|
3611
|
+
e.stopPropagation(), I("RETRY_PUZZLE", {}), f.hasStarted = !1, f.isPaused = !1, O(!1), y.disabled = !0, k("Ready to retry", "ready");
|
|
3612
|
+
let t = D("#simulator-pause"), n = D("#simulator-start");
|
|
3541
3613
|
t && (t.disabled = !0, t.textContent = "Pause"), n && (n.textContent = "Start");
|
|
3542
3614
|
}), x.addEventListener("click", (e) => {
|
|
3543
|
-
e.stopPropagation(), f.isCollapsed &&
|
|
3615
|
+
e.stopPropagation(), f.isCollapsed && M(!1), j("auth");
|
|
3544
3616
|
}), g.addEventListener("click", (e) => {
|
|
3545
|
-
f.isCollapsed && e.target !== S &&
|
|
3546
|
-
}), f.isCollapsed ||
|
|
3547
|
-
let
|
|
3548
|
-
(
|
|
3617
|
+
f.isCollapsed && e.target !== S && M(!1);
|
|
3618
|
+
}), f.isCollapsed || j(f.activeTab);
|
|
3619
|
+
let ce = new URLSearchParams(window.location.search);
|
|
3620
|
+
(ce.has("code") || ce.has("error")) && (M(!1), j("auth"));
|
|
3549
3621
|
let z = (e) => ({
|
|
3550
3622
|
userState: {
|
|
3551
3623
|
gameSettings: { "proto-game": f.gameSettings },
|
|
@@ -3589,12 +3661,12 @@ function At(e = {}) {
|
|
|
3589
3661
|
appRuntimeContract: "1.0"
|
|
3590
3662
|
}), B = function() {
|
|
3591
3663
|
var e = t(function* () {
|
|
3592
|
-
|
|
3664
|
+
k("Loading puzzle...", "waiting");
|
|
3593
3665
|
try {
|
|
3594
|
-
let e = z(yield
|
|
3595
|
-
|
|
3666
|
+
let e = z(yield P());
|
|
3667
|
+
k("Sending READY_DATA...", "waiting"), I("READY_DATA", e), k("Waiting for game to load...", "waiting");
|
|
3596
3668
|
} catch (e) {
|
|
3597
|
-
|
|
3669
|
+
k(`Error: ${e}`, "paused");
|
|
3598
3670
|
}
|
|
3599
3671
|
});
|
|
3600
3672
|
return function() {
|
|
@@ -3603,13 +3675,13 @@ function At(e = {}) {
|
|
|
3603
3675
|
}(), V = () => {
|
|
3604
3676
|
console.log("Simulator: Game loaded, ready to start"), b.disabled = !1, u.forEach((e) => {
|
|
3605
3677
|
var t;
|
|
3606
|
-
return (t = e.onMessage) == null ? void 0 : t.call(e, "READY_GAME_LOADED", void 0,
|
|
3678
|
+
return (t = e.onMessage) == null ? void 0 : t.call(e, "READY_GAME_LOADED", void 0, R);
|
|
3607
3679
|
}), a && !f.hasStarted && setTimeout(() => {
|
|
3608
|
-
let e =
|
|
3609
|
-
e == null || e.click(), y.disabled = !1, f.hasStarted = !0,
|
|
3680
|
+
let e = D("#simulator-start");
|
|
3681
|
+
e == null || e.click(), y.disabled = !1, f.hasStarted = !0, k("Running", "ready");
|
|
3610
3682
|
}, 100);
|
|
3611
3683
|
};
|
|
3612
|
-
return
|
|
3684
|
+
return ie((e, t) => {
|
|
3613
3685
|
var n, r;
|
|
3614
3686
|
if (e === "READY") {
|
|
3615
3687
|
console.log("Simulator: Received READY from game"), B();
|
|
@@ -3622,7 +3694,7 @@ function At(e = {}) {
|
|
|
3622
3694
|
if (e === "TIMER_TICK") {
|
|
3623
3695
|
if (t != null && t.display) {
|
|
3624
3696
|
let [e, n] = t.display;
|
|
3625
|
-
|
|
3697
|
+
A(e, n);
|
|
3626
3698
|
}
|
|
3627
3699
|
return;
|
|
3628
3700
|
}
|
|
@@ -3633,28 +3705,28 @@ function At(e = {}) {
|
|
|
3633
3705
|
}
|
|
3634
3706
|
u.forEach((n) => {
|
|
3635
3707
|
var r;
|
|
3636
|
-
return (r = n.onMessage) == null ? void 0 : r.call(n, e, t,
|
|
3708
|
+
return (r = n.onMessage) == null ? void 0 : r.call(n, e, t, R);
|
|
3637
3709
|
});
|
|
3638
3710
|
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
|
-
},
|
|
3711
|
+
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"));
|
|
3712
|
+
}, F), console.log("Simulator initialized"), $ = {
|
|
3641
3713
|
updateFixtures: (e) => {
|
|
3642
|
-
o =
|
|
3714
|
+
o = ae(e), s = Array.from(o.keys()).sort(), R.fixtures = o, R.fixtureCategories = s;
|
|
3643
3715
|
let t = localStorage.getItem("simulator-fixture-category");
|
|
3644
3716
|
if (!f.selectedCategory || !s.includes(f.selectedCategory)) {
|
|
3645
3717
|
var n;
|
|
3646
3718
|
f.selectedCategory = t && s.includes(t) ? t : (n = s[0]) == null ? null : n;
|
|
3647
3719
|
}
|
|
3648
3720
|
let r = u.find((e) => e.id === "ctrl");
|
|
3649
|
-
r == null || r.bind(
|
|
3721
|
+
r == null || r.bind(R), console.log("Simulator: Fixtures updated", {
|
|
3650
3722
|
categories: s,
|
|
3651
3723
|
selectedCategory: f.selectedCategory
|
|
3652
3724
|
});
|
|
3653
3725
|
},
|
|
3654
|
-
sendToGame:
|
|
3655
|
-
loadPuzzle:
|
|
3726
|
+
sendToGame: I,
|
|
3727
|
+
loadPuzzle: P
|
|
3656
3728
|
}, $;
|
|
3657
3729
|
}
|
|
3658
|
-
export {
|
|
3730
|
+
export { Ot as n, oe as r, Nt as t };
|
|
3659
3731
|
|
|
3660
|
-
//# sourceMappingURL=createSimulator-
|
|
3732
|
+
//# sourceMappingURL=createSimulator-B6T0o88B.js.map
|