@puzzmo/sdk 1.0.33 → 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/README.md +3 -3
- package/dist/{createSimulator-Bo6J_KC_.js → createSimulator-BuPYG4eZ.js} +364 -201
- package/dist/createSimulator-BuPYG4eZ.js.map +1 -0
- package/dist/{createSimulator-EBKHk3L6.cjs → createSimulator-DDHvAKZy.cjs} +114 -34
- package/dist/createSimulator-DDHvAKZy.cjs.map +1 -0
- package/dist/fonts.cjs +2 -2
- package/dist/fonts.cjs.map +1 -1
- package/dist/fonts.d.ts +2 -0
- package/dist/fonts.d.ts.map +1 -1
- package/dist/fonts.js +8 -6
- package/dist/fonts.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/simulator/index.cjs +1 -1
- package/dist/simulator/index.js +1 -1
- package/dist/simulator/normalizeThumbnail.d.ts +11 -0
- package/dist/simulator/normalizeThumbnail.d.ts.map +1 -0
- 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/DataView.d.ts.map +1 -1
- package/dist/simulator/views/ThumbView.d.ts.map +1 -1
- package/dist/types.d.ts +8 -2
- 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 +3 -2
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +4 -3
- package/dist/vite.js.map +1 -1
- package/package.json +1 -1
- package/dist/createSimulator-Bo6J_KC_.js.map +0 -1
- package/dist/createSimulator-EBKHk3L6.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
|
}
|
|
@@ -570,9 +578,49 @@ function se() {
|
|
|
570
578
|
}
|
|
571
579
|
};
|
|
572
580
|
}
|
|
573
|
-
|
|
581
|
+
/**
|
|
582
|
+
* Coerces a thumbnail render result into a `ThumbnailResult`. New game bundles return the object
|
|
583
|
+
* directly; bundles still built against the old `renderThumbnail(): string` contract return a bare
|
|
584
|
+
* SVG string, so we parse the dimensions out of it (falling back to a square).
|
|
585
|
+
*
|
|
586
|
+
* Inlined here (rather than shared with the rest of the monorepo) because the SDK ships to OSS and
|
|
587
|
+
* must stay self-contained.
|
|
588
|
+
*/
|
|
589
|
+
function E(e) {
|
|
590
|
+
var t;
|
|
591
|
+
if (typeof e != "string") return e;
|
|
592
|
+
let n = (t = D(e)) == null ? {
|
|
593
|
+
width: 800,
|
|
594
|
+
height: 800
|
|
595
|
+
} : t;
|
|
596
|
+
return {
|
|
597
|
+
svg: e,
|
|
598
|
+
width: n.width,
|
|
599
|
+
height: n.height
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
/** Reads an SVG's intrinsic size from its `viewBox` (preferred) or its `width`/`height` attributes. */
|
|
603
|
+
function D(e) {
|
|
604
|
+
var t, n, r, i;
|
|
605
|
+
let a = e.indexOf("<svg");
|
|
606
|
+
if (a === -1) return;
|
|
607
|
+
let o = e.indexOf(">", a), s = o === -1 ? e.slice(a) : e.slice(a, o + 1), c = /viewBox\s*=\s*["']\s*[-\d.]+[\s,]+[-\d.]+[\s,]+([\d.]+)[\s,]+([\d.]+)/i.exec(s);
|
|
608
|
+
if (c) {
|
|
609
|
+
let e = parseFloat(c[1]), t = parseFloat(c[2]);
|
|
610
|
+
if (e > 0 && t > 0) return {
|
|
611
|
+
width: e,
|
|
612
|
+
height: t
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
let l = parseFloat((t = (n = /\bwidth\s*=\s*["']\s*([\d.]+)(?:px)?\s*["']/i.exec(s)) == null ? void 0 : n[1]) == null ? "" : t), u = parseFloat((r = (i = /\bheight\s*=\s*["']\s*([\d.]+)(?:px)?\s*["']/i.exec(s)) == null ? void 0 : i[1]) == null ? "" : r);
|
|
616
|
+
if (l > 0 && u > 0) return {
|
|
617
|
+
width: l,
|
|
618
|
+
height: u
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
var O = "simulator-saved-states";
|
|
574
622
|
/** Find thumbnail function on globalThis (looks for functions ending in "Thumbnail") */
|
|
575
|
-
function
|
|
623
|
+
function k() {
|
|
576
624
|
let e = globalThis;
|
|
577
625
|
for (let t of Object.keys(e)) if (t.endsWith("Thumbnail") && typeof e[t] == "function") return {
|
|
578
626
|
name: t,
|
|
@@ -581,8 +629,8 @@ function T() {
|
|
|
581
629
|
return null;
|
|
582
630
|
}
|
|
583
631
|
/** Generate a small thumbnail SVG for a given input string */
|
|
584
|
-
function
|
|
585
|
-
let n =
|
|
632
|
+
function A(e, t) {
|
|
633
|
+
let n = k();
|
|
586
634
|
if (!n) return "";
|
|
587
635
|
try {
|
|
588
636
|
var r;
|
|
@@ -592,13 +640,13 @@ function E(e, t) {
|
|
|
592
640
|
strict: !0,
|
|
593
641
|
renderHost: "game"
|
|
594
642
|
};
|
|
595
|
-
return n.fn(i, t, a);
|
|
643
|
+
return E(n.fn(i, t, a)).svg;
|
|
596
644
|
} catch (e) {
|
|
597
645
|
return "";
|
|
598
646
|
}
|
|
599
647
|
}
|
|
600
|
-
var
|
|
601
|
-
function
|
|
648
|
+
var j = [];
|
|
649
|
+
function M(e, t = 8) {
|
|
602
650
|
let n = 14 * t + 8 + 4;
|
|
603
651
|
e.style.height = "auto";
|
|
604
652
|
let r = Math.min(Math.max(e.scrollHeight, 40), n);
|
|
@@ -622,102 +670,102 @@ function ce() {
|
|
|
622
670
|
let i = n.getElement(".data-view-container");
|
|
623
671
|
i == null || i.querySelectorAll(".data-subtab-content").forEach((e) => {
|
|
624
672
|
e.classList.toggle("active", e.id === `data-subtab-${t}`);
|
|
625
|
-
}), t === "edit" ?
|
|
673
|
+
}), t === "edit" ? L(n) : t === "history" ? P(n) : t === "saves" && F(n);
|
|
626
674
|
});
|
|
627
675
|
});
|
|
628
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");
|
|
629
677
|
setTimeout(() => {
|
|
630
|
-
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));
|
|
631
679
|
}, 0), i == null || i.addEventListener("input", () => {
|
|
632
|
-
|
|
680
|
+
M(i);
|
|
633
681
|
let t = i.value !== e;
|
|
634
682
|
s && (s.disabled = !t);
|
|
635
683
|
}), a == null || a.addEventListener("input", () => {
|
|
636
|
-
|
|
684
|
+
M(a);
|
|
637
685
|
let e = a.value !== t;
|
|
638
686
|
l && (l.disabled = !e);
|
|
639
687
|
}), o == null || o.addEventListener("click", () => {
|
|
640
|
-
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));
|
|
641
689
|
}), s == null || s.addEventListener("click", () => {
|
|
642
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);
|
|
643
691
|
}), c == null || c.addEventListener("click", () => {
|
|
644
|
-
a && (a.value = t,
|
|
692
|
+
a && (a.value = t, M(a), l && (l.disabled = !0));
|
|
645
693
|
}), l == null || l.addEventListener("click", () => {
|
|
646
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);
|
|
647
695
|
});
|
|
648
696
|
let f = n.getElement("#simulator-history-clear");
|
|
649
697
|
f == null || f.addEventListener("click", () => {
|
|
650
|
-
|
|
698
|
+
j = [], P(n);
|
|
651
699
|
});
|
|
652
700
|
let p = n.getElement("#simulator-save-name"), m = n.getElement("#simulator-save-btn");
|
|
653
701
|
m == null || m.addEventListener("click", () => {
|
|
654
702
|
if (!p || !p.value.trim()) return;
|
|
655
|
-
let e =
|
|
703
|
+
let e = N(), t = {
|
|
656
704
|
name: p.value.trim(),
|
|
657
705
|
puzzleStr: n.state.originalPuzzle,
|
|
658
706
|
inputStr: n.state.currentInputStr,
|
|
659
707
|
timestamp: Date.now()
|
|
660
708
|
};
|
|
661
|
-
e.push(t), localStorage.setItem(
|
|
662
|
-
}),
|
|
709
|
+
e.push(t), localStorage.setItem(O, JSON.stringify(e)), p.value = "", F(n);
|
|
710
|
+
}), F(n);
|
|
663
711
|
},
|
|
664
712
|
onActivate(n) {
|
|
665
|
-
e = n.state.originalPuzzle, t = n.state.currentInputStr,
|
|
713
|
+
e = n.state.originalPuzzle, t = n.state.currentInputStr, L(n), P(n);
|
|
666
714
|
},
|
|
667
715
|
onMessage(e, n, r) {
|
|
668
716
|
var i, a;
|
|
669
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;
|
|
670
718
|
if (e === "UPLOAD_NEW_GAME_STATE" && c) {
|
|
671
|
-
if (r.state.currentInputStr = c,
|
|
672
|
-
|
|
719
|
+
if (r.state.currentInputStr = c, j.length === 0 || j[j.length - 1].value !== c) {
|
|
720
|
+
j.push({
|
|
673
721
|
value: c,
|
|
674
722
|
timestamp: Date.now()
|
|
675
|
-
}),
|
|
723
|
+
}), j.length > 100 && (j = j.slice(-100));
|
|
676
724
|
let e = r.getElement("#data-subtab-history");
|
|
677
|
-
e != null && e.classList.contains("active") &&
|
|
725
|
+
e != null && e.classList.contains("active") && P(r);
|
|
678
726
|
}
|
|
679
|
-
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));
|
|
680
728
|
}
|
|
681
729
|
}
|
|
682
730
|
};
|
|
683
731
|
}
|
|
684
|
-
function
|
|
732
|
+
function N() {
|
|
685
733
|
try {
|
|
686
|
-
let e = localStorage.getItem(
|
|
734
|
+
let e = localStorage.getItem(O);
|
|
687
735
|
return e ? JSON.parse(e) : [];
|
|
688
736
|
} catch (e) {
|
|
689
737
|
return [];
|
|
690
738
|
}
|
|
691
739
|
}
|
|
692
|
-
function
|
|
740
|
+
function P(e) {
|
|
693
741
|
let t = e.getElement("#simulator-history-list");
|
|
694
742
|
if (t) {
|
|
695
|
-
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) {
|
|
696
744
|
t.innerHTML = "<div class=\"simulator-empty\">No history yet</div>";
|
|
697
745
|
return;
|
|
698
746
|
}
|
|
699
|
-
t.innerHTML = [...
|
|
700
|
-
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;
|
|
701
749
|
return `
|
|
702
750
|
<div class="history-item" data-history-idx="${r}">
|
|
703
|
-
<div class="history-item-thumb">${
|
|
751
|
+
<div class="history-item-thumb">${A(e, t.value)}</div>
|
|
704
752
|
<div class="history-item-content">
|
|
705
753
|
<div class="history-item-header">
|
|
706
754
|
<span class="history-item-num">#${r + 1}</span>
|
|
707
755
|
<span class="history-item-time">${i}</span>
|
|
708
756
|
<button class="simulator-btn tiny history-restore-btn" data-history-idx="${r}">Restore</button>
|
|
709
757
|
</div>
|
|
710
|
-
<div class="history-item-preview">${
|
|
758
|
+
<div class="history-item-preview">${I(a)}</div>
|
|
711
759
|
</div>
|
|
712
760
|
</div>
|
|
713
761
|
`;
|
|
714
762
|
}).join(""), t.querySelectorAll(".history-restore-btn").forEach((t) => {
|
|
715
763
|
t.addEventListener("click", (t) => {
|
|
716
|
-
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];
|
|
717
765
|
if (r) {
|
|
718
766
|
e.state.currentInputStr = r.value;
|
|
719
767
|
let t = e.getElement("#simulator-input");
|
|
720
|
-
t && (t.value = r.value,
|
|
768
|
+
t && (t.value = r.value, M(t)), e.updateStatus("Input restored from history", "ready");
|
|
721
769
|
let n = e.getElement(".data-subtab[data-subtab=\"edit\"]");
|
|
722
770
|
n == null || n.click();
|
|
723
771
|
}
|
|
@@ -725,10 +773,10 @@ function A(e) {
|
|
|
725
773
|
});
|
|
726
774
|
}
|
|
727
775
|
}
|
|
728
|
-
function
|
|
776
|
+
function F(e) {
|
|
729
777
|
let t = e.getElement("#simulator-saves-list");
|
|
730
778
|
if (!t) return;
|
|
731
|
-
let n =
|
|
779
|
+
let n = N();
|
|
732
780
|
if (n.length === 0) {
|
|
733
781
|
t.innerHTML = "<div class=\"simulator-empty\">No saved states</div>";
|
|
734
782
|
return;
|
|
@@ -738,7 +786,7 @@ function j(e) {
|
|
|
738
786
|
return `
|
|
739
787
|
<div class="save-item">
|
|
740
788
|
<div class="save-item-header">
|
|
741
|
-
<span class="save-item-name">${
|
|
789
|
+
<span class="save-item-name">${I(e.name)}</span>
|
|
742
790
|
<span class="save-item-time">${i} ${a}</span>
|
|
743
791
|
</div>
|
|
744
792
|
<div class="save-item-actions">
|
|
@@ -753,7 +801,7 @@ function j(e) {
|
|
|
753
801
|
if (r) {
|
|
754
802
|
e.state.puzzleData = r.puzzleStr, e.state.originalPuzzle = r.puzzleStr, e.state.currentInputStr = r.inputStr;
|
|
755
803
|
let t = e.getElement("#simulator-puzzle"), n = e.getElement("#simulator-input");
|
|
756
|
-
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");
|
|
757
805
|
let i = e.getElement(".data-subtab[data-subtab=\"edit\"]");
|
|
758
806
|
i == null || i.click();
|
|
759
807
|
}
|
|
@@ -761,18 +809,18 @@ function j(e) {
|
|
|
761
809
|
}), t.querySelectorAll(".save-delete-btn").forEach((t) => {
|
|
762
810
|
t.addEventListener("click", (t) => {
|
|
763
811
|
let r = parseInt(t.target.getAttribute("data-save-idx") || "0"), i = n.filter((e, t) => t !== r);
|
|
764
|
-
localStorage.setItem(
|
|
812
|
+
localStorage.setItem(O, JSON.stringify(i)), F(e);
|
|
765
813
|
});
|
|
766
814
|
});
|
|
767
815
|
}
|
|
768
|
-
function
|
|
816
|
+
function I(e) {
|
|
769
817
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
770
818
|
}
|
|
771
|
-
function
|
|
819
|
+
function L(e) {
|
|
772
820
|
let t = e.getElement("#simulator-puzzle"), n = e.getElement("#simulator-input"), r = e.getElement("#simulator-puzzle-apply"), i = e.getElement("#simulator-input-apply");
|
|
773
|
-
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));
|
|
774
822
|
}
|
|
775
|
-
function
|
|
823
|
+
function R(e) {
|
|
776
824
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
777
825
|
}
|
|
778
826
|
function le() {
|
|
@@ -802,7 +850,7 @@ function le() {
|
|
|
802
850
|
<span class="simulator-msg-type">${t.direction === "out" ? "→" : "←"} ${t.type}</span>
|
|
803
851
|
<span class="simulator-msg-time">${t.time}</span>
|
|
804
852
|
</div>
|
|
805
|
-
${a ? `<div class="simulator-msg-data">${
|
|
853
|
+
${a ? `<div class="simulator-msg-data">${R(a)}</div>` : ""}
|
|
806
854
|
`;
|
|
807
855
|
let o = i.querySelector(".simulator-msg-data");
|
|
808
856
|
for (o && o.addEventListener("click", () => {
|
|
@@ -901,7 +949,7 @@ function de() {
|
|
|
901
949
|
};
|
|
902
950
|
}
|
|
903
951
|
/** Find thumbnail function on globalThis (looks for functions ending in "Thumbnail") */
|
|
904
|
-
function
|
|
952
|
+
function fe() {
|
|
905
953
|
let e = globalThis;
|
|
906
954
|
for (let t of Object.keys(e)) if (t.endsWith("Thumbnail") && typeof e[t] == "function") return {
|
|
907
955
|
name: t,
|
|
@@ -909,47 +957,94 @@ function F() {
|
|
|
909
957
|
};
|
|
910
958
|
return null;
|
|
911
959
|
}
|
|
912
|
-
|
|
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() {
|
|
913
978
|
return {
|
|
914
979
|
id: "thumb",
|
|
915
980
|
label: "Thumb",
|
|
916
981
|
render() {
|
|
917
|
-
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 ";
|
|
918
983
|
},
|
|
919
984
|
bind(e) {
|
|
920
985
|
let t = e.getElement("#simulator-thumb-refresh");
|
|
921
986
|
t == null || t.addEventListener("click", () => e.updateThumbnail());
|
|
922
|
-
let n = e.getElement("#simulator-render-host-select"), r = e.getElement("#simulator-render-context-select"), i = e.getElement("#simulator-render-
|
|
923
|
-
|
|
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
|
+
});
|
|
924
995
|
};
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
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();
|
|
930
1006
|
},
|
|
931
1007
|
onActivate(e) {
|
|
932
1008
|
setTimeout(() => e.updateThumbnail(), 0);
|
|
933
1009
|
},
|
|
934
1010
|
updatePreview: (e) => {
|
|
935
1011
|
let t = e.getElement("#simulator-thumb-preview"), n = e.getElement("#simulator-thumb-fn");
|
|
936
|
-
t == null || t.style.setProperty("--sim-thumb-bg", e.state.selectedTheme.g_bg)
|
|
937
|
-
|
|
938
|
-
|
|
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) {
|
|
939
1034
|
t && (t.innerHTML = "<span class=\"simulator-empty\">No thumbnail function found</span>"), n && (n.textContent = "");
|
|
940
1035
|
return;
|
|
941
1036
|
}
|
|
942
|
-
n && (n.textContent = `Using: ${
|
|
1037
|
+
n && (n.textContent = `Using: ${s.name}()`);
|
|
943
1038
|
try {
|
|
944
|
-
var
|
|
945
|
-
let n = (
|
|
1039
|
+
var c;
|
|
1040
|
+
let n = (c = e.state.puzzleData) == null ? "" : c, r = {
|
|
946
1041
|
viewerIsOwner: !0,
|
|
947
1042
|
theme: e.state.selectedTheme,
|
|
948
1043
|
strict: !0,
|
|
949
1044
|
renderHost: e.state.renderHost,
|
|
950
1045
|
renderContext: e.state.renderContext
|
|
951
|
-
},
|
|
952
|
-
t && (t.innerHTML =
|
|
1046
|
+
}, { svg: i } = E(s.fn(n, e.state.currentInputStr, r));
|
|
1047
|
+
t && (t.innerHTML = i);
|
|
953
1048
|
} catch (e) {
|
|
954
1049
|
console.error("Simulator: Thumbnail error", e), t && (t.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
|
|
955
1050
|
}
|
|
@@ -957,7 +1052,7 @@ function fe() {
|
|
|
957
1052
|
};
|
|
958
1053
|
}
|
|
959
1054
|
/** Generate theme preview HTML showing key colors */
|
|
960
|
-
function
|
|
1055
|
+
function ye(e) {
|
|
961
1056
|
let t = [
|
|
962
1057
|
e.key,
|
|
963
1058
|
e.subBrand,
|
|
@@ -968,7 +1063,7 @@ function I(e) {
|
|
|
968
1063
|
].map((e) => `<div class="simulator-theme-preview-cell" style="background: ${e}"></div>`).join("");
|
|
969
1064
|
return `<div class="simulator-theme-preview" style="background: ${e.g_bg}">${t}</div>`;
|
|
970
1065
|
}
|
|
971
|
-
function
|
|
1066
|
+
function be() {
|
|
972
1067
|
return {
|
|
973
1068
|
id: "theme",
|
|
974
1069
|
label: "Theme",
|
|
@@ -980,7 +1075,7 @@ function pe() {
|
|
|
980
1075
|
t && n.forEach((n) => {
|
|
981
1076
|
let r = document.createElement("div");
|
|
982
1077
|
r.className = `simulator-theme-item${n.name === e.state.selectedTheme.name ? " selected" : ""}`, r.innerHTML = `
|
|
983
|
-
${
|
|
1078
|
+
${ye(n)}
|
|
984
1079
|
<div class="simulator-theme-name">${n.name}</div>
|
|
985
1080
|
<div class="simulator-theme-type">${n.type}</div>
|
|
986
1081
|
`, r.addEventListener("click", () => {
|
|
@@ -990,7 +1085,7 @@ function pe() {
|
|
|
990
1085
|
}
|
|
991
1086
|
};
|
|
992
1087
|
}
|
|
993
|
-
var
|
|
1088
|
+
var xe = [
|
|
994
1089
|
{
|
|
995
1090
|
name: "app (desktop)",
|
|
996
1091
|
context: [{
|
|
@@ -1037,8 +1132,8 @@ var L = [
|
|
|
1037
1132
|
* The bootstrap is only read at game boot, so applying a change persists it to localStorage and
|
|
1038
1133
|
* restarts (reloads) the page — the same flow as the Theme tab.
|
|
1039
1134
|
*/
|
|
1040
|
-
function
|
|
1041
|
-
let t = [...
|
|
1135
|
+
function Se(e = []) {
|
|
1136
|
+
let t = [...xe, ...e];
|
|
1042
1137
|
return {
|
|
1043
1138
|
id: "host",
|
|
1044
1139
|
label: "Host",
|
|
@@ -1055,7 +1150,7 @@ function me(e = []) {
|
|
|
1055
1150
|
<div class="host-note" id="host-source"></div>
|
|
1056
1151
|
<select class="simulator-select" id="host-presets">
|
|
1057
1152
|
<option value="">Preset…</option>
|
|
1058
|
-
${t.map((e, t) => `<option value="${t}">${
|
|
1153
|
+
${t.map((e, t) => `<option value="${t}">${Ce(e.name)}</option>`).join("")}
|
|
1059
1154
|
</select>
|
|
1060
1155
|
<textarea class="simulator-textarea" id="host-json" spellcheck="false"></textarea>
|
|
1061
1156
|
<div class="host-actions">
|
|
@@ -1092,42 +1187,42 @@ function me(e = []) {
|
|
|
1092
1187
|
};
|
|
1093
1188
|
}
|
|
1094
1189
|
/** Minimal HTML-escape so preset names can't break the simulator markup. */
|
|
1095
|
-
function
|
|
1190
|
+
function Ce(e) {
|
|
1096
1191
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
1097
1192
|
}
|
|
1098
|
-
var
|
|
1099
|
-
localStorage.setItem(
|
|
1100
|
-
},
|
|
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() {
|
|
1101
1196
|
var e = t(function* () {
|
|
1102
|
-
if (
|
|
1197
|
+
if (V !== null) return V;
|
|
1103
1198
|
try {
|
|
1104
|
-
let e = new AbortController(), t = setTimeout(() => e.abort(), 1e3), n = yield fetch(`${
|
|
1105
|
-
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;
|
|
1106
1201
|
} catch (e) {
|
|
1107
|
-
return
|
|
1202
|
+
return V = !1, !1;
|
|
1108
1203
|
}
|
|
1109
1204
|
});
|
|
1110
1205
|
return function() {
|
|
1111
1206
|
return e.apply(this, arguments);
|
|
1112
1207
|
};
|
|
1113
|
-
}(),
|
|
1114
|
-
apiURL:
|
|
1208
|
+
}(), H = () => ({
|
|
1209
|
+
apiURL: B() === "dev" ? z : Te,
|
|
1115
1210
|
clientID: "protosdk:oauthclient",
|
|
1116
1211
|
redirectUri: `${window.location.origin}/oauth/callback`
|
|
1117
|
-
}),
|
|
1212
|
+
}), Oe = () => {
|
|
1118
1213
|
let e = new Uint8Array(32);
|
|
1119
1214
|
return crypto.getRandomValues(e), Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
1120
|
-
},
|
|
1121
|
-
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);
|
|
1122
1217
|
return e && `${e.substring(0, 20)}`, e;
|
|
1123
|
-
},
|
|
1124
|
-
localStorage.removeItem(
|
|
1125
|
-
},
|
|
1126
|
-
let e =
|
|
1218
|
+
}, K = () => localStorage.getItem(W), q = () => {
|
|
1219
|
+
localStorage.removeItem(U), localStorage.removeItem(W);
|
|
1220
|
+
}, je = () => {
|
|
1221
|
+
let e = H(), t = Oe();
|
|
1127
1222
|
sessionStorage.setItem("oauth_state", t), sessionStorage.setItem("oauth_return_url", window.location.href);
|
|
1128
1223
|
let n = new URL(`${e.apiURL}/oauth/auth`);
|
|
1129
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();
|
|
1130
|
-
},
|
|
1225
|
+
}, Me = (e) => {
|
|
1131
1226
|
try {
|
|
1132
1227
|
let t = e.split(".");
|
|
1133
1228
|
if (t.length !== 3) return !0;
|
|
@@ -1136,11 +1231,11 @@ var z = "puzzmo_sim_api_mode", B = "http://localhost:8911", V = "https://api.puz
|
|
|
1136
1231
|
} catch (e) {
|
|
1137
1232
|
return !0;
|
|
1138
1233
|
}
|
|
1139
|
-
},
|
|
1234
|
+
}, Ne = function() {
|
|
1140
1235
|
var e = t(function* () {
|
|
1141
|
-
let e =
|
|
1236
|
+
let e = K();
|
|
1142
1237
|
if (!e) return !1;
|
|
1143
|
-
let t =
|
|
1238
|
+
let t = H();
|
|
1144
1239
|
try {
|
|
1145
1240
|
let n = new URLSearchParams({
|
|
1146
1241
|
grant_type: "refresh_token",
|
|
@@ -1154,9 +1249,9 @@ var z = "puzzmo_sim_api_mode", B = "http://localhost:8911", V = "https://api.puz
|
|
|
1154
1249
|
if (!r.ok) return r.statusText, !1;
|
|
1155
1250
|
let i = yield r.json(), a = i.access_token || i.accessToken;
|
|
1156
1251
|
if (!a) return !1;
|
|
1157
|
-
|
|
1252
|
+
ke(a);
|
|
1158
1253
|
let o = i.refresh_token || i.refreshToken;
|
|
1159
|
-
return o &&
|
|
1254
|
+
return o && Ae(o), !0;
|
|
1160
1255
|
} catch (e) {
|
|
1161
1256
|
return !1;
|
|
1162
1257
|
}
|
|
@@ -1164,9 +1259,9 @@ var z = "puzzmo_sim_api_mode", B = "http://localhost:8911", V = "https://api.puz
|
|
|
1164
1259
|
return function() {
|
|
1165
1260
|
return e.apply(this, arguments);
|
|
1166
1261
|
};
|
|
1167
|
-
}(),
|
|
1262
|
+
}(), Pe = function() {
|
|
1168
1263
|
var e = t(function* (e, t) {
|
|
1169
|
-
let n =
|
|
1264
|
+
let n = H(), r = sessionStorage.getItem("oauth_state");
|
|
1170
1265
|
if (!r || r !== t) return null;
|
|
1171
1266
|
sessionStorage.removeItem("oauth_state");
|
|
1172
1267
|
try {
|
|
@@ -1188,13 +1283,13 @@ var z = "puzzmo_sim_api_mode", B = "http://localhost:8911", V = "https://api.puz
|
|
|
1188
1283
|
return function(t, n) {
|
|
1189
1284
|
return e.apply(this, arguments);
|
|
1190
1285
|
};
|
|
1191
|
-
}(),
|
|
1286
|
+
}(), Fe = function() {
|
|
1192
1287
|
var e = t(function* (e, t = {}) {
|
|
1193
|
-
let n =
|
|
1288
|
+
let n = H(), r = G();
|
|
1194
1289
|
if (!r) throw Error("Not authenticated");
|
|
1195
|
-
if (
|
|
1196
|
-
if (r =
|
|
1197
|
-
} 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.");
|
|
1198
1293
|
let i = yield fetch(`${n.apiURL}/graphql`, {
|
|
1199
1294
|
method: "POST",
|
|
1200
1295
|
headers: {
|
|
@@ -1213,7 +1308,7 @@ var z = "puzzmo_sim_api_mode", B = "http://localhost:8911", V = "https://api.puz
|
|
|
1213
1308
|
return function(t) {
|
|
1214
1309
|
return e.apply(this, arguments);
|
|
1215
1310
|
};
|
|
1216
|
-
}(),
|
|
1311
|
+
}(), Ie = (e) => {
|
|
1217
1312
|
try {
|
|
1218
1313
|
let t = e.split(".");
|
|
1219
1314
|
return t.length, t.length === 3 ? JSON.parse(atob(t[1])) : null;
|
|
@@ -1221,15 +1316,15 @@ var z = "puzzmo_sim_api_mode", B = "http://localhost:8911", V = "https://api.puz
|
|
|
1221
1316
|
return null;
|
|
1222
1317
|
}
|
|
1223
1318
|
};
|
|
1224
|
-
function
|
|
1319
|
+
function Le() {
|
|
1225
1320
|
let e = !1;
|
|
1226
1321
|
return {
|
|
1227
1322
|
id: "auth",
|
|
1228
1323
|
label: "Auth",
|
|
1229
1324
|
render() {
|
|
1230
|
-
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>`;
|
|
1231
1326
|
if (t) {
|
|
1232
|
-
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;
|
|
1233
1328
|
return `
|
|
1234
1329
|
<div class="simulator-section">
|
|
1235
1330
|
<div class="simulator-section-title auth-title-row">
|
|
@@ -1270,7 +1365,7 @@ function Ee() {
|
|
|
1270
1365
|
</div>
|
|
1271
1366
|
<p class="auth-description">
|
|
1272
1367
|
Login with your Puzzmo account to make authenticated API requests.
|
|
1273
|
-
${n === "dev" ? `<br><strong>Using local dev server:</strong> ${
|
|
1368
|
+
${n === "dev" ? `<br><strong>Using local dev server:</strong> ${z}` : ""}
|
|
1274
1369
|
</p>
|
|
1275
1370
|
<div class="simulator-row">
|
|
1276
1371
|
<button class="simulator-btn primary" id="auth-login">Login with Puzzmo</button>
|
|
@@ -1281,21 +1376,21 @@ function Ee() {
|
|
|
1281
1376
|
},
|
|
1282
1377
|
bind(n) {
|
|
1283
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");
|
|
1284
|
-
e ?
|
|
1285
|
-
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"));
|
|
1286
1381
|
})), c == null || c.addEventListener("click", () => {
|
|
1287
|
-
|
|
1382
|
+
Ee(B() === "dev" ? "prod" : "dev"), q(), window.location.reload();
|
|
1288
1383
|
}), r == null || r.addEventListener("click", () => {
|
|
1289
|
-
|
|
1384
|
+
je();
|
|
1290
1385
|
}), i == null || i.addEventListener("click", () => {
|
|
1291
|
-
|
|
1386
|
+
q(), window.location.reload();
|
|
1292
1387
|
}), a == null || a.addEventListener("click", t(function* () {
|
|
1293
|
-
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);
|
|
1294
1389
|
})), o == null || o.addEventListener("click", t(function* () {
|
|
1295
1390
|
if (s) {
|
|
1296
1391
|
s.innerHTML = "<div class=\"loading\">Loading...</div>";
|
|
1297
1392
|
try {
|
|
1298
|
-
let t = yield
|
|
1393
|
+
let t = yield Fe("\n query {\n currentUser {\n id\n username\n usernameID\n name\n }\n }\n ");
|
|
1299
1394
|
if (t.errors) {
|
|
1300
1395
|
var e;
|
|
1301
1396
|
s.innerHTML = `<div class="error">Error: ${((e = t.errors[0]) == null ? void 0 : e.message) || "Unknown error"}</div>`;
|
|
@@ -1317,13 +1412,13 @@ function Ee() {
|
|
|
1317
1412
|
if (n && r) {
|
|
1318
1413
|
let t = e.getElement("#auth-status");
|
|
1319
1414
|
t && (t.innerHTML = "<span class=\"indicator waiting\"></span><span>Exchanging code...</span>");
|
|
1320
|
-
let i = yield
|
|
1415
|
+
let i = yield Pe(n, r);
|
|
1321
1416
|
if (window.history.replaceState({}, "", window.location.pathname), i) {
|
|
1322
1417
|
let e = i.access_token || i.accessToken;
|
|
1323
1418
|
if (e) {
|
|
1324
|
-
|
|
1419
|
+
ke(e);
|
|
1325
1420
|
let t = i.refresh_token || i.refreshToken;
|
|
1326
|
-
t &&
|
|
1421
|
+
t && Ae(t);
|
|
1327
1422
|
}
|
|
1328
1423
|
window.location.reload();
|
|
1329
1424
|
} else {
|
|
@@ -1335,9 +1430,9 @@ function Ee() {
|
|
|
1335
1430
|
}
|
|
1336
1431
|
};
|
|
1337
1432
|
}
|
|
1338
|
-
var
|
|
1339
|
-
localStorage.removeItem(
|
|
1340
|
-
},
|
|
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) => {
|
|
1341
1436
|
try {
|
|
1342
1437
|
let t = e.split(".");
|
|
1343
1438
|
if (t.length !== 3) return !0;
|
|
@@ -1346,11 +1441,11 @@ var De = "puzzmo_sim_api_mode", Oe = "http://localhost:8911", ke = "https://api.
|
|
|
1346
1441
|
} catch (e) {
|
|
1347
1442
|
return !0;
|
|
1348
1443
|
}
|
|
1349
|
-
},
|
|
1444
|
+
}, qe = function() {
|
|
1350
1445
|
var e = t(function* () {
|
|
1351
|
-
let e =
|
|
1446
|
+
let e = He();
|
|
1352
1447
|
if (!e) return !1;
|
|
1353
|
-
let t =
|
|
1448
|
+
let t = Ve() === "dev" ? ze : Be;
|
|
1354
1449
|
try {
|
|
1355
1450
|
let n = new URLSearchParams({
|
|
1356
1451
|
grant_type: "refresh_token",
|
|
@@ -1364,9 +1459,9 @@ var De = "puzzmo_sim_api_mode", Oe = "http://localhost:8911", ke = "https://api.
|
|
|
1364
1459
|
if (!r.ok) return !1;
|
|
1365
1460
|
let i = yield r.json(), a = i.access_token || i.accessToken;
|
|
1366
1461
|
if (!a) return !1;
|
|
1367
|
-
|
|
1462
|
+
Ue(a);
|
|
1368
1463
|
let o = i.refresh_token || i.refreshToken;
|
|
1369
|
-
return o &&
|
|
1464
|
+
return o && We(o), !0;
|
|
1370
1465
|
} catch (e) {
|
|
1371
1466
|
return !1;
|
|
1372
1467
|
}
|
|
@@ -1374,13 +1469,13 @@ var De = "puzzmo_sim_api_mode", Oe = "http://localhost:8911", ke = "https://api.
|
|
|
1374
1469
|
return function() {
|
|
1375
1470
|
return e.apply(this, arguments);
|
|
1376
1471
|
};
|
|
1377
|
-
}(),
|
|
1472
|
+
}(), Je = function() {
|
|
1378
1473
|
var e = t(function* (e, t = {}) {
|
|
1379
|
-
let n =
|
|
1474
|
+
let n = Ve() === "dev" ? ze : Be, r = X();
|
|
1380
1475
|
if (!r) throw Error("Not authenticated");
|
|
1381
|
-
if (
|
|
1382
|
-
if (r =
|
|
1383
|
-
} 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.");
|
|
1384
1479
|
let i = yield fetch(`${n}/graphql`, {
|
|
1385
1480
|
method: "POST",
|
|
1386
1481
|
headers: {
|
|
@@ -1399,19 +1494,19 @@ var De = "puzzmo_sim_api_mode", Oe = "http://localhost:8911", ke = "https://api.
|
|
|
1399
1494
|
return function(t) {
|
|
1400
1495
|
return e.apply(this, arguments);
|
|
1401
1496
|
};
|
|
1402
|
-
}(),
|
|
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) => {
|
|
1403
1498
|
let n = t - 1, r = Math.floor(n / 31), i = n % 31, a = [...e];
|
|
1404
1499
|
for (; a.length <= r;) a.push(0);
|
|
1405
1500
|
return a[r] = a[r] ^ 1 << i, a;
|
|
1406
1501
|
};
|
|
1407
|
-
const
|
|
1408
|
-
function
|
|
1502
|
+
const Qe = () => !!X();
|
|
1503
|
+
function $e() {
|
|
1409
1504
|
let n = null, r = !1, i = null, a = function() {
|
|
1410
1505
|
var e = t(function* (e) {
|
|
1411
1506
|
r = !0, i = null;
|
|
1412
1507
|
try {
|
|
1413
1508
|
var t;
|
|
1414
|
-
let r = yield
|
|
1509
|
+
let r = yield Je(Ye, { slug: e });
|
|
1415
1510
|
if (r.errors) {
|
|
1416
1511
|
var a;
|
|
1417
1512
|
i = ((a = r.errors[0]) == null ? void 0 : a.message) || "Unknown error", n = null;
|
|
@@ -1428,10 +1523,10 @@ function We() {
|
|
|
1428
1523
|
}(), o = function() {
|
|
1429
1524
|
var r = t(function* (t) {
|
|
1430
1525
|
if (!n) return;
|
|
1431
|
-
let r =
|
|
1526
|
+
let r = Ze(n.featuresArr, t);
|
|
1432
1527
|
try {
|
|
1433
1528
|
var i;
|
|
1434
|
-
let t = yield
|
|
1529
|
+
let t = yield Je(Xe, {
|
|
1435
1530
|
gameSlug: n.slug,
|
|
1436
1531
|
input: { featuresArr: r }
|
|
1437
1532
|
});
|
|
@@ -1479,7 +1574,7 @@ function We() {
|
|
|
1479
1574
|
id: "features",
|
|
1480
1575
|
label: "Features",
|
|
1481
1576
|
render() {
|
|
1482
|
-
return
|
|
1577
|
+
return Qe() ? `
|
|
1483
1578
|
<div class="features-view-container">
|
|
1484
1579
|
<div class="simulator-section">
|
|
1485
1580
|
<div class="simulator-section-title">Game Features</div>
|
|
@@ -1520,7 +1615,7 @@ function We() {
|
|
|
1520
1615
|
e && (yield d(e));
|
|
1521
1616
|
})), i == null || i.addEventListener("keypress", (e) => {
|
|
1522
1617
|
e.key === "Enter" && (r == null || r.click());
|
|
1523
|
-
}), 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();
|
|
1524
1619
|
},
|
|
1525
1620
|
onActivate(e) {
|
|
1526
1621
|
let t = e.getElement("#simulator-tab-features");
|
|
@@ -1529,7 +1624,7 @@ function We() {
|
|
|
1529
1624
|
};
|
|
1530
1625
|
}
|
|
1531
1626
|
/** Renders a single keyboard key as an HTML button string */
|
|
1532
|
-
var
|
|
1627
|
+
var et = (e, t) => {
|
|
1533
1628
|
var n, r;
|
|
1534
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);
|
|
1535
1630
|
return `<button class="${[
|
|
@@ -1540,9 +1635,9 @@ var Ge = (e, t) => {
|
|
|
1540
1635
|
c ? "l" : "",
|
|
1541
1636
|
l ? "grow" : ""
|
|
1542
1637
|
].filter(Boolean).join(" ")}" data-key="${e}" ${a ? "disabled" : ""}>${i}</button>`;
|
|
1543
|
-
},
|
|
1544
|
-
function
|
|
1545
|
-
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>";
|
|
1546
1641
|
return {
|
|
1547
1642
|
id: "kbd",
|
|
1548
1643
|
label: "Kbd",
|
|
@@ -1556,19 +1651,19 @@ function qe() {
|
|
|
1556
1651
|
`;
|
|
1557
1652
|
},
|
|
1558
1653
|
bind(e) {
|
|
1559
|
-
|
|
1654
|
+
rt(e);
|
|
1560
1655
|
},
|
|
1561
1656
|
onMessage(n, r, i) {
|
|
1562
1657
|
var a;
|
|
1563
1658
|
if (n !== "KEYBOARD_UPDATE_CONFIG") return;
|
|
1564
1659
|
e = !(!(r == null || (a = r.layout) == null) && a.length) || r.layout.every((e) => !e) ? null : r;
|
|
1565
1660
|
let o = i.getElement("#sim-kb-content");
|
|
1566
|
-
o && (o.innerHTML = t(),
|
|
1661
|
+
o && (o.innerHTML = t(), rt(i)), i.updateBadge("kbd", void 0);
|
|
1567
1662
|
}
|
|
1568
1663
|
};
|
|
1569
1664
|
}
|
|
1570
1665
|
/** Attach click handlers to all rendered keys */
|
|
1571
|
-
function
|
|
1666
|
+
function rt(e) {
|
|
1572
1667
|
var t;
|
|
1573
1668
|
let n = (t = e.getElement("#sim-kb-content")) == null ? void 0 : t.querySelectorAll(".sim-kb-key");
|
|
1574
1669
|
n == null || n.forEach((t) => {
|
|
@@ -1583,15 +1678,15 @@ function Je(e) {
|
|
|
1583
1678
|
* change values (persisted to localStorage and pushed to the game as SETTINGS_UPDATE, matching the
|
|
1584
1679
|
* production host) and reflects UPDATE_SETTINGS_FROM_EMBED writes coming from the game.
|
|
1585
1680
|
*/
|
|
1586
|
-
function
|
|
1681
|
+
function it() {
|
|
1587
1682
|
let t = (e) => {
|
|
1588
1683
|
let t = e.state.settingsComponents;
|
|
1589
|
-
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>`;
|
|
1590
1685
|
}, n = (e) => {
|
|
1591
1686
|
let n = e.getElement("#sim-settings-content");
|
|
1592
1687
|
n && (n.innerHTML = t(e), i(e));
|
|
1593
1688
|
}, r = (e) => {
|
|
1594
|
-
|
|
1689
|
+
h(e.state.gameSettings), e.sendToGame("SETTINGS_UPDATE", e.state.gameSettings);
|
|
1595
1690
|
}, i = (t) => {
|
|
1596
1691
|
var i;
|
|
1597
1692
|
let a = t.getElement("#sim-settings-content");
|
|
@@ -1607,7 +1702,7 @@ function Ye() {
|
|
|
1607
1702
|
});
|
|
1608
1703
|
}), (i = a.querySelector("#sim-settings-reset")) == null || i.addEventListener("click", () => {
|
|
1609
1704
|
var e;
|
|
1610
|
-
|
|
1705
|
+
g(), t.state.gameSettings = ot((e = t.state.settingsComponents) == null ? [] : e), r(t), n(t);
|
|
1611
1706
|
}));
|
|
1612
1707
|
};
|
|
1613
1708
|
return {
|
|
@@ -1622,21 +1717,21 @@ function Ye() {
|
|
|
1622
1717
|
onMessage(t, r, i) {
|
|
1623
1718
|
if (t === "INITIALIZE_SETTINGS") {
|
|
1624
1719
|
var a;
|
|
1625
|
-
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);
|
|
1626
1721
|
return;
|
|
1627
1722
|
}
|
|
1628
|
-
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));
|
|
1629
1724
|
}
|
|
1630
1725
|
};
|
|
1631
1726
|
}
|
|
1632
1727
|
/** Renders a single settings UI component as HTML, reading its current value from `settings` */
|
|
1633
|
-
function
|
|
1728
|
+
function at(e, t) {
|
|
1634
1729
|
switch (e.type) {
|
|
1635
1730
|
case "title": return `<div class="sim-settings-heading">${Q(e.value)}</div>`;
|
|
1636
1731
|
case "subtitle": return `<div class="sim-settings-subheading">${Q(e.value)}</div>`;
|
|
1637
1732
|
case "paragraph": return `<p class="sim-settings-paragraph">${Q(e.value)}</p>`;
|
|
1638
1733
|
case "separator": return "<div class=\"simulator-divider\"></div>";
|
|
1639
|
-
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>`;
|
|
1640
1735
|
case "boolean": {
|
|
1641
1736
|
var n;
|
|
1642
1737
|
let r = ((n = t[e.name]) == null ? e.defaultValue : n) ? "checked" : "", i = e.subtitle ? `<div class="sim-settings-subtitle">${Q(e.subtitle)}</div>` : "";
|
|
@@ -1704,9 +1799,9 @@ function Z(e) {
|
|
|
1704
1799
|
return `<span class="simulator-label">${Q(e.title)}</span>${t}`;
|
|
1705
1800
|
}
|
|
1706
1801
|
/** Collects name → defaultValue pairs from components, recursing into split groups */
|
|
1707
|
-
function
|
|
1802
|
+
function ot(e) {
|
|
1708
1803
|
let t = {};
|
|
1709
|
-
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);
|
|
1710
1805
|
return t;
|
|
1711
1806
|
}
|
|
1712
1807
|
function Q(e) {
|
|
@@ -1750,27 +1845,27 @@ var $ = null;
|
|
|
1750
1845
|
* Fixtures are loaded as raw strings and passed to the game verbatim (any text format works; the game parses it).
|
|
1751
1846
|
* This will show dropdowns in the Ctrl tab to select category and puzzle.
|
|
1752
1847
|
*/
|
|
1753
|
-
function
|
|
1848
|
+
function st(e = {}) {
|
|
1754
1849
|
var n, r, i;
|
|
1755
1850
|
if (console.log("[Simulator] createSimulator called with config:", {
|
|
1756
1851
|
slug: e.slug,
|
|
1757
1852
|
hasFixtures: !!e.fixtures
|
|
1758
1853
|
}), $) return e.fixtures && (console.log("[Simulator] Instance already exists, updating fixtures"), $.updateFixtures(e.fixtures)), $;
|
|
1759
|
-
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 = [
|
|
1760
1855
|
se(),
|
|
1761
1856
|
ce(),
|
|
1762
1857
|
c,
|
|
1763
1858
|
ue(),
|
|
1764
1859
|
de(),
|
|
1765
1860
|
l,
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1861
|
+
be(),
|
|
1862
|
+
Se(e.hostContextPresets),
|
|
1863
|
+
Le(),
|
|
1864
|
+
$e(),
|
|
1865
|
+
nt(),
|
|
1866
|
+
it(),
|
|
1772
1867
|
...(r = e.views) == null ? [] : r
|
|
1773
|
-
], d = u.map((e) => e.id), f =
|
|
1868
|
+
], d = u.map((e) => e.id), f = m(e, s, d), p = {
|
|
1774
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>",
|
|
1775
1870
|
play: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><polygon points=\"2,1 9,5 2,9\"/></svg>",
|
|
1776
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>",
|
|
@@ -2286,6 +2381,74 @@ function Qe(e = {}) {
|
|
|
2286
2381
|
text-align: center;
|
|
2287
2382
|
padding: 20px;
|
|
2288
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
|
+
}
|
|
2289
2452
|
.simulator-value {
|
|
2290
2453
|
color: var(--sim-text);
|
|
2291
2454
|
font-size: 10px;
|
|
@@ -3022,8 +3185,8 @@ function Qe(e = {}) {
|
|
|
3022
3185
|
<div id="simulator-timer">--:--</div>
|
|
3023
3186
|
<span class="header-sep">|</span>
|
|
3024
3187
|
<div id="simulator-header-controls">
|
|
3025
|
-
<button id="simulator-header-pause" class="header-icon-btn" title="Pause" disabled>${
|
|
3026
|
-
<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>
|
|
3027
3190
|
</div>
|
|
3028
3191
|
<span class="header-sep">|</span>
|
|
3029
3192
|
<div id="simulator-header-status">
|
|
@@ -3031,8 +3194,8 @@ function Qe(e = {}) {
|
|
|
3031
3194
|
<span id="simulator-header-status-text">Waiting...</span>
|
|
3032
3195
|
</div>
|
|
3033
3196
|
<span class="header-spacer"></span>
|
|
3034
|
-
<button id="simulator-header-settings" class="header-icon-btn" title="Settings">${
|
|
3035
|
-
<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>
|
|
3036
3199
|
</div>
|
|
3037
3200
|
<div id="simulator-body">
|
|
3038
3201
|
<div id="simulator-tabs">
|
|
@@ -3044,8 +3207,8 @@ function Qe(e = {}) {
|
|
|
3044
3207
|
</div>
|
|
3045
3208
|
</div>
|
|
3046
3209
|
`, document.body.appendChild(h);
|
|
3047
|
-
let
|
|
3048
|
-
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";
|
|
3049
3212
|
}, O = (e, t) => {
|
|
3050
3213
|
let n = E("#simulator-status .text"), r = E("#simulator-status .indicator"), i = t === "complete" ? "✓" : "";
|
|
3051
3214
|
n && (n.textContent = e), r && (r.className = `indicator ${t}`, r.textContent = i), v.className = t, v.textContent = i, ne.textContent = e;
|
|
@@ -3061,7 +3224,7 @@ function Qe(e = {}) {
|
|
|
3061
3224
|
let n = u.find((t) => t.id === e);
|
|
3062
3225
|
n == null || (t = n.onActivate) == null || t.call(n, L);
|
|
3063
3226
|
}, j = (e) => {
|
|
3064
|
-
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);
|
|
3065
3228
|
}, M = () => {
|
|
3066
3229
|
l.updatePreview(L);
|
|
3067
3230
|
}, N = function() {
|
|
@@ -3123,12 +3286,12 @@ function Qe(e = {}) {
|
|
|
3123
3286
|
t && (t.disabled = !0, t.textContent = "Pause"), n && (n.textContent = "Start");
|
|
3124
3287
|
}), x.addEventListener("click", (e) => {
|
|
3125
3288
|
e.stopPropagation(), f.isCollapsed && j(!1), A("auth");
|
|
3126
|
-
}),
|
|
3289
|
+
}), te.addEventListener("click", (e) => {
|
|
3127
3290
|
f.isCollapsed && e.target !== S && j(!1);
|
|
3128
3291
|
}), f.isCollapsed || A(f.activeTab);
|
|
3129
3292
|
let R = new URLSearchParams(window.location.search);
|
|
3130
3293
|
(R.has("code") || R.has("error")) && (j(!1), A("auth"));
|
|
3131
|
-
let
|
|
3294
|
+
let fe = (e) => ({
|
|
3132
3295
|
userState: {
|
|
3133
3296
|
gameSettings: f.gameSettings,
|
|
3134
3297
|
id: "simulator-user",
|
|
@@ -3170,11 +3333,11 @@ function Qe(e = {}) {
|
|
|
3170
3333
|
theme: f.selectedTheme,
|
|
3171
3334
|
hostContext: f.hostContext,
|
|
3172
3335
|
appRuntimeContract: "1.0"
|
|
3173
|
-
}),
|
|
3336
|
+
}), pe = function() {
|
|
3174
3337
|
var e = t(function* () {
|
|
3175
3338
|
O("Loading puzzle...", "waiting");
|
|
3176
3339
|
try {
|
|
3177
|
-
let e =
|
|
3340
|
+
let e = fe(yield N());
|
|
3178
3341
|
O("Sending READY_DATA...", "waiting"), F("READY_DATA", e), O("Waiting for game to load...", "waiting");
|
|
3179
3342
|
} catch (e) {
|
|
3180
3343
|
O(`Error: ${e}`, "paused");
|
|
@@ -3183,7 +3346,7 @@ function Qe(e = {}) {
|
|
|
3183
3346
|
return function() {
|
|
3184
3347
|
return e.apply(this, arguments);
|
|
3185
3348
|
};
|
|
3186
|
-
}(),
|
|
3349
|
+
}(), me = () => {
|
|
3187
3350
|
console.log("Simulator: Game loaded, ready to start"), b.disabled = !1, u.forEach((e) => {
|
|
3188
3351
|
var t;
|
|
3189
3352
|
return (t = e.onMessage) == null ? void 0 : t.call(e, "READY_GAME_LOADED", void 0, L);
|
|
@@ -3195,11 +3358,11 @@ function Qe(e = {}) {
|
|
|
3195
3358
|
return ae((e, t) => {
|
|
3196
3359
|
var n, r;
|
|
3197
3360
|
if (e === "READY") {
|
|
3198
|
-
console.log("Simulator: Received READY from game"),
|
|
3361
|
+
console.log("Simulator: Received READY from game"), pe();
|
|
3199
3362
|
return;
|
|
3200
3363
|
}
|
|
3201
3364
|
if (e === "READY_GAME_LOADED") {
|
|
3202
|
-
|
|
3365
|
+
me();
|
|
3203
3366
|
return;
|
|
3204
3367
|
}
|
|
3205
3368
|
if (e === "TIMER_TICK") {
|
|
@@ -3238,6 +3401,6 @@ function Qe(e = {}) {
|
|
|
3238
3401
|
loadPuzzle: N
|
|
3239
3402
|
}, $;
|
|
3240
3403
|
}
|
|
3241
|
-
export {
|
|
3404
|
+
export { st as t };
|
|
3242
3405
|
|
|
3243
|
-
//# sourceMappingURL=createSimulator-
|
|
3406
|
+
//# sourceMappingURL=createSimulator-BuPYG4eZ.js.map
|