@puzzmo/sdk 1.0.34 → 1.0.35
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-CxuhQLO3.js → createSimulator-BuPYG4eZ.js} +327 -204
- package/dist/createSimulator-BuPYG4eZ.js.map +1 -0
- package/dist/{createSimulator-DK8Pd9vS.cjs → createSimulator-DDHvAKZy.cjs} +114 -34
- package/dist/createSimulator-DDHvAKZy.cjs.map +1 -0
- 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/state.d.ts +2 -1
- package/dist/simulator/state.d.ts.map +1 -1
- package/dist/simulator/styles.d.ts +1 -1
- package/dist/simulator/styles.d.ts.map +1 -1
- package/dist/simulator/types.d.ts +7 -0
- package/dist/simulator/types.d.ts.map +1 -1
- package/dist/simulator/views/ThumbView.d.ts.map +1 -1
- package/dist/vite.cjs +1 -1
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +1 -1
- package/dist/vite.js.map +1 -1
- package/package.json +1 -1
- package/dist/createSimulator-CxuhQLO3.js.map +0 -1
- package/dist/createSimulator-DK8Pd9vS.cjs.map +0 -1
|
@@ -314,6 +314,7 @@ var r = {
|
|
|
314
314
|
fixturePuzzle: "simulator-fixture-puzzle",
|
|
315
315
|
renderHost: "simulator-render-host",
|
|
316
316
|
renderContext: "simulator-render-context",
|
|
317
|
+
previewKind: "simulator-preview-kind",
|
|
317
318
|
gameSettings: "simulator-game-settings",
|
|
318
319
|
hostContext: "simulator-host-context"
|
|
319
320
|
};
|
|
@@ -368,6 +369,9 @@ function d() {
|
|
|
368
369
|
].includes(e) ? e : "game";
|
|
369
370
|
}
|
|
370
371
|
function f() {
|
|
372
|
+
return localStorage.getItem(r.previewKind) === "text" ? "text" : "image";
|
|
373
|
+
}
|
|
374
|
+
function p() {
|
|
371
375
|
let e = localStorage.getItem(r.renderContext);
|
|
372
376
|
if (e && [
|
|
373
377
|
"preview",
|
|
@@ -376,16 +380,16 @@ function f() {
|
|
|
376
380
|
"timeline"
|
|
377
381
|
].includes(e)) return e;
|
|
378
382
|
}
|
|
379
|
-
function
|
|
380
|
-
var a, o,
|
|
381
|
-
let
|
|
383
|
+
function m(e, t, n) {
|
|
384
|
+
var a, o, m;
|
|
385
|
+
let h = localStorage.getItem(r.fixtureCategory), g = localStorage.getItem(r.fixturePuzzle), _ = i();
|
|
382
386
|
return {
|
|
383
|
-
hostContext: (a =
|
|
387
|
+
hostContext: (a = _ == null ? e.hostContext : _) == null ? [{
|
|
384
388
|
type: "app",
|
|
385
389
|
layout: "desktop",
|
|
386
390
|
host: null
|
|
387
391
|
}] : a,
|
|
388
|
-
hostContextIsOverridden:
|
|
392
|
+
hostContextIsOverridden: _ !== null,
|
|
389
393
|
isCollapsed: u((o = e.collapsed) == null ? !0 : o),
|
|
390
394
|
isPaused: !1,
|
|
391
395
|
hasStarted: !1,
|
|
@@ -395,21 +399,22 @@ function p(e, t, n) {
|
|
|
395
399
|
currentInputStr: "",
|
|
396
400
|
completionData: null,
|
|
397
401
|
selectedTheme: c(),
|
|
398
|
-
selectedCategory:
|
|
399
|
-
selectedPuzzle:
|
|
402
|
+
selectedCategory: h && t.includes(h) ? h : (m = t[0]) == null ? null : m,
|
|
403
|
+
selectedPuzzle: g == null ? null : g,
|
|
400
404
|
renderHost: d(),
|
|
401
|
-
renderContext:
|
|
405
|
+
renderContext: p(),
|
|
406
|
+
previewKind: f(),
|
|
402
407
|
gameSettings: s(),
|
|
403
408
|
settingsComponents: null
|
|
404
409
|
};
|
|
405
410
|
}
|
|
406
|
-
function
|
|
411
|
+
function h(e) {
|
|
407
412
|
localStorage.setItem(r.gameSettings, JSON.stringify(e));
|
|
408
413
|
}
|
|
409
|
-
function
|
|
414
|
+
function g() {
|
|
410
415
|
localStorage.removeItem(r.gameSettings);
|
|
411
416
|
}
|
|
412
|
-
function
|
|
417
|
+
function _(e) {
|
|
413
418
|
localStorage.setItem(r.collapsed, String(e));
|
|
414
419
|
}
|
|
415
420
|
function ee(e) {
|
|
@@ -418,19 +423,22 @@ function ee(e) {
|
|
|
418
423
|
function te(e) {
|
|
419
424
|
localStorage.setItem(r.theme, e);
|
|
420
425
|
}
|
|
421
|
-
function
|
|
426
|
+
function v(e) {
|
|
422
427
|
localStorage.setItem(r.fixtureCategory, e);
|
|
423
428
|
}
|
|
424
|
-
function
|
|
429
|
+
function ne(e) {
|
|
425
430
|
localStorage.setItem(r.fixturePuzzle, e);
|
|
426
431
|
}
|
|
427
|
-
function
|
|
432
|
+
function y() {
|
|
428
433
|
localStorage.removeItem(r.fixturePuzzle);
|
|
429
434
|
}
|
|
430
|
-
function
|
|
435
|
+
function b(e) {
|
|
431
436
|
e ? localStorage.setItem(r.renderHost, e) : localStorage.removeItem(r.renderHost);
|
|
432
437
|
}
|
|
433
|
-
function
|
|
438
|
+
function x(e) {
|
|
439
|
+
localStorage.setItem(r.previewKind, e);
|
|
440
|
+
}
|
|
441
|
+
function S(e) {
|
|
434
442
|
e ? localStorage.setItem(r.renderContext, e) : localStorage.removeItem(r.renderContext);
|
|
435
443
|
}
|
|
436
444
|
function re(e) {
|
|
@@ -493,7 +501,7 @@ function oe(e) {
|
|
|
493
501
|
}), t;
|
|
494
502
|
}
|
|
495
503
|
/** Render fixture selector HTML */
|
|
496
|
-
function
|
|
504
|
+
function C(e, t) {
|
|
497
505
|
return e.length === 0 ? "" : `
|
|
498
506
|
<div class="simulator-fixtures">
|
|
499
507
|
<div class="simulator-field">
|
|
@@ -510,7 +518,7 @@ function x(e, t) {
|
|
|
510
518
|
`;
|
|
511
519
|
}
|
|
512
520
|
/** Update puzzle select options based on selected category */
|
|
513
|
-
function
|
|
521
|
+
function w(e, t, n, r) {
|
|
514
522
|
let i = t.get(n);
|
|
515
523
|
if (!i) return null;
|
|
516
524
|
let a = Array.from(i.keys()), o = r;
|
|
@@ -521,7 +529,7 @@ function S(e, t, n, r) {
|
|
|
521
529
|
return e.innerHTML = a.map((e) => `<option value="${e}" ${e === o ? "selected" : ""}>${e}</option>`).join(""), o;
|
|
522
530
|
}
|
|
523
531
|
/** Get puzzle data from fixtures */
|
|
524
|
-
function
|
|
532
|
+
function T(e, t, n) {
|
|
525
533
|
var r, i;
|
|
526
534
|
return !t || !n || (r = (i = e.get(t)) == null ? void 0 : i.get(n)) == null ? null : r;
|
|
527
535
|
}
|
|
@@ -540,19 +548,19 @@ function se() {
|
|
|
540
548
|
selectedCategory: e.state.selectedCategory,
|
|
541
549
|
selectedPuzzle: e.state.selectedPuzzle
|
|
542
550
|
}), e.fixtures && e.fixtureCategories.length > 0 && i) {
|
|
543
|
-
i.innerHTML =
|
|
551
|
+
i.innerHTML = C(e.fixtureCategories, e.state.selectedCategory);
|
|
544
552
|
let t = e.getElement("#simulator-fixture-category"), n = e.getElement("#simulator-fixture-puzzle");
|
|
545
553
|
if (t && n && e.state.selectedCategory) {
|
|
546
|
-
e.state.selectedPuzzle =
|
|
547
|
-
let r =
|
|
554
|
+
e.state.selectedPuzzle = w(n, e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
|
|
555
|
+
let r = T(e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
|
|
548
556
|
console.log("Simulator: Loading fixture puzzle", {
|
|
549
557
|
category: e.state.selectedCategory,
|
|
550
558
|
puzzle: e.state.selectedPuzzle,
|
|
551
559
|
hasPuzzleData: !!r
|
|
552
|
-
}), r && (e.state.puzzleData = r, e.state.originalPuzzle = r, e.state.selectedCategory &&
|
|
553
|
-
console.log("Simulator: Category changed, reloading...", t.value),
|
|
560
|
+
}), r && (e.state.puzzleData = r, e.state.originalPuzzle = r, e.state.selectedCategory && v(e.state.selectedCategory), e.state.selectedPuzzle && ne(e.state.selectedPuzzle)), t.addEventListener("change", () => {
|
|
561
|
+
console.log("Simulator: Category changed, reloading...", t.value), v(t.value), y(), window.location.reload();
|
|
554
562
|
}), n.addEventListener("change", () => {
|
|
555
|
-
console.log("Simulator: Puzzle changed, reloading...", n.value),
|
|
563
|
+
console.log("Simulator: Puzzle changed, reloading...", n.value), ne(n.value), window.location.reload();
|
|
556
564
|
});
|
|
557
565
|
}
|
|
558
566
|
}
|
|
@@ -578,10 +586,10 @@ function se() {
|
|
|
578
586
|
* Inlined here (rather than shared with the rest of the monorepo) because the SDK ships to OSS and
|
|
579
587
|
* must stay self-contained.
|
|
580
588
|
*/
|
|
581
|
-
function
|
|
589
|
+
function E(e) {
|
|
582
590
|
var t;
|
|
583
591
|
if (typeof e != "string") return e;
|
|
584
|
-
let n = (t =
|
|
592
|
+
let n = (t = D(e)) == null ? {
|
|
585
593
|
width: 800,
|
|
586
594
|
height: 800
|
|
587
595
|
} : t;
|
|
@@ -592,7 +600,7 @@ function w(e) {
|
|
|
592
600
|
};
|
|
593
601
|
}
|
|
594
602
|
/** Reads an SVG's intrinsic size from its `viewBox` (preferred) or its `width`/`height` attributes. */
|
|
595
|
-
function
|
|
603
|
+
function D(e) {
|
|
596
604
|
var t, n, r, i;
|
|
597
605
|
let a = e.indexOf("<svg");
|
|
598
606
|
if (a === -1) return;
|
|
@@ -610,9 +618,9 @@ function T(e) {
|
|
|
610
618
|
height: u
|
|
611
619
|
};
|
|
612
620
|
}
|
|
613
|
-
var
|
|
621
|
+
var O = "simulator-saved-states";
|
|
614
622
|
/** Find thumbnail function on globalThis (looks for functions ending in "Thumbnail") */
|
|
615
|
-
function
|
|
623
|
+
function k() {
|
|
616
624
|
let e = globalThis;
|
|
617
625
|
for (let t of Object.keys(e)) if (t.endsWith("Thumbnail") && typeof e[t] == "function") return {
|
|
618
626
|
name: t,
|
|
@@ -621,8 +629,8 @@ function D() {
|
|
|
621
629
|
return null;
|
|
622
630
|
}
|
|
623
631
|
/** Generate a small thumbnail SVG for a given input string */
|
|
624
|
-
function
|
|
625
|
-
let n =
|
|
632
|
+
function A(e, t) {
|
|
633
|
+
let n = k();
|
|
626
634
|
if (!n) return "";
|
|
627
635
|
try {
|
|
628
636
|
var r;
|
|
@@ -632,13 +640,13 @@ function O(e, t) {
|
|
|
632
640
|
strict: !0,
|
|
633
641
|
renderHost: "game"
|
|
634
642
|
};
|
|
635
|
-
return
|
|
643
|
+
return E(n.fn(i, t, a)).svg;
|
|
636
644
|
} catch (e) {
|
|
637
645
|
return "";
|
|
638
646
|
}
|
|
639
647
|
}
|
|
640
|
-
var
|
|
641
|
-
function
|
|
648
|
+
var j = [];
|
|
649
|
+
function M(e, t = 8) {
|
|
642
650
|
let n = 14 * t + 8 + 4;
|
|
643
651
|
e.style.height = "auto";
|
|
644
652
|
let r = Math.min(Math.max(e.scrollHeight, 40), n);
|
|
@@ -662,102 +670,102 @@ function ce() {
|
|
|
662
670
|
let i = n.getElement(".data-view-container");
|
|
663
671
|
i == null || i.querySelectorAll(".data-subtab-content").forEach((e) => {
|
|
664
672
|
e.classList.toggle("active", e.id === `data-subtab-${t}`);
|
|
665
|
-
}), t === "edit" ?
|
|
673
|
+
}), t === "edit" ? L(n) : t === "history" ? P(n) : t === "saves" && F(n);
|
|
666
674
|
});
|
|
667
675
|
});
|
|
668
676
|
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"), u = n.getElement("#simulator-start"), d = n.getElement("#simulator-pause");
|
|
669
677
|
setTimeout(() => {
|
|
670
|
-
i && n.state.originalPuzzle && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle,
|
|
678
|
+
i && n.state.originalPuzzle && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle, M(i)), a && n.state.currentInputStr && (a.value = n.state.currentInputStr, t = n.state.currentInputStr, M(a));
|
|
671
679
|
}, 0), i == null || i.addEventListener("input", () => {
|
|
672
|
-
|
|
680
|
+
M(i);
|
|
673
681
|
let t = i.value !== e;
|
|
674
682
|
s && (s.disabled = !t);
|
|
675
683
|
}), a == null || a.addEventListener("input", () => {
|
|
676
|
-
|
|
684
|
+
M(a);
|
|
677
685
|
let e = a.value !== t;
|
|
678
686
|
l && (l.disabled = !e);
|
|
679
687
|
}), o == null || o.addEventListener("click", () => {
|
|
680
|
-
i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle,
|
|
688
|
+
i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle, M(i), s && (s.disabled = !0));
|
|
681
689
|
}), s == null || s.addEventListener("click", () => {
|
|
682
690
|
i && (n.state.puzzleData = i.value, n.state.originalPuzzle = i.value, e = i.value, n.sendToGame("RETRY_PUZZLE", {}), n.state.hasStarted = !1, n.state.isPaused = !1, d && (d.disabled = !0, d.textContent = "Pause"), u && (u.textContent = "Start"), n.updateStatus("Puzzle updated", "ready"), s.disabled = !0);
|
|
683
691
|
}), c == null || c.addEventListener("click", () => {
|
|
684
|
-
a && (a.value = t,
|
|
692
|
+
a && (a.value = t, M(a), l && (l.disabled = !0));
|
|
685
693
|
}), l == null || l.addEventListener("click", () => {
|
|
686
694
|
a && (n.state.currentInputStr = a.value, t = a.value, console.log("Simulator: Input string updated (game restart required to apply)"), n.updateStatus("Input stored", "ready"), l.disabled = !0);
|
|
687
695
|
});
|
|
688
696
|
let f = n.getElement("#simulator-history-clear");
|
|
689
697
|
f == null || f.addEventListener("click", () => {
|
|
690
|
-
|
|
698
|
+
j = [], P(n);
|
|
691
699
|
});
|
|
692
700
|
let p = n.getElement("#simulator-save-name"), m = n.getElement("#simulator-save-btn");
|
|
693
701
|
m == null || m.addEventListener("click", () => {
|
|
694
702
|
if (!p || !p.value.trim()) return;
|
|
695
|
-
let e =
|
|
703
|
+
let e = N(), t = {
|
|
696
704
|
name: p.value.trim(),
|
|
697
705
|
puzzleStr: n.state.originalPuzzle,
|
|
698
706
|
inputStr: n.state.currentInputStr,
|
|
699
707
|
timestamp: Date.now()
|
|
700
708
|
};
|
|
701
|
-
e.push(t), localStorage.setItem(
|
|
702
|
-
}),
|
|
709
|
+
e.push(t), localStorage.setItem(O, JSON.stringify(e)), p.value = "", F(n);
|
|
710
|
+
}), F(n);
|
|
703
711
|
},
|
|
704
712
|
onActivate(n) {
|
|
705
|
-
e = n.state.originalPuzzle, t = n.state.currentInputStr,
|
|
713
|
+
e = n.state.originalPuzzle, t = n.state.currentInputStr, L(n), P(n);
|
|
706
714
|
},
|
|
707
715
|
onMessage(e, n, r) {
|
|
708
716
|
var i, a;
|
|
709
717
|
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;
|
|
710
718
|
if (e === "UPLOAD_NEW_GAME_STATE" && c) {
|
|
711
|
-
if (r.state.currentInputStr = c,
|
|
712
|
-
|
|
719
|
+
if (r.state.currentInputStr = c, j.length === 0 || j[j.length - 1].value !== c) {
|
|
720
|
+
j.push({
|
|
713
721
|
value: c,
|
|
714
722
|
timestamp: Date.now()
|
|
715
|
-
}),
|
|
723
|
+
}), j.length > 100 && (j = j.slice(-100));
|
|
716
724
|
let e = r.getElement("#data-subtab-history");
|
|
717
|
-
e != null && e.classList.contains("active") &&
|
|
725
|
+
e != null && e.classList.contains("active") && P(r);
|
|
718
726
|
}
|
|
719
|
-
o && (o.value = r.state.currentInputStr, t = r.state.currentInputStr,
|
|
727
|
+
o && (o.value = r.state.currentInputStr, t = r.state.currentInputStr, M(o), s && (s.disabled = !0));
|
|
720
728
|
}
|
|
721
729
|
}
|
|
722
730
|
};
|
|
723
731
|
}
|
|
724
|
-
function
|
|
732
|
+
function N() {
|
|
725
733
|
try {
|
|
726
|
-
let e = localStorage.getItem(
|
|
734
|
+
let e = localStorage.getItem(O);
|
|
727
735
|
return e ? JSON.parse(e) : [];
|
|
728
736
|
} catch (e) {
|
|
729
737
|
return [];
|
|
730
738
|
}
|
|
731
739
|
}
|
|
732
|
-
function
|
|
740
|
+
function P(e) {
|
|
733
741
|
let t = e.getElement("#simulator-history-list");
|
|
734
742
|
if (t) {
|
|
735
|
-
if (t.style.setProperty("--history-thumb-bg", e.state.selectedTheme.a_bg),
|
|
743
|
+
if (t.style.setProperty("--history-thumb-bg", e.state.selectedTheme.a_bg), j.length === 0) {
|
|
736
744
|
t.innerHTML = "<div class=\"simulator-empty\">No history yet</div>";
|
|
737
745
|
return;
|
|
738
746
|
}
|
|
739
|
-
t.innerHTML = [...
|
|
740
|
-
let r =
|
|
747
|
+
t.innerHTML = [...j].reverse().map((t, n) => {
|
|
748
|
+
let r = j.length - 1 - n, i = new Date(t.timestamp).toLocaleTimeString(), a = t.value.length > 60 ? t.value.slice(0, 60) + "..." : t.value;
|
|
741
749
|
return `
|
|
742
750
|
<div class="history-item" data-history-idx="${r}">
|
|
743
|
-
<div class="history-item-thumb">${
|
|
751
|
+
<div class="history-item-thumb">${A(e, t.value)}</div>
|
|
744
752
|
<div class="history-item-content">
|
|
745
753
|
<div class="history-item-header">
|
|
746
754
|
<span class="history-item-num">#${r + 1}</span>
|
|
747
755
|
<span class="history-item-time">${i}</span>
|
|
748
756
|
<button class="simulator-btn tiny history-restore-btn" data-history-idx="${r}">Restore</button>
|
|
749
757
|
</div>
|
|
750
|
-
<div class="history-item-preview">${
|
|
758
|
+
<div class="history-item-preview">${I(a)}</div>
|
|
751
759
|
</div>
|
|
752
760
|
</div>
|
|
753
761
|
`;
|
|
754
762
|
}).join(""), t.querySelectorAll(".history-restore-btn").forEach((t) => {
|
|
755
763
|
t.addEventListener("click", (t) => {
|
|
756
|
-
let n = parseInt(t.target.getAttribute("data-history-idx") || "0"), r =
|
|
764
|
+
let n = parseInt(t.target.getAttribute("data-history-idx") || "0"), r = j[n];
|
|
757
765
|
if (r) {
|
|
758
766
|
e.state.currentInputStr = r.value;
|
|
759
767
|
let t = e.getElement("#simulator-input");
|
|
760
|
-
t && (t.value = r.value,
|
|
768
|
+
t && (t.value = r.value, M(t)), e.updateStatus("Input restored from history", "ready");
|
|
761
769
|
let n = e.getElement(".data-subtab[data-subtab=\"edit\"]");
|
|
762
770
|
n == null || n.click();
|
|
763
771
|
}
|
|
@@ -765,10 +773,10 @@ function M(e) {
|
|
|
765
773
|
});
|
|
766
774
|
}
|
|
767
775
|
}
|
|
768
|
-
function
|
|
776
|
+
function F(e) {
|
|
769
777
|
let t = e.getElement("#simulator-saves-list");
|
|
770
778
|
if (!t) return;
|
|
771
|
-
let n =
|
|
779
|
+
let n = N();
|
|
772
780
|
if (n.length === 0) {
|
|
773
781
|
t.innerHTML = "<div class=\"simulator-empty\">No saved states</div>";
|
|
774
782
|
return;
|
|
@@ -778,7 +786,7 @@ function N(e) {
|
|
|
778
786
|
return `
|
|
779
787
|
<div class="save-item">
|
|
780
788
|
<div class="save-item-header">
|
|
781
|
-
<span class="save-item-name">${
|
|
789
|
+
<span class="save-item-name">${I(e.name)}</span>
|
|
782
790
|
<span class="save-item-time">${i} ${a}</span>
|
|
783
791
|
</div>
|
|
784
792
|
<div class="save-item-actions">
|
|
@@ -793,7 +801,7 @@ function N(e) {
|
|
|
793
801
|
if (r) {
|
|
794
802
|
e.state.puzzleData = r.puzzleStr, e.state.originalPuzzle = r.puzzleStr, e.state.currentInputStr = r.inputStr;
|
|
795
803
|
let t = e.getElement("#simulator-puzzle"), n = e.getElement("#simulator-input");
|
|
796
|
-
t && (t.value = r.puzzleStr,
|
|
804
|
+
t && (t.value = r.puzzleStr, M(t)), n && (n.value = r.inputStr, M(n)), e.updateStatus(`Loaded: ${r.name}`, "ready");
|
|
797
805
|
let i = e.getElement(".data-subtab[data-subtab=\"edit\"]");
|
|
798
806
|
i == null || i.click();
|
|
799
807
|
}
|
|
@@ -801,18 +809,18 @@ function N(e) {
|
|
|
801
809
|
}), t.querySelectorAll(".save-delete-btn").forEach((t) => {
|
|
802
810
|
t.addEventListener("click", (t) => {
|
|
803
811
|
let r = parseInt(t.target.getAttribute("data-save-idx") || "0"), i = n.filter((e, t) => t !== r);
|
|
804
|
-
localStorage.setItem(
|
|
812
|
+
localStorage.setItem(O, JSON.stringify(i)), F(e);
|
|
805
813
|
});
|
|
806
814
|
});
|
|
807
815
|
}
|
|
808
|
-
function
|
|
816
|
+
function I(e) {
|
|
809
817
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
810
818
|
}
|
|
811
|
-
function
|
|
819
|
+
function L(e) {
|
|
812
820
|
let t = e.getElement("#simulator-puzzle"), n = e.getElement("#simulator-input"), r = e.getElement("#simulator-puzzle-apply"), i = e.getElement("#simulator-input-apply");
|
|
813
|
-
t && e.state.originalPuzzle && (t.value = e.state.originalPuzzle,
|
|
821
|
+
t && e.state.originalPuzzle && (t.value = e.state.originalPuzzle, M(t), r && (r.disabled = !0)), n && (n.value = e.state.currentInputStr, M(n), i && (i.disabled = !0));
|
|
814
822
|
}
|
|
815
|
-
function
|
|
823
|
+
function R(e) {
|
|
816
824
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
817
825
|
}
|
|
818
826
|
function le() {
|
|
@@ -842,7 +850,7 @@ function le() {
|
|
|
842
850
|
<span class="simulator-msg-type">${t.direction === "out" ? "→" : "←"} ${t.type}</span>
|
|
843
851
|
<span class="simulator-msg-time">${t.time}</span>
|
|
844
852
|
</div>
|
|
845
|
-
${a ? `<div class="simulator-msg-data">${
|
|
853
|
+
${a ? `<div class="simulator-msg-data">${R(a)}</div>` : ""}
|
|
846
854
|
`;
|
|
847
855
|
let o = i.querySelector(".simulator-msg-data");
|
|
848
856
|
for (o && o.addEventListener("click", () => {
|
|
@@ -941,7 +949,7 @@ function de() {
|
|
|
941
949
|
};
|
|
942
950
|
}
|
|
943
951
|
/** Find thumbnail function on globalThis (looks for functions ending in "Thumbnail") */
|
|
944
|
-
function
|
|
952
|
+
function fe() {
|
|
945
953
|
let e = globalThis;
|
|
946
954
|
for (let t of Object.keys(e)) if (t.endsWith("Thumbnail") && typeof e[t] == "function") return {
|
|
947
955
|
name: t,
|
|
@@ -949,47 +957,94 @@ function L() {
|
|
|
949
957
|
};
|
|
950
958
|
return null;
|
|
951
959
|
}
|
|
952
|
-
|
|
960
|
+
/** The bundle's `getShareString` (if any), exposed to the sim via vite.ts's bundle loader. */
|
|
961
|
+
function pe() {
|
|
962
|
+
let e = globalThis.getShareString;
|
|
963
|
+
return typeof e == "function" ? e : null;
|
|
964
|
+
}
|
|
965
|
+
function me(e) {
|
|
966
|
+
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
967
|
+
}
|
|
968
|
+
function he() {
|
|
969
|
+
let e = /* @__PURE__ */ new Date();
|
|
970
|
+
return `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`;
|
|
971
|
+
}
|
|
972
|
+
function ge(e) {
|
|
973
|
+
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
974
|
+
}
|
|
975
|
+
/** Shown when Preview Kind = Text but the bundle doesn't export `getShareString`. */
|
|
976
|
+
var _e = "\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";
|
|
977
|
+
function ve() {
|
|
953
978
|
return {
|
|
954
979
|
id: "thumb",
|
|
955
980
|
label: "Thumb",
|
|
956
981
|
render() {
|
|
957
|
-
return "\n <div class=\"thumb-view-container\">\n <div class=\"thumb-header\">\n <span class=\"simulator-label\">
|
|
982
|
+
return "\n <div class=\"thumb-view-container\">\n <div class=\"thumb-header\">\n <span class=\"simulator-label\">Preview</span>\n <button class=\"simulator-btn tiny\" id=\"simulator-thumb-refresh\">Refresh</button>\n </div>\n <div class=\"simulator-segmented\" id=\"simulator-preview-kind\" role=\"tablist\">\n <button class=\"simulator-segmented-btn\" data-preview-kind=\"image\" type=\"button\" role=\"tab\">Image</button>\n <button class=\"simulator-segmented-btn\" data-preview-kind=\"text\" type=\"button\" role=\"tab\">Text</button>\n </div>\n <div id=\"simulator-thumb-preview\">\n <span class=\"simulator-empty\">No thumbnail function found</span>\n </div>\n <div id=\"simulator-thumb-fn\"></div>\n <div class=\"simulator-divider\"></div>\n <div class=\"simulator-field\" id=\"simulator-render-host-field\">\n <label class=\"simulator-label\">Render Host</label>\n <select class=\"simulator-select\" id=\"simulator-render-host-select\">\n <option value=\"game\">game</option>\n <option value=\"app\">app</option>\n <option value=\"opengraph\">opengraph</option>\n </select>\n </div>\n <div class=\"simulator-field\" id=\"simulator-render-context-field\" style=\"display: none;\">\n <label class=\"simulator-label\">Render Context</label>\n <select class=\"simulator-select\" id=\"simulator-render-context-select\">\n <option value=\"preview\">preview</option>\n <option value=\"share\">share</option>\n <option value=\"completed\">completed</option>\n <option value=\"timeline\">timeline</option>\n </select>\n </div>\n </div>\n ";
|
|
958
983
|
},
|
|
959
984
|
bind(e) {
|
|
960
985
|
let t = e.getElement("#simulator-thumb-refresh");
|
|
961
986
|
t == null || t.addEventListener("click", () => e.updateThumbnail());
|
|
962
|
-
let n = e.getElement("#simulator-render-host-select"), r = e.getElement("#simulator-render-context-select"), i = e.getElement("#simulator-render-
|
|
963
|
-
|
|
987
|
+
let n = e.getElement("#simulator-render-host-select"), r = e.getElement("#simulator-render-context-select"), i = e.getElement("#simulator-render-host-field"), a = e.getElement("#simulator-render-context-field"), o = e.getElement("#simulator-preview-kind"), s = () => {
|
|
988
|
+
let t = e.state.previewKind !== "text";
|
|
989
|
+
i && (i.style.display = t ? "block" : "none"), a && (a.style.display = t && e.state.renderHost === "opengraph" ? "block" : "none");
|
|
990
|
+
}, c = () => {
|
|
991
|
+
o == null || o.querySelectorAll(".simulator-segmented-btn").forEach((t) => {
|
|
992
|
+
let n = t.dataset.previewKind;
|
|
993
|
+
t.classList.toggle("active", n === e.state.previewKind), t.setAttribute("aria-selected", n === e.state.previewKind ? "true" : "false");
|
|
994
|
+
});
|
|
964
995
|
};
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
996
|
+
o == null || o.querySelectorAll(".simulator-segmented-btn").forEach((t) => {
|
|
997
|
+
t.addEventListener("click", () => {
|
|
998
|
+
let n = t.dataset.previewKind;
|
|
999
|
+
!n || n === e.state.previewKind || (e.state.previewKind = n, x(n), c(), s(), e.updateThumbnail());
|
|
1000
|
+
});
|
|
1001
|
+
}), n && (e.state.renderHost || (e.state.renderHost = "game", b(e.state.renderHost)), n.value = e.state.renderHost || "game", n.addEventListener("change", () => {
|
|
1002
|
+
e.state.renderHost = n.value, b(e.state.renderHost), s(), e.updateThumbnail();
|
|
1003
|
+
})), r && (e.state.renderContext || (e.state.renderContext = "preview", S(e.state.renderContext)), r.value = e.state.renderContext || "preview", r.addEventListener("change", () => {
|
|
1004
|
+
e.state.renderContext = r.value, S(e.state.renderContext), e.updateThumbnail();
|
|
1005
|
+
})), c(), s();
|
|
970
1006
|
},
|
|
971
1007
|
onActivate(e) {
|
|
972
1008
|
setTimeout(() => e.updateThumbnail(), 0);
|
|
973
1009
|
},
|
|
974
1010
|
updatePreview: (e) => {
|
|
975
1011
|
let t = e.getElement("#simulator-thumb-preview"), n = e.getElement("#simulator-thumb-fn");
|
|
976
|
-
t == null || t.style.setProperty("--sim-thumb-bg", e.state.selectedTheme.g_bg)
|
|
977
|
-
|
|
978
|
-
|
|
1012
|
+
if (t == null || t.style.setProperty("--sim-thumb-bg", e.state.selectedTheme.g_bg), e.state.previewKind === "text") {
|
|
1013
|
+
let s = pe();
|
|
1014
|
+
if (!s) {
|
|
1015
|
+
t && (t.innerHTML = _e), n && (n.textContent = "");
|
|
1016
|
+
return;
|
|
1017
|
+
}
|
|
1018
|
+
n && (n.textContent = "Using: getShareString()");
|
|
1019
|
+
try {
|
|
1020
|
+
var r, i, a, o;
|
|
1021
|
+
let n = (r = e.gameSlug) == null ? "game" : r, c = s((i = e.state.currentInputStr) == null ? "" : i, ge(n), {
|
|
1022
|
+
puzzleString: (a = e.state.puzzleData) == null ? "" : a,
|
|
1023
|
+
dateKey: he(),
|
|
1024
|
+
gameplaySlug: `simulator:${n}`
|
|
1025
|
+
}), l = (o = c == null ? void 0 : c.str) == null ? "" : o;
|
|
1026
|
+
t && (t.innerHTML = `<pre class="simulator-share-preview" style="color: ${e.state.selectedTheme.fg}">${me(l)}</pre>`);
|
|
1027
|
+
} catch (e) {
|
|
1028
|
+
console.error("Simulator: Share string error", e), t && (t.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
|
|
1029
|
+
}
|
|
1030
|
+
return;
|
|
1031
|
+
}
|
|
1032
|
+
let s = fe();
|
|
1033
|
+
if (!s) {
|
|
979
1034
|
t && (t.innerHTML = "<span class=\"simulator-empty\">No thumbnail function found</span>"), n && (n.textContent = "");
|
|
980
1035
|
return;
|
|
981
1036
|
}
|
|
982
|
-
n && (n.textContent = `Using: ${
|
|
1037
|
+
n && (n.textContent = `Using: ${s.name}()`);
|
|
983
1038
|
try {
|
|
984
|
-
var
|
|
985
|
-
let n = (
|
|
1039
|
+
var c;
|
|
1040
|
+
let n = (c = e.state.puzzleData) == null ? "" : c, r = {
|
|
986
1041
|
viewerIsOwner: !0,
|
|
987
1042
|
theme: e.state.selectedTheme,
|
|
988
1043
|
strict: !0,
|
|
989
1044
|
renderHost: e.state.renderHost,
|
|
990
1045
|
renderContext: e.state.renderContext
|
|
991
|
-
}, { svg:
|
|
992
|
-
t && (t.innerHTML =
|
|
1046
|
+
}, { svg: i } = E(s.fn(n, e.state.currentInputStr, r));
|
|
1047
|
+
t && (t.innerHTML = i);
|
|
993
1048
|
} catch (e) {
|
|
994
1049
|
console.error("Simulator: Thumbnail error", e), t && (t.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
|
|
995
1050
|
}
|
|
@@ -997,7 +1052,7 @@ function fe() {
|
|
|
997
1052
|
};
|
|
998
1053
|
}
|
|
999
1054
|
/** Generate theme preview HTML showing key colors */
|
|
1000
|
-
function
|
|
1055
|
+
function ye(e) {
|
|
1001
1056
|
let t = [
|
|
1002
1057
|
e.key,
|
|
1003
1058
|
e.subBrand,
|
|
@@ -1008,7 +1063,7 @@ function R(e) {
|
|
|
1008
1063
|
].map((e) => `<div class="simulator-theme-preview-cell" style="background: ${e}"></div>`).join("");
|
|
1009
1064
|
return `<div class="simulator-theme-preview" style="background: ${e.g_bg}">${t}</div>`;
|
|
1010
1065
|
}
|
|
1011
|
-
function
|
|
1066
|
+
function be() {
|
|
1012
1067
|
return {
|
|
1013
1068
|
id: "theme",
|
|
1014
1069
|
label: "Theme",
|
|
@@ -1020,7 +1075,7 @@ function pe() {
|
|
|
1020
1075
|
t && n.forEach((n) => {
|
|
1021
1076
|
let r = document.createElement("div");
|
|
1022
1077
|
r.className = `simulator-theme-item${n.name === e.state.selectedTheme.name ? " selected" : ""}`, r.innerHTML = `
|
|
1023
|
-
${
|
|
1078
|
+
${ye(n)}
|
|
1024
1079
|
<div class="simulator-theme-name">${n.name}</div>
|
|
1025
1080
|
<div class="simulator-theme-type">${n.type}</div>
|
|
1026
1081
|
`, r.addEventListener("click", () => {
|
|
@@ -1030,7 +1085,7 @@ function pe() {
|
|
|
1030
1085
|
}
|
|
1031
1086
|
};
|
|
1032
1087
|
}
|
|
1033
|
-
var
|
|
1088
|
+
var xe = [
|
|
1034
1089
|
{
|
|
1035
1090
|
name: "app (desktop)",
|
|
1036
1091
|
context: [{
|
|
@@ -1077,8 +1132,8 @@ var me = [
|
|
|
1077
1132
|
* The bootstrap is only read at game boot, so applying a change persists it to localStorage and
|
|
1078
1133
|
* restarts (reloads) the page — the same flow as the Theme tab.
|
|
1079
1134
|
*/
|
|
1080
|
-
function
|
|
1081
|
-
let t = [...
|
|
1135
|
+
function Se(e = []) {
|
|
1136
|
+
let t = [...xe, ...e];
|
|
1082
1137
|
return {
|
|
1083
1138
|
id: "host",
|
|
1084
1139
|
label: "Host",
|
|
@@ -1095,7 +1150,7 @@ function he(e = []) {
|
|
|
1095
1150
|
<div class="host-note" id="host-source"></div>
|
|
1096
1151
|
<select class="simulator-select" id="host-presets">
|
|
1097
1152
|
<option value="">Preset…</option>
|
|
1098
|
-
${t.map((e, t) => `<option value="${t}">${
|
|
1153
|
+
${t.map((e, t) => `<option value="${t}">${Ce(e.name)}</option>`).join("")}
|
|
1099
1154
|
</select>
|
|
1100
1155
|
<textarea class="simulator-textarea" id="host-json" spellcheck="false"></textarea>
|
|
1101
1156
|
<div class="host-actions">
|
|
@@ -1132,42 +1187,42 @@ function he(e = []) {
|
|
|
1132
1187
|
};
|
|
1133
1188
|
}
|
|
1134
1189
|
/** Minimal HTML-escape so preset names can't break the simulator markup. */
|
|
1135
|
-
function
|
|
1190
|
+
function Ce(e) {
|
|
1136
1191
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
1137
1192
|
}
|
|
1138
|
-
var
|
|
1139
|
-
localStorage.setItem(
|
|
1140
|
-
},
|
|
1193
|
+
var we = "puzzmo_sim_api_mode", z = "http://localhost:8911", Te = "https://api.puzzmo.com", B = () => localStorage.getItem(we) === "dev" ? "dev" : "prod", Ee = (e) => {
|
|
1194
|
+
localStorage.setItem(we, e);
|
|
1195
|
+
}, V = null, De = function() {
|
|
1141
1196
|
var e = t(function* () {
|
|
1142
|
-
if (
|
|
1197
|
+
if (V !== null) return V;
|
|
1143
1198
|
try {
|
|
1144
|
-
let e = new AbortController(), t = setTimeout(() => e.abort(), 1e3), n = yield fetch(`${
|
|
1145
|
-
return clearTimeout(t),
|
|
1199
|
+
let e = new AbortController(), t = setTimeout(() => e.abort(), 1e3), n = yield fetch(`${z}/healthz`, { signal: e.signal });
|
|
1200
|
+
return clearTimeout(t), V = n.ok, V;
|
|
1146
1201
|
} catch (e) {
|
|
1147
|
-
return
|
|
1202
|
+
return V = !1, !1;
|
|
1148
1203
|
}
|
|
1149
1204
|
});
|
|
1150
1205
|
return function() {
|
|
1151
1206
|
return e.apply(this, arguments);
|
|
1152
1207
|
};
|
|
1153
|
-
}(),
|
|
1154
|
-
apiURL:
|
|
1208
|
+
}(), H = () => ({
|
|
1209
|
+
apiURL: B() === "dev" ? z : Te,
|
|
1155
1210
|
clientID: "protosdk:oauthclient",
|
|
1156
1211
|
redirectUri: `${window.location.origin}/oauth/callback`
|
|
1157
|
-
}),
|
|
1212
|
+
}), Oe = () => {
|
|
1158
1213
|
let e = new Uint8Array(32);
|
|
1159
1214
|
return crypto.getRandomValues(e), Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
1160
|
-
},
|
|
1161
|
-
let e = localStorage.getItem(
|
|
1215
|
+
}, U = "puzzmo_sim_oauth_token", W = "puzzmo_sim_oauth_refresh_token", ke = (e) => localStorage.setItem(U, e), Ae = (e) => localStorage.setItem(W, e), G = () => {
|
|
1216
|
+
let e = localStorage.getItem(U);
|
|
1162
1217
|
return e && `${e.substring(0, 20)}`, e;
|
|
1163
|
-
},
|
|
1164
|
-
localStorage.removeItem(
|
|
1165
|
-
},
|
|
1166
|
-
let e =
|
|
1218
|
+
}, K = () => localStorage.getItem(W), q = () => {
|
|
1219
|
+
localStorage.removeItem(U), localStorage.removeItem(W);
|
|
1220
|
+
}, je = () => {
|
|
1221
|
+
let e = H(), t = Oe();
|
|
1167
1222
|
sessionStorage.setItem("oauth_state", t), sessionStorage.setItem("oauth_return_url", window.location.href);
|
|
1168
1223
|
let n = new URL(`${e.apiURL}/oauth/auth`);
|
|
1169
1224
|
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();
|
|
1170
|
-
},
|
|
1225
|
+
}, Me = (e) => {
|
|
1171
1226
|
try {
|
|
1172
1227
|
let t = e.split(".");
|
|
1173
1228
|
if (t.length !== 3) return !0;
|
|
@@ -1176,11 +1231,11 @@ var z = "puzzmo_sim_api_mode", B = "http://localhost:8911", _e = "https://api.pu
|
|
|
1176
1231
|
} catch (e) {
|
|
1177
1232
|
return !0;
|
|
1178
1233
|
}
|
|
1179
|
-
},
|
|
1234
|
+
}, Ne = function() {
|
|
1180
1235
|
var e = t(function* () {
|
|
1181
|
-
let e =
|
|
1236
|
+
let e = K();
|
|
1182
1237
|
if (!e) return !1;
|
|
1183
|
-
let t =
|
|
1238
|
+
let t = H();
|
|
1184
1239
|
try {
|
|
1185
1240
|
let n = new URLSearchParams({
|
|
1186
1241
|
grant_type: "refresh_token",
|
|
@@ -1194,9 +1249,9 @@ var z = "puzzmo_sim_api_mode", B = "http://localhost:8911", _e = "https://api.pu
|
|
|
1194
1249
|
if (!r.ok) return r.statusText, !1;
|
|
1195
1250
|
let i = yield r.json(), a = i.access_token || i.accessToken;
|
|
1196
1251
|
if (!a) return !1;
|
|
1197
|
-
|
|
1252
|
+
ke(a);
|
|
1198
1253
|
let o = i.refresh_token || i.refreshToken;
|
|
1199
|
-
return o &&
|
|
1254
|
+
return o && Ae(o), !0;
|
|
1200
1255
|
} catch (e) {
|
|
1201
1256
|
return !1;
|
|
1202
1257
|
}
|
|
@@ -1204,9 +1259,9 @@ var z = "puzzmo_sim_api_mode", B = "http://localhost:8911", _e = "https://api.pu
|
|
|
1204
1259
|
return function() {
|
|
1205
1260
|
return e.apply(this, arguments);
|
|
1206
1261
|
};
|
|
1207
|
-
}(),
|
|
1262
|
+
}(), Pe = function() {
|
|
1208
1263
|
var e = t(function* (e, t) {
|
|
1209
|
-
let n =
|
|
1264
|
+
let n = H(), r = sessionStorage.getItem("oauth_state");
|
|
1210
1265
|
if (!r || r !== t) return null;
|
|
1211
1266
|
sessionStorage.removeItem("oauth_state");
|
|
1212
1267
|
try {
|
|
@@ -1228,13 +1283,13 @@ var z = "puzzmo_sim_api_mode", B = "http://localhost:8911", _e = "https://api.pu
|
|
|
1228
1283
|
return function(t, n) {
|
|
1229
1284
|
return e.apply(this, arguments);
|
|
1230
1285
|
};
|
|
1231
|
-
}(),
|
|
1286
|
+
}(), Fe = function() {
|
|
1232
1287
|
var e = t(function* (e, t = {}) {
|
|
1233
|
-
let n =
|
|
1288
|
+
let n = H(), r = G();
|
|
1234
1289
|
if (!r) throw Error("Not authenticated");
|
|
1235
|
-
if (
|
|
1236
|
-
if (r =
|
|
1237
|
-
} else throw
|
|
1290
|
+
if (Me(r)) if (yield Ne()) {
|
|
1291
|
+
if (r = G(), !r) throw Error("Token refresh succeeded but no token available");
|
|
1292
|
+
} else throw q(), Error("Session expired. Please log in again.");
|
|
1238
1293
|
let i = yield fetch(`${n.apiURL}/graphql`, {
|
|
1239
1294
|
method: "POST",
|
|
1240
1295
|
headers: {
|
|
@@ -1253,7 +1308,7 @@ var z = "puzzmo_sim_api_mode", B = "http://localhost:8911", _e = "https://api.pu
|
|
|
1253
1308
|
return function(t) {
|
|
1254
1309
|
return e.apply(this, arguments);
|
|
1255
1310
|
};
|
|
1256
|
-
}(),
|
|
1311
|
+
}(), Ie = (e) => {
|
|
1257
1312
|
try {
|
|
1258
1313
|
let t = e.split(".");
|
|
1259
1314
|
return t.length, t.length === 3 ? JSON.parse(atob(t[1])) : null;
|
|
@@ -1261,15 +1316,15 @@ var z = "puzzmo_sim_api_mode", B = "http://localhost:8911", _e = "https://api.pu
|
|
|
1261
1316
|
return null;
|
|
1262
1317
|
}
|
|
1263
1318
|
};
|
|
1264
|
-
function
|
|
1319
|
+
function Le() {
|
|
1265
1320
|
let e = !1;
|
|
1266
1321
|
return {
|
|
1267
1322
|
id: "auth",
|
|
1268
1323
|
label: "Auth",
|
|
1269
1324
|
render() {
|
|
1270
|
-
let e =
|
|
1325
|
+
let e = G(), t = !!e, n = B(), r = n === "dev" ? z : Te, i = `<button class="simulator-btn tiny" id="auth-dev-toggle" style="display: none;">${n === "dev" ? "Using Dev" : "Dev"}</button>`;
|
|
1271
1326
|
if (t) {
|
|
1272
|
-
let t =
|
|
1327
|
+
let t = Ie(e), n = t != null && t.exp ? (/* @__PURE__ */ new Date(t.exp * 1e3)).toLocaleString() : "Unknown", a = !!K(), o = a ? Ie(K()) : null, s = o != null && o.exp ? (/* @__PURE__ */ new Date(o.exp * 1e3)).toLocaleString() : null;
|
|
1273
1328
|
return `
|
|
1274
1329
|
<div class="simulator-section">
|
|
1275
1330
|
<div class="simulator-section-title auth-title-row">
|
|
@@ -1310,7 +1365,7 @@ function ke() {
|
|
|
1310
1365
|
</div>
|
|
1311
1366
|
<p class="auth-description">
|
|
1312
1367
|
Login with your Puzzmo account to make authenticated API requests.
|
|
1313
|
-
${n === "dev" ? `<br><strong>Using local dev server:</strong> ${
|
|
1368
|
+
${n === "dev" ? `<br><strong>Using local dev server:</strong> ${z}` : ""}
|
|
1314
1369
|
</p>
|
|
1315
1370
|
<div class="simulator-row">
|
|
1316
1371
|
<button class="simulator-btn primary" id="auth-login">Login with Puzzmo</button>
|
|
@@ -1321,21 +1376,21 @@ function ke() {
|
|
|
1321
1376
|
},
|
|
1322
1377
|
bind(n) {
|
|
1323
1378
|
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");
|
|
1324
|
-
e ?
|
|
1325
|
-
e && c && (c.style.display = "",
|
|
1379
|
+
e ? V && c && (c.style.display = "", B() === "dev" && c.classList.add("active")) : (e = !0, De().then((e) => {
|
|
1380
|
+
e && c && (c.style.display = "", B() === "dev" && c.classList.add("active"));
|
|
1326
1381
|
})), c == null || c.addEventListener("click", () => {
|
|
1327
|
-
|
|
1382
|
+
Ee(B() === "dev" ? "prod" : "dev"), q(), window.location.reload();
|
|
1328
1383
|
}), r == null || r.addEventListener("click", () => {
|
|
1329
|
-
|
|
1384
|
+
je();
|
|
1330
1385
|
}), i == null || i.addEventListener("click", () => {
|
|
1331
|
-
|
|
1386
|
+
q(), window.location.reload();
|
|
1332
1387
|
}), a == null || a.addEventListener("click", t(function* () {
|
|
1333
|
-
a.disabled = !0, a.textContent = "Refreshing...", (yield
|
|
1388
|
+
a.disabled = !0, a.textContent = "Refreshing...", (yield Ne()) ? window.location.reload() : (a.textContent = "Refresh Failed", a.disabled = !1);
|
|
1334
1389
|
})), o == null || o.addEventListener("click", t(function* () {
|
|
1335
1390
|
if (s) {
|
|
1336
1391
|
s.innerHTML = "<div class=\"loading\">Loading...</div>";
|
|
1337
1392
|
try {
|
|
1338
|
-
let t = yield
|
|
1393
|
+
let t = yield Fe("\n query {\n currentUser {\n id\n username\n usernameID\n name\n }\n }\n ");
|
|
1339
1394
|
if (t.errors) {
|
|
1340
1395
|
var e;
|
|
1341
1396
|
s.innerHTML = `<div class="error">Error: ${((e = t.errors[0]) == null ? void 0 : e.message) || "Unknown error"}</div>`;
|
|
@@ -1357,13 +1412,13 @@ function ke() {
|
|
|
1357
1412
|
if (n && r) {
|
|
1358
1413
|
let t = e.getElement("#auth-status");
|
|
1359
1414
|
t && (t.innerHTML = "<span class=\"indicator waiting\"></span><span>Exchanging code...</span>");
|
|
1360
|
-
let i = yield
|
|
1415
|
+
let i = yield Pe(n, r);
|
|
1361
1416
|
if (window.history.replaceState({}, "", window.location.pathname), i) {
|
|
1362
1417
|
let e = i.access_token || i.accessToken;
|
|
1363
1418
|
if (e) {
|
|
1364
|
-
|
|
1419
|
+
ke(e);
|
|
1365
1420
|
let t = i.refresh_token || i.refreshToken;
|
|
1366
|
-
t &&
|
|
1421
|
+
t && Ae(t);
|
|
1367
1422
|
}
|
|
1368
1423
|
window.location.reload();
|
|
1369
1424
|
} else {
|
|
@@ -1375,9 +1430,9 @@ function ke() {
|
|
|
1375
1430
|
}
|
|
1376
1431
|
};
|
|
1377
1432
|
}
|
|
1378
|
-
var
|
|
1379
|
-
localStorage.removeItem(
|
|
1380
|
-
},
|
|
1433
|
+
var Re = "puzzmo_sim_api_mode", ze = "http://localhost:8911", Be = "https://api.puzzmo.com", J = "puzzmo_sim_oauth_token", Y = "puzzmo_sim_oauth_refresh_token", Ve = () => localStorage.getItem(Re) === "dev" ? "dev" : "prod", X = () => localStorage.getItem(J), He = () => localStorage.getItem(Y), Ue = (e) => localStorage.setItem(J, e), We = (e) => localStorage.setItem(Y, e), Ge = () => {
|
|
1434
|
+
localStorage.removeItem(J), localStorage.removeItem(Y);
|
|
1435
|
+
}, Ke = (e) => {
|
|
1381
1436
|
try {
|
|
1382
1437
|
let t = e.split(".");
|
|
1383
1438
|
if (t.length !== 3) return !0;
|
|
@@ -1386,11 +1441,11 @@ var Ae = "puzzmo_sim_api_mode", je = "http://localhost:8911", Me = "https://api.
|
|
|
1386
1441
|
} catch (e) {
|
|
1387
1442
|
return !0;
|
|
1388
1443
|
}
|
|
1389
|
-
},
|
|
1444
|
+
}, qe = function() {
|
|
1390
1445
|
var e = t(function* () {
|
|
1391
|
-
let e =
|
|
1446
|
+
let e = He();
|
|
1392
1447
|
if (!e) return !1;
|
|
1393
|
-
let t =
|
|
1448
|
+
let t = Ve() === "dev" ? ze : Be;
|
|
1394
1449
|
try {
|
|
1395
1450
|
let n = new URLSearchParams({
|
|
1396
1451
|
grant_type: "refresh_token",
|
|
@@ -1404,9 +1459,9 @@ var Ae = "puzzmo_sim_api_mode", je = "http://localhost:8911", Me = "https://api.
|
|
|
1404
1459
|
if (!r.ok) return !1;
|
|
1405
1460
|
let i = yield r.json(), a = i.access_token || i.accessToken;
|
|
1406
1461
|
if (!a) return !1;
|
|
1407
|
-
|
|
1462
|
+
Ue(a);
|
|
1408
1463
|
let o = i.refresh_token || i.refreshToken;
|
|
1409
|
-
return o &&
|
|
1464
|
+
return o && We(o), !0;
|
|
1410
1465
|
} catch (e) {
|
|
1411
1466
|
return !1;
|
|
1412
1467
|
}
|
|
@@ -1414,13 +1469,13 @@ var Ae = "puzzmo_sim_api_mode", je = "http://localhost:8911", Me = "https://api.
|
|
|
1414
1469
|
return function() {
|
|
1415
1470
|
return e.apply(this, arguments);
|
|
1416
1471
|
};
|
|
1417
|
-
}(),
|
|
1472
|
+
}(), Je = function() {
|
|
1418
1473
|
var e = t(function* (e, t = {}) {
|
|
1419
|
-
let n =
|
|
1474
|
+
let n = Ve() === "dev" ? ze : Be, r = X();
|
|
1420
1475
|
if (!r) throw Error("Not authenticated");
|
|
1421
|
-
if (
|
|
1422
|
-
if (r =
|
|
1423
|
-
} else throw
|
|
1476
|
+
if (Ke(r)) if (yield qe()) {
|
|
1477
|
+
if (r = X(), !r) throw Error("Token refresh succeeded but no token available");
|
|
1478
|
+
} else throw Ge(), Error("Session expired. Please log in again.");
|
|
1424
1479
|
let i = yield fetch(`${n}/graphql`, {
|
|
1425
1480
|
method: "POST",
|
|
1426
1481
|
headers: {
|
|
@@ -1439,19 +1494,19 @@ var Ae = "puzzmo_sim_api_mode", je = "http://localhost:8911", Me = "https://api.
|
|
|
1439
1494
|
return function(t) {
|
|
1440
1495
|
return e.apply(this, arguments);
|
|
1441
1496
|
};
|
|
1442
|
-
}(),
|
|
1497
|
+
}(), Ye = "\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", Xe = "\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", Ze = (e, t) => {
|
|
1443
1498
|
let n = t - 1, r = Math.floor(n / 31), i = n % 31, a = [...e];
|
|
1444
1499
|
for (; a.length <= r;) a.push(0);
|
|
1445
1500
|
return a[r] = a[r] ^ 1 << i, a;
|
|
1446
1501
|
};
|
|
1447
|
-
const
|
|
1448
|
-
function
|
|
1502
|
+
const Qe = () => !!X();
|
|
1503
|
+
function $e() {
|
|
1449
1504
|
let n = null, r = !1, i = null, a = function() {
|
|
1450
1505
|
var e = t(function* (e) {
|
|
1451
1506
|
r = !0, i = null;
|
|
1452
1507
|
try {
|
|
1453
1508
|
var t;
|
|
1454
|
-
let r = yield
|
|
1509
|
+
let r = yield Je(Ye, { slug: e });
|
|
1455
1510
|
if (r.errors) {
|
|
1456
1511
|
var a;
|
|
1457
1512
|
i = ((a = r.errors[0]) == null ? void 0 : a.message) || "Unknown error", n = null;
|
|
@@ -1468,10 +1523,10 @@ function Ke() {
|
|
|
1468
1523
|
}(), o = function() {
|
|
1469
1524
|
var r = t(function* (t) {
|
|
1470
1525
|
if (!n) return;
|
|
1471
|
-
let r =
|
|
1526
|
+
let r = Ze(n.featuresArr, t);
|
|
1472
1527
|
try {
|
|
1473
1528
|
var i;
|
|
1474
|
-
let t = yield
|
|
1529
|
+
let t = yield Je(Xe, {
|
|
1475
1530
|
gameSlug: n.slug,
|
|
1476
1531
|
input: { featuresArr: r }
|
|
1477
1532
|
});
|
|
@@ -1519,7 +1574,7 @@ function Ke() {
|
|
|
1519
1574
|
id: "features",
|
|
1520
1575
|
label: "Features",
|
|
1521
1576
|
render() {
|
|
1522
|
-
return
|
|
1577
|
+
return Qe() ? `
|
|
1523
1578
|
<div class="features-view-container">
|
|
1524
1579
|
<div class="simulator-section">
|
|
1525
1580
|
<div class="simulator-section-title">Game Features</div>
|
|
@@ -1560,7 +1615,7 @@ function Ke() {
|
|
|
1560
1615
|
e && (yield d(e));
|
|
1561
1616
|
})), i == null || i.addEventListener("keypress", (e) => {
|
|
1562
1617
|
e.key === "Enter" && (r == null || r.click());
|
|
1563
|
-
}), console.log("[FeaturesView] bind called, ctx.gameSlug:", e.gameSlug, "slugInput:", i), e.gameSlug && i && (i.value = e.gameSlug,
|
|
1618
|
+
}), console.log("[FeaturesView] bind called, ctx.gameSlug:", e.gameSlug, "slugInput:", i), e.gameSlug && i && (i.value = e.gameSlug, Qe() && !n && d(e.gameSlug)), u();
|
|
1564
1619
|
},
|
|
1565
1620
|
onActivate(e) {
|
|
1566
1621
|
let t = e.getElement("#simulator-tab-features");
|
|
@@ -1569,7 +1624,7 @@ function Ke() {
|
|
|
1569
1624
|
};
|
|
1570
1625
|
}
|
|
1571
1626
|
/** Renders a single keyboard key as an HTML button string */
|
|
1572
|
-
var
|
|
1627
|
+
var et = (e, t) => {
|
|
1573
1628
|
var n, r;
|
|
1574
1629
|
let i = (n = t.symbols[e]) == null ? e : n, a = t.disabled.includes(e), o = t.highlight.includes(e), s = t.xl.includes(e), c = t.l.includes(e), l = (r = t.flexGrowSymbols) == null ? void 0 : r.includes(e);
|
|
1575
1630
|
return `<button class="${[
|
|
@@ -1580,9 +1635,9 @@ var qe = (e, t) => {
|
|
|
1580
1635
|
c ? "l" : "",
|
|
1581
1636
|
l ? "grow" : ""
|
|
1582
1637
|
].filter(Boolean).join(" ")}" data-key="${e}" ${a ? "disabled" : ""}>${i}</button>`;
|
|
1583
|
-
},
|
|
1584
|
-
function
|
|
1585
|
-
let e = null, t = () => e ?
|
|
1638
|
+
}, tt = (e) => `<div class="sim-kb">${e.layout.filter((e) => e != null).map((t) => `<div class="sim-kb-row">${[...t].map((t) => et(t, e)).join("")}</div>`).join("")}</div>`;
|
|
1639
|
+
function nt() {
|
|
1640
|
+
let e = null, t = () => e ? tt(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>";
|
|
1586
1641
|
return {
|
|
1587
1642
|
id: "kbd",
|
|
1588
1643
|
label: "Kbd",
|
|
@@ -1596,19 +1651,19 @@ function Ye() {
|
|
|
1596
1651
|
`;
|
|
1597
1652
|
},
|
|
1598
1653
|
bind(e) {
|
|
1599
|
-
|
|
1654
|
+
rt(e);
|
|
1600
1655
|
},
|
|
1601
1656
|
onMessage(n, r, i) {
|
|
1602
1657
|
var a;
|
|
1603
1658
|
if (n !== "KEYBOARD_UPDATE_CONFIG") return;
|
|
1604
1659
|
e = !(!(r == null || (a = r.layout) == null) && a.length) || r.layout.every((e) => !e) ? null : r;
|
|
1605
1660
|
let o = i.getElement("#sim-kb-content");
|
|
1606
|
-
o && (o.innerHTML = t(),
|
|
1661
|
+
o && (o.innerHTML = t(), rt(i)), i.updateBadge("kbd", void 0);
|
|
1607
1662
|
}
|
|
1608
1663
|
};
|
|
1609
1664
|
}
|
|
1610
1665
|
/** Attach click handlers to all rendered keys */
|
|
1611
|
-
function
|
|
1666
|
+
function rt(e) {
|
|
1612
1667
|
var t;
|
|
1613
1668
|
let n = (t = e.getElement("#sim-kb-content")) == null ? void 0 : t.querySelectorAll(".sim-kb-key");
|
|
1614
1669
|
n == null || n.forEach((t) => {
|
|
@@ -1623,15 +1678,15 @@ function Xe(e) {
|
|
|
1623
1678
|
* change values (persisted to localStorage and pushed to the game as SETTINGS_UPDATE, matching the
|
|
1624
1679
|
* production host) and reflects UPDATE_SETTINGS_FROM_EMBED writes coming from the game.
|
|
1625
1680
|
*/
|
|
1626
|
-
function
|
|
1681
|
+
function it() {
|
|
1627
1682
|
let t = (e) => {
|
|
1628
1683
|
let t = e.state.settingsComponents;
|
|
1629
|
-
return !t || t.length === 0 ? "<div class=\"sim-settings-empty\">No settings registered by the game yet.<br>The game calls <code>sdk.settings.initialize(components)</code> to describe its settings UI.</div>" : `<div class="sim-settings-form">${t.map((t) =>
|
|
1684
|
+
return !t || t.length === 0 ? "<div class=\"sim-settings-empty\">No settings registered by the game yet.<br>The game calls <code>sdk.settings.initialize(components)</code> to describe its settings UI.</div>" : `<div class="sim-settings-form">${t.map((t) => at(t, e.state.gameSettings)).join("")}</div><div class="sim-settings-actions"><button class="simulator-btn tiny" id="sim-settings-reset">Reset to defaults</button></div>`;
|
|
1630
1685
|
}, n = (e) => {
|
|
1631
1686
|
let n = e.getElement("#sim-settings-content");
|
|
1632
1687
|
n && (n.innerHTML = t(e), i(e));
|
|
1633
1688
|
}, r = (e) => {
|
|
1634
|
-
|
|
1689
|
+
h(e.state.gameSettings), e.sendToGame("SETTINGS_UPDATE", e.state.gameSettings);
|
|
1635
1690
|
}, i = (t) => {
|
|
1636
1691
|
var i;
|
|
1637
1692
|
let a = t.getElement("#sim-settings-content");
|
|
@@ -1647,7 +1702,7 @@ function Ze() {
|
|
|
1647
1702
|
});
|
|
1648
1703
|
}), (i = a.querySelector("#sim-settings-reset")) == null || i.addEventListener("click", () => {
|
|
1649
1704
|
var e;
|
|
1650
|
-
|
|
1705
|
+
g(), t.state.gameSettings = ot((e = t.state.settingsComponents) == null ? [] : e), r(t), n(t);
|
|
1651
1706
|
}));
|
|
1652
1707
|
};
|
|
1653
1708
|
return {
|
|
@@ -1662,21 +1717,21 @@ function Ze() {
|
|
|
1662
1717
|
onMessage(t, r, i) {
|
|
1663
1718
|
if (t === "INITIALIZE_SETTINGS") {
|
|
1664
1719
|
var a;
|
|
1665
|
-
i.state.settingsComponents = (a = r == null ? void 0 : r.components) == null ? [] : a, i.state.gameSettings = e(e({}, r == null ? void 0 : r.settings), i.state.gameSettings),
|
|
1720
|
+
i.state.settingsComponents = (a = r == null ? void 0 : r.components) == null ? [] : a, i.state.gameSettings = e(e({}, r == null ? void 0 : r.settings), i.state.gameSettings), h(i.state.gameSettings), n(i);
|
|
1666
1721
|
return;
|
|
1667
1722
|
}
|
|
1668
|
-
t === "UPDATE_SETTINGS_FROM_EMBED" && (i.state.gameSettings = e(e({}, i.state.gameSettings), r == null ? void 0 : r.settings),
|
|
1723
|
+
t === "UPDATE_SETTINGS_FROM_EMBED" && (i.state.gameSettings = e(e({}, i.state.gameSettings), r == null ? void 0 : r.settings), h(i.state.gameSettings), n(i));
|
|
1669
1724
|
}
|
|
1670
1725
|
};
|
|
1671
1726
|
}
|
|
1672
1727
|
/** Renders a single settings UI component as HTML, reading its current value from `settings` */
|
|
1673
|
-
function
|
|
1728
|
+
function at(e, t) {
|
|
1674
1729
|
switch (e.type) {
|
|
1675
1730
|
case "title": return `<div class="sim-settings-heading">${Q(e.value)}</div>`;
|
|
1676
1731
|
case "subtitle": return `<div class="sim-settings-subheading">${Q(e.value)}</div>`;
|
|
1677
1732
|
case "paragraph": return `<p class="sim-settings-paragraph">${Q(e.value)}</p>`;
|
|
1678
1733
|
case "separator": return "<div class=\"simulator-divider\"></div>";
|
|
1679
|
-
case "split": return `<div class="sim-settings-split">${e.content.map((e) =>
|
|
1734
|
+
case "split": return `<div class="sim-settings-split">${e.content.map((e) => at(e, t)).join("")}</div>`;
|
|
1680
1735
|
case "boolean": {
|
|
1681
1736
|
var n;
|
|
1682
1737
|
let r = ((n = t[e.name]) == null ? e.defaultValue : n) ? "checked" : "", i = e.subtitle ? `<div class="sim-settings-subtitle">${Q(e.subtitle)}</div>` : "";
|
|
@@ -1744,9 +1799,9 @@ function Z(e) {
|
|
|
1744
1799
|
return `<span class="simulator-label">${Q(e.title)}</span>${t}`;
|
|
1745
1800
|
}
|
|
1746
1801
|
/** Collects name → defaultValue pairs from components, recursing into split groups */
|
|
1747
|
-
function
|
|
1802
|
+
function ot(e) {
|
|
1748
1803
|
let t = {};
|
|
1749
|
-
for (let n of e) n.type === "split" ? Object.assign(t,
|
|
1804
|
+
for (let n of e) n.type === "split" ? Object.assign(t, ot(n.content)) : "name" in n && (t[n.name] = n.defaultValue);
|
|
1750
1805
|
return t;
|
|
1751
1806
|
}
|
|
1752
1807
|
function Q(e) {
|
|
@@ -1790,27 +1845,27 @@ var $ = null;
|
|
|
1790
1845
|
* Fixtures are loaded as raw strings and passed to the game verbatim (any text format works; the game parses it).
|
|
1791
1846
|
* This will show dropdowns in the Ctrl tab to select category and puzzle.
|
|
1792
1847
|
*/
|
|
1793
|
-
function
|
|
1848
|
+
function st(e = {}) {
|
|
1794
1849
|
var n, r, i;
|
|
1795
1850
|
if (console.log("[Simulator] createSimulator called with config:", {
|
|
1796
1851
|
slug: e.slug,
|
|
1797
1852
|
hasFixtures: !!e.fixtures
|
|
1798
1853
|
}), $) return e.fixtures && (console.log("[Simulator] Instance already exists, updating fixtures"), $.updateFixtures(e.fixtures)), $;
|
|
1799
|
-
let a = (n = e.autoStart) == null ? !0 : n, o = e.fixtures ? oe(e.fixtures) : null, s = o ? Array.from(o.keys()).sort() : [], c = le(), l =
|
|
1854
|
+
let a = (n = e.autoStart) == null ? !0 : n, o = e.fixtures ? oe(e.fixtures) : null, s = o ? Array.from(o.keys()).sort() : [], c = le(), l = ve(), u = [
|
|
1800
1855
|
se(),
|
|
1801
1856
|
ce(),
|
|
1802
1857
|
c,
|
|
1803
1858
|
ue(),
|
|
1804
1859
|
de(),
|
|
1805
1860
|
l,
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1861
|
+
be(),
|
|
1862
|
+
Se(e.hostContextPresets),
|
|
1863
|
+
Le(),
|
|
1864
|
+
$e(),
|
|
1865
|
+
nt(),
|
|
1866
|
+
it(),
|
|
1812
1867
|
...(r = e.views) == null ? [] : r
|
|
1813
|
-
], d = u.map((e) => e.id), f =
|
|
1868
|
+
], d = u.map((e) => e.id), f = m(e, s, d), p = {
|
|
1814
1869
|
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>",
|
|
1815
1870
|
play: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><polygon points=\"2,1 9,5 2,9\"/></svg>",
|
|
1816
1871
|
retry: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><path d=\"M5 1C2.8 1 1 2.8 1 5s1.8 4 4 4c1.8 0 3.3-1.2 3.8-2.8H7.5c-.4.9-1.3 1.5-2.5 1.5-1.5 0-2.7-1.2-2.7-2.7S3.5 2.3 5 2.3c.7 0 1.4.3 1.9.8L5.5 4.5H9V1L7.6 2.4C6.9 1.5 5.9 1 5 1z\"/></svg>",
|
|
@@ -2326,6 +2381,74 @@ function et(e = {}) {
|
|
|
2326
2381
|
text-align: center;
|
|
2327
2382
|
padding: 20px;
|
|
2328
2383
|
}
|
|
2384
|
+
.simulator-share-preview {
|
|
2385
|
+
margin: 0;
|
|
2386
|
+
padding: 8px;
|
|
2387
|
+
text-align: left;
|
|
2388
|
+
font-size: 13px;
|
|
2389
|
+
line-height: 1.45;
|
|
2390
|
+
white-space: pre-wrap;
|
|
2391
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
2392
|
+
}
|
|
2393
|
+
.simulator-segmented {
|
|
2394
|
+
display: flex;
|
|
2395
|
+
gap: 2px;
|
|
2396
|
+
padding: 2px;
|
|
2397
|
+
background: var(--sim-bg);
|
|
2398
|
+
border: 2px solid var(--sim-border);
|
|
2399
|
+
border-radius: 2px;
|
|
2400
|
+
margin-bottom: 6px;
|
|
2401
|
+
}
|
|
2402
|
+
.simulator-segmented-btn {
|
|
2403
|
+
flex: 1;
|
|
2404
|
+
padding: 4px 8px;
|
|
2405
|
+
background: transparent;
|
|
2406
|
+
border: 0;
|
|
2407
|
+
border-radius: 2px;
|
|
2408
|
+
color: var(--sim-text-dim);
|
|
2409
|
+
font: inherit;
|
|
2410
|
+
font-size: 10px;
|
|
2411
|
+
font-weight: bold;
|
|
2412
|
+
text-transform: uppercase;
|
|
2413
|
+
letter-spacing: 1px;
|
|
2414
|
+
cursor: pointer;
|
|
2415
|
+
}
|
|
2416
|
+
.simulator-segmented-btn:hover:not(.active) {
|
|
2417
|
+
color: var(--sim-text);
|
|
2418
|
+
}
|
|
2419
|
+
.simulator-segmented-btn.active {
|
|
2420
|
+
background: var(--sim-border);
|
|
2421
|
+
color: var(--sim-text);
|
|
2422
|
+
}
|
|
2423
|
+
.simulator-share-missing {
|
|
2424
|
+
color: var(--sim-text-dim);
|
|
2425
|
+
font-size: 11px;
|
|
2426
|
+
padding: 12px;
|
|
2427
|
+
line-height: 1.4;
|
|
2428
|
+
}
|
|
2429
|
+
.simulator-share-missing p {
|
|
2430
|
+
margin: 0 0 6px;
|
|
2431
|
+
}
|
|
2432
|
+
.simulator-share-missing code {
|
|
2433
|
+
color: var(--sim-text);
|
|
2434
|
+
background: var(--sim-bg);
|
|
2435
|
+
padding: 1px 4px;
|
|
2436
|
+
border-radius: 2px;
|
|
2437
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
2438
|
+
}
|
|
2439
|
+
.simulator-share-missing pre {
|
|
2440
|
+
margin: 6px 0 0;
|
|
2441
|
+
padding: 8px;
|
|
2442
|
+
background: var(--sim-bg);
|
|
2443
|
+
border: 1px solid var(--sim-border);
|
|
2444
|
+
border-radius: 2px;
|
|
2445
|
+
color: var(--sim-text);
|
|
2446
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
2447
|
+
font-size: 10.5px;
|
|
2448
|
+
line-height: 1.45;
|
|
2449
|
+
white-space: pre-wrap;
|
|
2450
|
+
overflow-x: auto;
|
|
2451
|
+
}
|
|
2329
2452
|
.simulator-value {
|
|
2330
2453
|
color: var(--sim-text);
|
|
2331
2454
|
font-size: 10px;
|
|
@@ -3062,8 +3185,8 @@ function et(e = {}) {
|
|
|
3062
3185
|
<div id="simulator-timer">--:--</div>
|
|
3063
3186
|
<span class="header-sep">|</span>
|
|
3064
3187
|
<div id="simulator-header-controls">
|
|
3065
|
-
<button id="simulator-header-pause" class="header-icon-btn" title="Pause" disabled>${
|
|
3066
|
-
<button id="simulator-header-retry" class="header-icon-btn" title="Retry" disabled>${
|
|
3188
|
+
<button id="simulator-header-pause" class="header-icon-btn" title="Pause" disabled>${p.pause}</button>
|
|
3189
|
+
<button id="simulator-header-retry" class="header-icon-btn" title="Retry" disabled>${p.retry}</button>
|
|
3067
3190
|
</div>
|
|
3068
3191
|
<span class="header-sep">|</span>
|
|
3069
3192
|
<div id="simulator-header-status">
|
|
@@ -3071,8 +3194,8 @@ function et(e = {}) {
|
|
|
3071
3194
|
<span id="simulator-header-status-text">Waiting...</span>
|
|
3072
3195
|
</div>
|
|
3073
3196
|
<span class="header-spacer"></span>
|
|
3074
|
-
<button id="simulator-header-settings" class="header-icon-btn" title="Settings">${
|
|
3075
|
-
<button id="simulator-toggle" class="header-icon-btn" title="Minimize">${
|
|
3197
|
+
<button id="simulator-header-settings" class="header-icon-btn" title="Settings">${p.cog}</button>
|
|
3198
|
+
<button id="simulator-toggle" class="header-icon-btn" title="Minimize">${p.minimize}</button>
|
|
3076
3199
|
</div>
|
|
3077
3200
|
<div id="simulator-body">
|
|
3078
3201
|
<div id="simulator-tabs">
|
|
@@ -3084,8 +3207,8 @@ function et(e = {}) {
|
|
|
3084
3207
|
</div>
|
|
3085
3208
|
</div>
|
|
3086
3209
|
`, document.body.appendChild(h);
|
|
3087
|
-
let
|
|
3088
|
-
y.innerHTML = e ?
|
|
3210
|
+
let g = h.querySelector("#simulator-panel"), te = h.querySelector("#simulator-header"), v = h.querySelector("#simulator-header-indicator"), ne = h.querySelector("#simulator-header-status-text"), y = h.querySelector("#simulator-header-pause"), b = h.querySelector("#simulator-header-retry"), x = h.querySelector("#simulator-header-settings"), S = h.querySelector("#simulator-toggle"), C = h.querySelector("#simulator-timer"), w = h.querySelector("#simulator-tabs"), T = h.querySelector("#simulator-content"), E = (e) => h.querySelector(e), D = (e) => {
|
|
3211
|
+
y.innerHTML = e ? p.play : p.pause, y.title = e ? "Resume" : "Pause";
|
|
3089
3212
|
}, O = (e, t) => {
|
|
3090
3213
|
let n = E("#simulator-status .text"), r = E("#simulator-status .indicator"), i = t === "complete" ? "✓" : "";
|
|
3091
3214
|
n && (n.textContent = e), r && (r.className = `indicator ${t}`, r.textContent = i), v.className = t, v.textContent = i, ne.textContent = e;
|
|
@@ -3101,7 +3224,7 @@ function et(e = {}) {
|
|
|
3101
3224
|
let n = u.find((t) => t.id === e);
|
|
3102
3225
|
n == null || (t = n.onActivate) == null || t.call(n, L);
|
|
3103
3226
|
}, j = (e) => {
|
|
3104
|
-
f.isCollapsed = e,
|
|
3227
|
+
f.isCollapsed = e, g.classList.toggle("collapsed", e), _(e), e ? (T.classList.add("hidden"), w.querySelectorAll(".simulator-tab").forEach((e) => e.classList.remove("active"))) : A(f.activeTab);
|
|
3105
3228
|
}, M = () => {
|
|
3106
3229
|
l.updatePreview(L);
|
|
3107
3230
|
}, N = function() {
|
|
@@ -3163,12 +3286,12 @@ function et(e = {}) {
|
|
|
3163
3286
|
t && (t.disabled = !0, t.textContent = "Pause"), n && (n.textContent = "Start");
|
|
3164
3287
|
}), x.addEventListener("click", (e) => {
|
|
3165
3288
|
e.stopPropagation(), f.isCollapsed && j(!1), A("auth");
|
|
3166
|
-
}),
|
|
3289
|
+
}), te.addEventListener("click", (e) => {
|
|
3167
3290
|
f.isCollapsed && e.target !== S && j(!1);
|
|
3168
3291
|
}), f.isCollapsed || A(f.activeTab);
|
|
3169
3292
|
let R = new URLSearchParams(window.location.search);
|
|
3170
3293
|
(R.has("code") || R.has("error")) && (j(!1), A("auth"));
|
|
3171
|
-
let
|
|
3294
|
+
let fe = (e) => ({
|
|
3172
3295
|
userState: {
|
|
3173
3296
|
gameSettings: f.gameSettings,
|
|
3174
3297
|
id: "simulator-user",
|
|
@@ -3210,11 +3333,11 @@ function et(e = {}) {
|
|
|
3210
3333
|
theme: f.selectedTheme,
|
|
3211
3334
|
hostContext: f.hostContext,
|
|
3212
3335
|
appRuntimeContract: "1.0"
|
|
3213
|
-
}),
|
|
3336
|
+
}), pe = function() {
|
|
3214
3337
|
var e = t(function* () {
|
|
3215
3338
|
O("Loading puzzle...", "waiting");
|
|
3216
3339
|
try {
|
|
3217
|
-
let e =
|
|
3340
|
+
let e = fe(yield N());
|
|
3218
3341
|
O("Sending READY_DATA...", "waiting"), F("READY_DATA", e), O("Waiting for game to load...", "waiting");
|
|
3219
3342
|
} catch (e) {
|
|
3220
3343
|
O(`Error: ${e}`, "paused");
|
|
@@ -3223,7 +3346,7 @@ function et(e = {}) {
|
|
|
3223
3346
|
return function() {
|
|
3224
3347
|
return e.apply(this, arguments);
|
|
3225
3348
|
};
|
|
3226
|
-
}(),
|
|
3349
|
+
}(), me = () => {
|
|
3227
3350
|
console.log("Simulator: Game loaded, ready to start"), b.disabled = !1, u.forEach((e) => {
|
|
3228
3351
|
var t;
|
|
3229
3352
|
return (t = e.onMessage) == null ? void 0 : t.call(e, "READY_GAME_LOADED", void 0, L);
|
|
@@ -3235,11 +3358,11 @@ function et(e = {}) {
|
|
|
3235
3358
|
return ae((e, t) => {
|
|
3236
3359
|
var n, r;
|
|
3237
3360
|
if (e === "READY") {
|
|
3238
|
-
console.log("Simulator: Received READY from game"),
|
|
3361
|
+
console.log("Simulator: Received READY from game"), pe();
|
|
3239
3362
|
return;
|
|
3240
3363
|
}
|
|
3241
3364
|
if (e === "READY_GAME_LOADED") {
|
|
3242
|
-
|
|
3365
|
+
me();
|
|
3243
3366
|
return;
|
|
3244
3367
|
}
|
|
3245
3368
|
if (e === "TIMER_TICK") {
|
|
@@ -3278,6 +3401,6 @@ function et(e = {}) {
|
|
|
3278
3401
|
loadPuzzle: N
|
|
3279
3402
|
}, $;
|
|
3280
3403
|
}
|
|
3281
|
-
export {
|
|
3404
|
+
export { st as t };
|
|
3282
3405
|
|
|
3283
|
-
//# sourceMappingURL=createSimulator-
|
|
3406
|
+
//# sourceMappingURL=createSimulator-BuPYG4eZ.js.map
|