@puzzmo/sdk 1.0.52 → 1.0.54
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-BV7LZXDL.cjs → createSimulator-CB_nIwbm.cjs} +44 -32
- package/dist/createSimulator-CB_nIwbm.cjs.map +1 -0
- package/dist/{createSimulator-DWyT-Js_.js → createSimulator-bJ1qCLmt.js} +459 -302
- package/dist/createSimulator-bJ1qCLmt.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.global.js +1 -1
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/simulator/dockedKeyboard.d.ts +16 -0
- package/dist/simulator/dockedKeyboard.d.ts.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 +1 -0
- package/dist/simulator/state.d.ts.map +1 -1
- package/dist/simulator/types.d.ts +2 -0
- package/dist/simulator/types.d.ts.map +1 -1
- package/dist/simulator/views/KeyboardView.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/createSimulator-BV7LZXDL.cjs.map +0 -1
- package/dist/createSimulator-DWyT-Js_.js.map +0 -1
|
@@ -316,7 +316,8 @@ var r = {
|
|
|
316
316
|
renderContext: "simulator-render-context",
|
|
317
317
|
previewKind: "simulator-preview-kind",
|
|
318
318
|
gameSettings: "simulator-game-settings",
|
|
319
|
-
hostContext: "simulator-host-context"
|
|
319
|
+
hostContext: "simulator-host-context",
|
|
320
|
+
keyboardDocked: "simulator-keyboard-docked"
|
|
320
321
|
}, i = "simulator-override:";
|
|
321
322
|
/**
|
|
322
323
|
* Overrides are scoped to the page that applied them. localStorage is per-origin but a dev server
|
|
@@ -366,7 +367,14 @@ function d(e) {
|
|
|
366
367
|
function f() {
|
|
367
368
|
localStorage.removeItem(r.hostContext);
|
|
368
369
|
}
|
|
370
|
+
/** The Kbd tab's "show keyboard under game" checkbox. Off until asked for: it takes space from the game. */
|
|
369
371
|
function p() {
|
|
372
|
+
return localStorage.getItem(r.keyboardDocked) === "true";
|
|
373
|
+
}
|
|
374
|
+
function m(e) {
|
|
375
|
+
localStorage.setItem(r.keyboardDocked, String(e));
|
|
376
|
+
}
|
|
377
|
+
function h() {
|
|
370
378
|
let e = localStorage.getItem(r.gameSettings);
|
|
371
379
|
if (!e) return {};
|
|
372
380
|
try {
|
|
@@ -375,7 +383,7 @@ function p() {
|
|
|
375
383
|
} catch (e) {}
|
|
376
384
|
return {};
|
|
377
385
|
}
|
|
378
|
-
function
|
|
386
|
+
function g() {
|
|
379
387
|
let e = localStorage.getItem(r.theme);
|
|
380
388
|
if (e) {
|
|
381
389
|
let t = n.find((t) => t.name === e);
|
|
@@ -383,16 +391,16 @@ function m() {
|
|
|
383
391
|
}
|
|
384
392
|
return n[0];
|
|
385
393
|
}
|
|
386
|
-
function
|
|
394
|
+
function _(e) {
|
|
387
395
|
var t;
|
|
388
396
|
let n = localStorage.getItem(r.tab);
|
|
389
397
|
return n && e.includes(n) ? n : (t = e[0]) == null ? "ctrl" : t;
|
|
390
398
|
}
|
|
391
|
-
function
|
|
399
|
+
function v(e) {
|
|
392
400
|
let t = localStorage.getItem(r.collapsed);
|
|
393
401
|
return t === null ? e : t === "true";
|
|
394
402
|
}
|
|
395
|
-
function
|
|
403
|
+
function y() {
|
|
396
404
|
let e = localStorage.getItem(r.renderHost);
|
|
397
405
|
return e && [
|
|
398
406
|
"game",
|
|
@@ -400,10 +408,10 @@ function h() {
|
|
|
400
408
|
"opengraph"
|
|
401
409
|
].includes(e) ? e : "game";
|
|
402
410
|
}
|
|
403
|
-
function
|
|
411
|
+
function b() {
|
|
404
412
|
return localStorage.getItem(r.previewKind) === "text" ? "text" : "image";
|
|
405
413
|
}
|
|
406
|
-
function
|
|
414
|
+
function x() {
|
|
407
415
|
let e = localStorage.getItem(r.renderContext);
|
|
408
416
|
if (e && [
|
|
409
417
|
"preview",
|
|
@@ -412,9 +420,9 @@ function g() {
|
|
|
412
420
|
"timeline"
|
|
413
421
|
].includes(e)) return e;
|
|
414
422
|
}
|
|
415
|
-
function
|
|
423
|
+
function ee(e, t, n) {
|
|
416
424
|
var i, a, s;
|
|
417
|
-
let c = localStorage.getItem(r.fixtureCategory), l = localStorage.getItem(r.fixturePuzzle), d = u(), f = o("puzzle"),
|
|
425
|
+
let c = localStorage.getItem(r.fixtureCategory), l = localStorage.getItem(r.fixturePuzzle), d = u(), f = o("puzzle"), m = o("input");
|
|
418
426
|
return {
|
|
419
427
|
hostContext: (i = d == null ? e.hostContext : d) == null ? [{
|
|
420
428
|
type: "app",
|
|
@@ -422,60 +430,61 @@ function _(e, t, n) {
|
|
|
422
430
|
host: null
|
|
423
431
|
}] : i,
|
|
424
432
|
hostContextIsOverridden: d !== null,
|
|
425
|
-
isCollapsed:
|
|
433
|
+
isCollapsed: v((a = e.collapsed) == null ? !0 : a),
|
|
426
434
|
isPaused: !1,
|
|
427
435
|
hasStarted: !1,
|
|
428
|
-
activeTab:
|
|
436
|
+
activeTab: _(n),
|
|
429
437
|
puzzleData: f,
|
|
430
438
|
originalPuzzle: f == null ? "" : f,
|
|
431
|
-
currentInputStr:
|
|
439
|
+
currentInputStr: m == null ? "" : m,
|
|
432
440
|
appliedPuzzleOverride: f,
|
|
433
|
-
appliedInputOverride:
|
|
441
|
+
appliedInputOverride: m,
|
|
434
442
|
completionData: null,
|
|
435
|
-
selectedTheme:
|
|
443
|
+
selectedTheme: g(),
|
|
436
444
|
selectedCategory: c && t.includes(c) ? c : (s = t[0]) == null ? null : s,
|
|
437
445
|
selectedPuzzle: l == null ? null : l,
|
|
438
|
-
renderHost:
|
|
439
|
-
renderContext:
|
|
440
|
-
previewKind:
|
|
441
|
-
gameSettings:
|
|
446
|
+
renderHost: y(),
|
|
447
|
+
renderContext: x(),
|
|
448
|
+
previewKind: b(),
|
|
449
|
+
gameSettings: h(),
|
|
450
|
+
keyboardDocked: p(),
|
|
442
451
|
settingsComponents: null
|
|
443
452
|
};
|
|
444
453
|
}
|
|
445
|
-
function
|
|
454
|
+
function S(e) {
|
|
446
455
|
localStorage.setItem(r.gameSettings, JSON.stringify(e));
|
|
447
456
|
}
|
|
448
|
-
function
|
|
457
|
+
function C() {
|
|
449
458
|
localStorage.removeItem(r.gameSettings);
|
|
450
459
|
}
|
|
451
|
-
function
|
|
460
|
+
function te(e) {
|
|
452
461
|
localStorage.setItem(r.collapsed, String(e));
|
|
453
462
|
}
|
|
454
|
-
function
|
|
463
|
+
function ne(e) {
|
|
455
464
|
localStorage.setItem(r.tab, e);
|
|
456
465
|
}
|
|
457
|
-
function
|
|
466
|
+
function w(e) {
|
|
458
467
|
localStorage.setItem(r.theme, e);
|
|
459
468
|
}
|
|
460
|
-
function
|
|
469
|
+
function T(e) {
|
|
461
470
|
localStorage.setItem(r.fixtureCategory, e);
|
|
462
471
|
}
|
|
463
|
-
function
|
|
472
|
+
function E(e) {
|
|
464
473
|
localStorage.setItem(r.fixturePuzzle, e);
|
|
465
474
|
}
|
|
466
|
-
function
|
|
475
|
+
function D() {
|
|
467
476
|
localStorage.removeItem(r.fixturePuzzle);
|
|
468
477
|
}
|
|
469
|
-
function
|
|
478
|
+
function O(e) {
|
|
470
479
|
e ? localStorage.setItem(r.renderHost, e) : localStorage.removeItem(r.renderHost);
|
|
471
480
|
}
|
|
472
|
-
function
|
|
481
|
+
function k(e) {
|
|
473
482
|
localStorage.setItem(r.previewKind, e);
|
|
474
483
|
}
|
|
475
|
-
function
|
|
484
|
+
function A(e) {
|
|
476
485
|
e ? localStorage.setItem(r.renderContext, e) : localStorage.removeItem(r.renderContext);
|
|
477
486
|
}
|
|
478
|
-
function
|
|
487
|
+
function re(e) {
|
|
479
488
|
let t = [];
|
|
480
489
|
return {
|
|
481
490
|
log(n, r, i) {
|
|
@@ -500,13 +509,13 @@ function ae(e) {
|
|
|
500
509
|
}
|
|
501
510
|
};
|
|
502
511
|
}
|
|
503
|
-
function
|
|
512
|
+
function ie(e, t, n) {
|
|
504
513
|
console.log("Simulator sending:", e, t), n == null || n.log(e, t, "out"), window.postMessage({
|
|
505
514
|
type: e,
|
|
506
515
|
data: t
|
|
507
516
|
}, "*");
|
|
508
517
|
}
|
|
509
|
-
function
|
|
518
|
+
function ae(e, t) {
|
|
510
519
|
let n = (n) => {
|
|
511
520
|
var r, i, a;
|
|
512
521
|
if (!(!(n == null || (r = n.data) == null) && r.type)) return;
|
|
@@ -516,7 +525,7 @@ function se(e, t) {
|
|
|
516
525
|
return window.addEventListener("message", n), () => window.removeEventListener("message", n);
|
|
517
526
|
}
|
|
518
527
|
/** Parse fixture imports into a structured format: { category: { filename: data } } */
|
|
519
|
-
function
|
|
528
|
+
function oe(e) {
|
|
520
529
|
let t = /* @__PURE__ */ new Map();
|
|
521
530
|
console.log("Simulator: Parsing fixtures", Object.keys(e));
|
|
522
531
|
for (let [o, s] of Object.entries(e)) {
|
|
@@ -535,7 +544,7 @@ function ce(e) {
|
|
|
535
544
|
}), t;
|
|
536
545
|
}
|
|
537
546
|
/** Render fixture selector HTML */
|
|
538
|
-
function
|
|
547
|
+
function j(e, t) {
|
|
539
548
|
return e.length === 0 ? "" : `
|
|
540
549
|
<div class="simulator-fixtures">
|
|
541
550
|
<div class="simulator-field">
|
|
@@ -552,7 +561,7 @@ function D(e, t) {
|
|
|
552
561
|
`;
|
|
553
562
|
}
|
|
554
563
|
/** Update puzzle select options based on selected category */
|
|
555
|
-
function
|
|
564
|
+
function M(e, t, n, r) {
|
|
556
565
|
let i = t.get(n);
|
|
557
566
|
if (!i) return null;
|
|
558
567
|
let a = Array.from(i.keys()), o = r;
|
|
@@ -563,7 +572,7 @@ function O(e, t, n, r) {
|
|
|
563
572
|
return e.innerHTML = a.map((e) => `<option value="${e}" ${e === o ? "selected" : ""}>${e}</option>`).join(""), o;
|
|
564
573
|
}
|
|
565
574
|
/** Get puzzle data from fixtures */
|
|
566
|
-
function
|
|
575
|
+
function N(e, t, n) {
|
|
567
576
|
var r, i;
|
|
568
577
|
return !t || !n || (r = (i = e.get(t)) == null ? void 0 : i.get(n)) == null ? null : r;
|
|
569
578
|
}
|
|
@@ -575,8 +584,8 @@ function k(e, t, n) {
|
|
|
575
584
|
* `puzzmo games validate` greps build output for it — keep it in sync with the copy in
|
|
576
585
|
* packages/cli/src/util/lintDist.ts.
|
|
577
586
|
*/
|
|
578
|
-
const
|
|
579
|
-
function
|
|
587
|
+
const se = "puzzmo-simulator-dev-only-do-not-ship";
|
|
588
|
+
function ce() {
|
|
580
589
|
return {
|
|
581
590
|
id: "ctrl",
|
|
582
591
|
label: "Ctrl",
|
|
@@ -591,19 +600,19 @@ function ue() {
|
|
|
591
600
|
selectedCategory: e.state.selectedCategory,
|
|
592
601
|
selectedPuzzle: e.state.selectedPuzzle
|
|
593
602
|
}), e.fixtures && e.fixtureCategories.length > 0 && i) {
|
|
594
|
-
i.innerHTML =
|
|
603
|
+
i.innerHTML = j(e.fixtureCategories, e.state.selectedCategory);
|
|
595
604
|
let t = e.getElement("#simulator-fixture-category"), n = e.getElement("#simulator-fixture-puzzle");
|
|
596
605
|
if (t && n && e.state.selectedCategory) {
|
|
597
|
-
e.state.selectedPuzzle =
|
|
598
|
-
let r =
|
|
606
|
+
e.state.selectedPuzzle = M(n, e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
|
|
607
|
+
let r = N(e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
|
|
599
608
|
console.log("Simulator: Loading fixture puzzle", {
|
|
600
609
|
category: e.state.selectedCategory,
|
|
601
610
|
puzzle: e.state.selectedPuzzle,
|
|
602
611
|
hasPuzzleData: !!r
|
|
603
|
-
}), r && (e.state.appliedPuzzleOverride === null && (e.state.puzzleData = r, e.state.originalPuzzle = r), e.state.selectedCategory &&
|
|
604
|
-
console.log("Simulator: Category changed, reloading...", t.value), l(),
|
|
612
|
+
}), r && (e.state.appliedPuzzleOverride === null && (e.state.puzzleData = r, e.state.originalPuzzle = r), e.state.selectedCategory && T(e.state.selectedCategory), e.state.selectedPuzzle && E(e.state.selectedPuzzle)), t.addEventListener("change", () => {
|
|
613
|
+
console.log("Simulator: Category changed, reloading...", t.value), l(), T(t.value), D(), window.location.reload();
|
|
605
614
|
}), n.addEventListener("change", () => {
|
|
606
|
-
console.log("Simulator: Puzzle changed, reloading...", n.value), l(),
|
|
615
|
+
console.log("Simulator: Puzzle changed, reloading...", n.value), l(), E(n.value), window.location.reload();
|
|
607
616
|
});
|
|
608
617
|
}
|
|
609
618
|
}
|
|
@@ -629,10 +638,10 @@ function ue() {
|
|
|
629
638
|
* Inlined here (rather than shared with the rest of the monorepo) because the SDK ships to OSS and
|
|
630
639
|
* must stay self-contained.
|
|
631
640
|
*/
|
|
632
|
-
function
|
|
641
|
+
function P(e) {
|
|
633
642
|
var t;
|
|
634
643
|
if (typeof e != "string") return e;
|
|
635
|
-
let n = (t =
|
|
644
|
+
let n = (t = F(e)) == null ? {
|
|
636
645
|
width: 800,
|
|
637
646
|
height: 800
|
|
638
647
|
} : t;
|
|
@@ -643,7 +652,7 @@ function A(e) {
|
|
|
643
652
|
};
|
|
644
653
|
}
|
|
645
654
|
/** Reads an SVG's intrinsic size from its `viewBox` (preferred) or its `width`/`height` attributes. */
|
|
646
|
-
function
|
|
655
|
+
function F(e) {
|
|
647
656
|
var t, n, r, i;
|
|
648
657
|
let a = e.indexOf("<svg");
|
|
649
658
|
if (a === -1) return;
|
|
@@ -661,9 +670,9 @@ function j(e) {
|
|
|
661
670
|
height: u
|
|
662
671
|
};
|
|
663
672
|
}
|
|
664
|
-
var
|
|
673
|
+
var I = "simulator-saved-states";
|
|
665
674
|
/** Find thumbnail function on globalThis (looks for functions ending in "Thumbnail") */
|
|
666
|
-
function
|
|
675
|
+
function L() {
|
|
667
676
|
let e = globalThis;
|
|
668
677
|
for (let t of Object.keys(e)) if (t.endsWith("Thumbnail") && typeof e[t] == "function") return {
|
|
669
678
|
name: t,
|
|
@@ -672,8 +681,8 @@ function N() {
|
|
|
672
681
|
return null;
|
|
673
682
|
}
|
|
674
683
|
/** Generate a small thumbnail SVG for a given input string */
|
|
675
|
-
function
|
|
676
|
-
let n =
|
|
684
|
+
function R(e, t) {
|
|
685
|
+
let n = L();
|
|
677
686
|
if (!n) return "";
|
|
678
687
|
try {
|
|
679
688
|
var r;
|
|
@@ -683,19 +692,19 @@ function P(e, t) {
|
|
|
683
692
|
strict: !0,
|
|
684
693
|
renderHost: "game"
|
|
685
694
|
};
|
|
686
|
-
return
|
|
695
|
+
return P(n.fn(i, t, a)).svg;
|
|
687
696
|
} catch (e) {
|
|
688
697
|
return "";
|
|
689
698
|
}
|
|
690
699
|
}
|
|
691
|
-
var
|
|
692
|
-
function
|
|
700
|
+
var z = [];
|
|
701
|
+
function B(e, t = 8) {
|
|
693
702
|
let n = 14 * t + 8 + 4;
|
|
694
703
|
e.style.height = "auto";
|
|
695
704
|
let r = Math.min(Math.max(e.scrollHeight, 40), n);
|
|
696
705
|
e.style.height = `${r}px`;
|
|
697
706
|
}
|
|
698
|
-
function
|
|
707
|
+
function le() {
|
|
699
708
|
let e = "", t = "";
|
|
700
709
|
return {
|
|
701
710
|
id: "data",
|
|
@@ -713,18 +722,18 @@ function de() {
|
|
|
713
722
|
let i = n.getElement(".data-view-container");
|
|
714
723
|
i == null || i.querySelectorAll(".data-subtab-content").forEach((e) => {
|
|
715
724
|
e.classList.toggle("active", e.id === `data-subtab-${t}`);
|
|
716
|
-
}), t === "edit" ?
|
|
725
|
+
}), t === "edit" ? de(n) : t === "history" ? H(n) : t === "saves" && U(n);
|
|
717
726
|
});
|
|
718
727
|
});
|
|
719
728
|
let i = n.getElement("#simulator-puzzle"), a = n.getElement("#simulator-input"), o = n.getElement("#simulator-puzzle-reset"), l = n.getElement("#simulator-puzzle-apply"), u = n.getElement("#simulator-input-reset"), d = n.getElement("#simulator-input-apply");
|
|
720
729
|
setTimeout(() => {
|
|
721
|
-
i && n.state.originalPuzzle && document.activeElement !== i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle,
|
|
730
|
+
i && n.state.originalPuzzle && document.activeElement !== i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle, B(i)), a && n.state.currentInputStr && document.activeElement !== a && (a.value = n.state.currentInputStr, t = n.state.currentInputStr, B(a)), fe(n);
|
|
722
731
|
}, 0), i == null || i.addEventListener("input", () => {
|
|
723
|
-
|
|
732
|
+
B(i);
|
|
724
733
|
let t = i.value !== e;
|
|
725
734
|
l && (l.disabled = !t);
|
|
726
735
|
}), a == null || a.addEventListener("input", () => {
|
|
727
|
-
|
|
736
|
+
B(a);
|
|
728
737
|
let e = a.value !== t;
|
|
729
738
|
d && (d.disabled = !e);
|
|
730
739
|
}), o == null || o.addEventListener("click", () => {
|
|
@@ -732,7 +741,7 @@ function de() {
|
|
|
732
741
|
c("puzzle"), n.updateStatus("Restoring fixture puzzle...", "waiting"), window.location.reload();
|
|
733
742
|
return;
|
|
734
743
|
}
|
|
735
|
-
i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle,
|
|
744
|
+
i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle, B(i), l && (l.disabled = !0));
|
|
736
745
|
}), l == null || l.addEventListener("click", () => {
|
|
737
746
|
if (i) {
|
|
738
747
|
if (!s("puzzle", i.value)) {
|
|
@@ -746,7 +755,7 @@ function de() {
|
|
|
746
755
|
c("input"), n.updateStatus("Clearing input...", "waiting"), window.location.reload();
|
|
747
756
|
return;
|
|
748
757
|
}
|
|
749
|
-
a && (a.value = t,
|
|
758
|
+
a && (a.value = t, B(a), d && (d.disabled = !0));
|
|
750
759
|
}), d == null || d.addEventListener("click", () => {
|
|
751
760
|
if (a) {
|
|
752
761
|
if (!s("input", a.value)) {
|
|
@@ -758,87 +767,87 @@ function de() {
|
|
|
758
767
|
});
|
|
759
768
|
let f = n.getElement("#simulator-history-clear");
|
|
760
769
|
f == null || f.addEventListener("click", () => {
|
|
761
|
-
|
|
770
|
+
z = [], H(n);
|
|
762
771
|
});
|
|
763
772
|
let p = n.getElement("#simulator-save-name"), m = n.getElement("#simulator-save-btn");
|
|
764
773
|
m == null || m.addEventListener("click", () => {
|
|
765
774
|
if (!p || !p.value.trim()) return;
|
|
766
|
-
let e =
|
|
775
|
+
let e = V(), t = {
|
|
767
776
|
name: p.value.trim(),
|
|
768
777
|
puzzleStr: n.state.originalPuzzle,
|
|
769
778
|
inputStr: n.state.currentInputStr,
|
|
770
779
|
timestamp: Date.now()
|
|
771
780
|
};
|
|
772
|
-
e.push(t), localStorage.setItem(
|
|
773
|
-
}),
|
|
781
|
+
e.push(t), localStorage.setItem(I, JSON.stringify(e)), p.value = "", U(n);
|
|
782
|
+
}), U(n);
|
|
774
783
|
},
|
|
775
784
|
onActivate(n) {
|
|
776
|
-
e = n.state.originalPuzzle, t = n.state.currentInputStr,
|
|
785
|
+
e = n.state.originalPuzzle, t = n.state.currentInputStr, de(n), H(n);
|
|
777
786
|
},
|
|
778
787
|
onMessage(e, n, r) {
|
|
779
788
|
var i, a;
|
|
780
789
|
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;
|
|
781
790
|
if (e === "UPLOAD_NEW_GAME_STATE" && c) {
|
|
782
|
-
if (r.state.currentInputStr = c,
|
|
783
|
-
|
|
791
|
+
if (r.state.currentInputStr = c, z.length === 0 || z[z.length - 1].value !== c) {
|
|
792
|
+
z.push({
|
|
784
793
|
value: c,
|
|
785
794
|
timestamp: Date.now()
|
|
786
|
-
}),
|
|
795
|
+
}), z.length > 100 && (z = z.slice(-100));
|
|
787
796
|
let e = r.getElement("#data-subtab-history");
|
|
788
|
-
e != null && e.classList.contains("active") &&
|
|
797
|
+
e != null && e.classList.contains("active") && H(r);
|
|
789
798
|
}
|
|
790
|
-
o && document.activeElement !== o && (o.value !== c && (o.value = c,
|
|
799
|
+
o && document.activeElement !== o && (o.value !== c && (o.value = c, B(o)), t = c, s && (s.disabled = !0));
|
|
791
800
|
}
|
|
792
801
|
}
|
|
793
802
|
};
|
|
794
803
|
}
|
|
795
|
-
function
|
|
804
|
+
function V() {
|
|
796
805
|
try {
|
|
797
|
-
let e = localStorage.getItem(
|
|
806
|
+
let e = localStorage.getItem(I);
|
|
798
807
|
return e ? JSON.parse(e) : [];
|
|
799
808
|
} catch (e) {
|
|
800
809
|
return [];
|
|
801
810
|
}
|
|
802
811
|
}
|
|
803
|
-
function
|
|
812
|
+
function H(e) {
|
|
804
813
|
let t = e.getElement("#simulator-history-list");
|
|
805
814
|
if (t) {
|
|
806
|
-
if (t.style.setProperty("--history-thumb-bg", e.state.selectedTheme.a_bg),
|
|
815
|
+
if (t.style.setProperty("--history-thumb-bg", e.state.selectedTheme.a_bg), z.length === 0) {
|
|
807
816
|
t.innerHTML = "<div class=\"simulator-empty\">No history yet</div>";
|
|
808
817
|
return;
|
|
809
818
|
}
|
|
810
|
-
t.innerHTML = [...
|
|
811
|
-
let r =
|
|
819
|
+
t.innerHTML = [...z].reverse().map((t, n) => {
|
|
820
|
+
let r = z.length - 1 - n, i = new Date(t.timestamp).toLocaleTimeString(), a = t.value.length > 60 ? t.value.slice(0, 60) + "..." : t.value;
|
|
812
821
|
return `
|
|
813
822
|
<div class="history-item" data-history-idx="${r}">
|
|
814
|
-
<div class="history-item-thumb">${
|
|
823
|
+
<div class="history-item-thumb">${R(e, t.value)}</div>
|
|
815
824
|
<div class="history-item-content">
|
|
816
825
|
<div class="history-item-header">
|
|
817
826
|
<span class="history-item-num">#${r + 1}</span>
|
|
818
827
|
<span class="history-item-time">${i}</span>
|
|
819
828
|
<button class="simulator-btn tiny history-restore-btn" data-history-idx="${r}">Restore</button>
|
|
820
829
|
</div>
|
|
821
|
-
<div class="history-item-preview">${
|
|
830
|
+
<div class="history-item-preview">${ue(a)}</div>
|
|
822
831
|
</div>
|
|
823
832
|
</div>
|
|
824
833
|
`;
|
|
825
834
|
}).join(""), t.querySelectorAll(".history-restore-btn").forEach((t) => {
|
|
826
835
|
t.addEventListener("click", (t) => {
|
|
827
|
-
let n = parseInt(t.target.getAttribute("data-history-idx") || "0"), r =
|
|
836
|
+
let n = parseInt(t.target.getAttribute("data-history-idx") || "0"), r = z[n];
|
|
828
837
|
if (r) {
|
|
829
838
|
let t = e.getElement(".data-subtab[data-subtab=\"edit\"]");
|
|
830
839
|
t == null || t.click();
|
|
831
840
|
let n = e.getElement("#simulator-input"), i = e.getElement("#simulator-input-apply");
|
|
832
|
-
n && (n.value = r.value,
|
|
841
|
+
n && (n.value = r.value, B(n)), i && (i.disabled = !1), e.updateStatus("Input restored — press Apply to load it", "ready");
|
|
833
842
|
}
|
|
834
843
|
});
|
|
835
844
|
});
|
|
836
845
|
}
|
|
837
846
|
}
|
|
838
|
-
function
|
|
847
|
+
function U(e) {
|
|
839
848
|
let t = e.getElement("#simulator-saves-list");
|
|
840
849
|
if (!t) return;
|
|
841
|
-
let n =
|
|
850
|
+
let n = V();
|
|
842
851
|
if (n.length === 0) {
|
|
843
852
|
t.innerHTML = "<div class=\"simulator-empty\">No saved states</div>";
|
|
844
853
|
return;
|
|
@@ -848,7 +857,7 @@ function z(e) {
|
|
|
848
857
|
return `
|
|
849
858
|
<div class="save-item">
|
|
850
859
|
<div class="save-item-header">
|
|
851
|
-
<span class="save-item-name">${
|
|
860
|
+
<span class="save-item-name">${ue(e.name)}</span>
|
|
852
861
|
<span class="save-item-time">${i} ${a}</span>
|
|
853
862
|
</div>
|
|
854
863
|
<div class="save-item-actions">
|
|
@@ -871,25 +880,25 @@ function z(e) {
|
|
|
871
880
|
}), t.querySelectorAll(".save-delete-btn").forEach((t) => {
|
|
872
881
|
t.addEventListener("click", (t) => {
|
|
873
882
|
let r = parseInt(t.target.getAttribute("data-save-idx") || "0"), i = n.filter((e, t) => t !== r);
|
|
874
|
-
localStorage.setItem(
|
|
883
|
+
localStorage.setItem(I, JSON.stringify(i)), U(e);
|
|
875
884
|
});
|
|
876
885
|
});
|
|
877
886
|
}
|
|
878
|
-
function
|
|
887
|
+
function ue(e) {
|
|
879
888
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
880
889
|
}
|
|
881
|
-
function
|
|
890
|
+
function de(e) {
|
|
882
891
|
let t = e.getElement("#simulator-puzzle"), n = e.getElement("#simulator-input"), r = e.getElement("#simulator-puzzle-apply"), i = e.getElement("#simulator-input-apply");
|
|
883
|
-
t && e.state.originalPuzzle && (t.value = e.state.originalPuzzle,
|
|
892
|
+
t && e.state.originalPuzzle && (t.value = e.state.originalPuzzle, B(t), r && (r.disabled = !0)), n && (n.value = e.state.currentInputStr, B(n), i && (i.disabled = !0)), fe(e);
|
|
884
893
|
}
|
|
885
|
-
function
|
|
894
|
+
function fe(e) {
|
|
886
895
|
let t = e.getElement("#simulator-puzzle-override-tag"), n = e.getElement("#simulator-input-override-tag");
|
|
887
896
|
t && (t.hidden = e.state.appliedPuzzleOverride === null), n && (n.hidden = e.state.appliedInputOverride === null);
|
|
888
897
|
}
|
|
889
|
-
function
|
|
898
|
+
function pe(e) {
|
|
890
899
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
891
900
|
}
|
|
892
|
-
function
|
|
901
|
+
function me() {
|
|
893
902
|
let e = 0;
|
|
894
903
|
return {
|
|
895
904
|
id: "msgs",
|
|
@@ -916,7 +925,7 @@ function ge() {
|
|
|
916
925
|
<span class="simulator-msg-type">${t.direction === "out" ? "→" : "←"} ${t.type}</span>
|
|
917
926
|
<span class="simulator-msg-time">${t.time}</span>
|
|
918
927
|
</div>
|
|
919
|
-
${a ? `<div class="simulator-msg-data">${
|
|
928
|
+
${a ? `<div class="simulator-msg-data">${pe(a)}</div>` : ""}
|
|
920
929
|
`;
|
|
921
930
|
let o = i.querySelector(".simulator-msg-data");
|
|
922
931
|
for (o && o.addEventListener("click", () => {
|
|
@@ -927,7 +936,7 @@ function ge() {
|
|
|
927
936
|
}
|
|
928
937
|
};
|
|
929
938
|
}
|
|
930
|
-
function
|
|
939
|
+
function he() {
|
|
931
940
|
return {
|
|
932
941
|
id: "done",
|
|
933
942
|
label: "Done",
|
|
@@ -964,7 +973,7 @@ function _e() {
|
|
|
964
973
|
}
|
|
965
974
|
};
|
|
966
975
|
}
|
|
967
|
-
function
|
|
976
|
+
function ge() {
|
|
968
977
|
let e = [], t = () => (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", { hour12: !1 }), n = (e) => {
|
|
969
978
|
let { checkpointName: t, augConfig: n, time: r } = e, i = n == null ? void 0 : n.deeds;
|
|
970
979
|
return `
|
|
@@ -1015,7 +1024,7 @@ function ve() {
|
|
|
1015
1024
|
};
|
|
1016
1025
|
}
|
|
1017
1026
|
/** Find thumbnail function on globalThis (looks for functions ending in "Thumbnail") */
|
|
1018
|
-
function
|
|
1027
|
+
function _e() {
|
|
1019
1028
|
let e = globalThis;
|
|
1020
1029
|
for (let t of Object.keys(e)) if (t.endsWith("Thumbnail") && typeof e[t] == "function") return {
|
|
1021
1030
|
name: t,
|
|
@@ -1024,23 +1033,23 @@ function ye() {
|
|
|
1024
1033
|
return null;
|
|
1025
1034
|
}
|
|
1026
1035
|
/** The bundle's `getShareString` (if any), exposed to the sim via vite.ts's bundle loader. */
|
|
1027
|
-
function
|
|
1036
|
+
function ve() {
|
|
1028
1037
|
let e = globalThis.getShareString;
|
|
1029
1038
|
return typeof e == "function" ? e : null;
|
|
1030
1039
|
}
|
|
1031
|
-
function
|
|
1040
|
+
function ye(e) {
|
|
1032
1041
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
1033
1042
|
}
|
|
1034
|
-
function
|
|
1043
|
+
function be() {
|
|
1035
1044
|
let e = /* @__PURE__ */ new Date();
|
|
1036
1045
|
return `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`;
|
|
1037
1046
|
}
|
|
1038
|
-
function
|
|
1047
|
+
function xe(e) {
|
|
1039
1048
|
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
1040
1049
|
}
|
|
1041
1050
|
/** Shown when Preview Kind = Text but the bundle doesn't export `getShareString`. */
|
|
1042
|
-
var
|
|
1043
|
-
function
|
|
1051
|
+
var Se = "\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";
|
|
1052
|
+
function Ce() {
|
|
1044
1053
|
return {
|
|
1045
1054
|
id: "thumb",
|
|
1046
1055
|
label: "Thumb",
|
|
@@ -1062,12 +1071,12 @@ function Te() {
|
|
|
1062
1071
|
o == null || o.querySelectorAll(".simulator-segmented-btn").forEach((t) => {
|
|
1063
1072
|
t.addEventListener("click", () => {
|
|
1064
1073
|
let n = t.dataset.previewKind;
|
|
1065
|
-
!n || n === e.state.previewKind || (e.state.previewKind = n,
|
|
1074
|
+
!n || n === e.state.previewKind || (e.state.previewKind = n, k(n), c(), s(), e.updateThumbnail());
|
|
1066
1075
|
});
|
|
1067
|
-
}), n && (e.state.renderHost || (e.state.renderHost = "game",
|
|
1068
|
-
e.state.renderHost = n.value,
|
|
1069
|
-
})), r && (e.state.renderContext || (e.state.renderContext = "preview",
|
|
1070
|
-
e.state.renderContext = r.value,
|
|
1076
|
+
}), n && (e.state.renderHost || (e.state.renderHost = "game", O(e.state.renderHost)), n.value = e.state.renderHost || "game", n.addEventListener("change", () => {
|
|
1077
|
+
e.state.renderHost = n.value, O(e.state.renderHost), s(), e.updateThumbnail();
|
|
1078
|
+
})), r && (e.state.renderContext || (e.state.renderContext = "preview", A(e.state.renderContext)), r.value = e.state.renderContext || "preview", r.addEventListener("change", () => {
|
|
1079
|
+
e.state.renderContext = r.value, A(e.state.renderContext), e.updateThumbnail();
|
|
1071
1080
|
})), c(), s();
|
|
1072
1081
|
},
|
|
1073
1082
|
onActivate(e) {
|
|
@@ -1076,26 +1085,26 @@ function Te() {
|
|
|
1076
1085
|
updatePreview: (e) => {
|
|
1077
1086
|
let t = e.getElement("#simulator-thumb-preview"), n = e.getElement("#simulator-thumb-fn");
|
|
1078
1087
|
if (t == null || t.style.setProperty("--sim-thumb-bg", e.state.selectedTheme.g_bg), e.state.previewKind === "text") {
|
|
1079
|
-
let s =
|
|
1088
|
+
let s = ve();
|
|
1080
1089
|
if (!s) {
|
|
1081
|
-
t && (t.innerHTML =
|
|
1090
|
+
t && (t.innerHTML = Se), n && (n.textContent = "");
|
|
1082
1091
|
return;
|
|
1083
1092
|
}
|
|
1084
1093
|
n && (n.textContent = "Using: getShareString()");
|
|
1085
1094
|
try {
|
|
1086
1095
|
var r, i, a, o;
|
|
1087
|
-
let n = (r = e.gameSlug) == null ? "game" : r, c = s((i = e.state.currentInputStr) == null ? "" : i,
|
|
1096
|
+
let n = (r = e.gameSlug) == null ? "game" : r, c = s((i = e.state.currentInputStr) == null ? "" : i, xe(n), {
|
|
1088
1097
|
puzzleString: (a = e.state.puzzleData) == null ? "" : a,
|
|
1089
|
-
dateKey:
|
|
1098
|
+
dateKey: be(),
|
|
1090
1099
|
gameplaySlug: `simulator:${n}`
|
|
1091
1100
|
}), l = (o = c == null ? void 0 : c.str) == null ? "" : o;
|
|
1092
|
-
t && (t.innerHTML = `<pre class="simulator-share-preview" style="color: ${e.state.selectedTheme.fg}">${
|
|
1101
|
+
t && (t.innerHTML = `<pre class="simulator-share-preview" style="color: ${e.state.selectedTheme.fg}">${ye(l)}</pre>`);
|
|
1093
1102
|
} catch (e) {
|
|
1094
1103
|
console.error("Simulator: Share string error", e), t && (t.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
|
|
1095
1104
|
}
|
|
1096
1105
|
return;
|
|
1097
1106
|
}
|
|
1098
|
-
let s =
|
|
1107
|
+
let s = _e();
|
|
1099
1108
|
if (!s) {
|
|
1100
1109
|
t && (t.innerHTML = "<span class=\"simulator-empty\">No thumbnail function found</span>"), n && (n.textContent = "");
|
|
1101
1110
|
return;
|
|
@@ -1109,7 +1118,7 @@ function Te() {
|
|
|
1109
1118
|
strict: !0,
|
|
1110
1119
|
renderHost: e.state.renderHost,
|
|
1111
1120
|
renderContext: e.state.renderContext
|
|
1112
|
-
}, { svg: i } =
|
|
1121
|
+
}, { svg: i } = P(s.fn(n, e.state.currentInputStr, r));
|
|
1113
1122
|
t && (t.innerHTML = i);
|
|
1114
1123
|
} catch (e) {
|
|
1115
1124
|
console.error("Simulator: Thumbnail error", e), t && (t.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
|
|
@@ -1118,7 +1127,7 @@ function Te() {
|
|
|
1118
1127
|
};
|
|
1119
1128
|
}
|
|
1120
1129
|
/** Generate theme preview HTML showing key colors */
|
|
1121
|
-
function
|
|
1130
|
+
function we(e) {
|
|
1122
1131
|
let t = [
|
|
1123
1132
|
e.key,
|
|
1124
1133
|
e.subBrand,
|
|
@@ -1129,7 +1138,7 @@ function Ee(e) {
|
|
|
1129
1138
|
].map((e) => `<div class="simulator-theme-preview-cell" style="background: ${e}"></div>`).join("");
|
|
1130
1139
|
return `<div class="simulator-theme-preview" style="background: ${e.g_bg}">${t}</div>`;
|
|
1131
1140
|
}
|
|
1132
|
-
function
|
|
1141
|
+
function Te() {
|
|
1133
1142
|
return {
|
|
1134
1143
|
id: "theme",
|
|
1135
1144
|
label: "Theme",
|
|
@@ -1141,17 +1150,17 @@ function De() {
|
|
|
1141
1150
|
t && n.forEach((n) => {
|
|
1142
1151
|
let r = document.createElement("div");
|
|
1143
1152
|
r.className = `simulator-theme-item${n.name === e.state.selectedTheme.name ? " selected" : ""}`, r.innerHTML = `
|
|
1144
|
-
${
|
|
1153
|
+
${we(n)}
|
|
1145
1154
|
<div class="simulator-theme-name">${n.name}</div>
|
|
1146
1155
|
<div class="simulator-theme-type">${n.type}</div>
|
|
1147
1156
|
`, r.addEventListener("click", () => {
|
|
1148
|
-
console.log("Simulator: Theme changed, reloading...", n.name),
|
|
1157
|
+
console.log("Simulator: Theme changed, reloading...", n.name), w(n.name), window.location.reload();
|
|
1149
1158
|
}), t.appendChild(r);
|
|
1150
1159
|
});
|
|
1151
1160
|
}
|
|
1152
1161
|
};
|
|
1153
1162
|
}
|
|
1154
|
-
var
|
|
1163
|
+
var Ee = [
|
|
1155
1164
|
{
|
|
1156
1165
|
name: "app (desktop)",
|
|
1157
1166
|
context: [{
|
|
@@ -1198,8 +1207,8 @@ var Oe = [
|
|
|
1198
1207
|
* The bootstrap is only read at game boot, so applying a change persists it to localStorage and
|
|
1199
1208
|
* restarts (reloads) the page — the same flow as the Theme tab.
|
|
1200
1209
|
*/
|
|
1201
|
-
function
|
|
1202
|
-
let t = [...
|
|
1210
|
+
function De(e = []) {
|
|
1211
|
+
let t = [...Ee, ...e];
|
|
1203
1212
|
return {
|
|
1204
1213
|
id: "host",
|
|
1205
1214
|
label: "Host",
|
|
@@ -1216,7 +1225,7 @@ function ke(e = []) {
|
|
|
1216
1225
|
<div class="host-note" id="host-source"></div>
|
|
1217
1226
|
<select class="simulator-select" id="host-presets">
|
|
1218
1227
|
<option value="">Preset…</option>
|
|
1219
|
-
${t.map((e, t) => `<option value="${t}">${
|
|
1228
|
+
${t.map((e, t) => `<option value="${t}">${Oe(e.name)}</option>`).join("")}
|
|
1220
1229
|
</select>
|
|
1221
1230
|
<textarea class="simulator-textarea" id="host-json" spellcheck="false"></textarea>
|
|
1222
1231
|
<div class="host-actions">
|
|
@@ -1253,42 +1262,42 @@ function ke(e = []) {
|
|
|
1253
1262
|
};
|
|
1254
1263
|
}
|
|
1255
1264
|
/** Minimal HTML-escape so preset names can't break the simulator markup. */
|
|
1256
|
-
function
|
|
1265
|
+
function Oe(e) {
|
|
1257
1266
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
1258
1267
|
}
|
|
1259
|
-
var
|
|
1260
|
-
localStorage.setItem(
|
|
1261
|
-
},
|
|
1268
|
+
var ke = "puzzmo_sim_api_mode", W = "http://localhost:8911", Ae = "https://api.puzzmo.com", G = () => localStorage.getItem(ke) === "dev" ? "dev" : "prod", je = (e) => {
|
|
1269
|
+
localStorage.setItem(ke, e);
|
|
1270
|
+
}, K = null, Me = function() {
|
|
1262
1271
|
var e = t(function* () {
|
|
1263
|
-
if (
|
|
1272
|
+
if (K !== null) return K;
|
|
1264
1273
|
try {
|
|
1265
|
-
let e = new AbortController(), t = setTimeout(() => e.abort(), 1e3), n = yield fetch(`${
|
|
1266
|
-
return clearTimeout(t),
|
|
1274
|
+
let e = new AbortController(), t = setTimeout(() => e.abort(), 1e3), n = yield fetch(`${W}/healthz`, { signal: e.signal });
|
|
1275
|
+
return clearTimeout(t), K = n.ok, K;
|
|
1267
1276
|
} catch (e) {
|
|
1268
|
-
return
|
|
1277
|
+
return K = !1, !1;
|
|
1269
1278
|
}
|
|
1270
1279
|
});
|
|
1271
1280
|
return function() {
|
|
1272
1281
|
return e.apply(this, arguments);
|
|
1273
1282
|
};
|
|
1274
|
-
}(),
|
|
1275
|
-
apiURL:
|
|
1283
|
+
}(), q = () => ({
|
|
1284
|
+
apiURL: G() === "dev" ? W : Ae,
|
|
1276
1285
|
clientID: "protosdk:oauthclient",
|
|
1277
1286
|
redirectUri: `${window.location.origin}/oauth/callback`
|
|
1278
|
-
}),
|
|
1287
|
+
}), Ne = () => {
|
|
1279
1288
|
let e = new Uint8Array(32);
|
|
1280
1289
|
return crypto.getRandomValues(e), Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
1281
|
-
},
|
|
1282
|
-
let e = localStorage.getItem(
|
|
1290
|
+
}, J = "puzzmo_sim_oauth_token", Pe = "puzzmo_sim_oauth_refresh_token", Fe = (e) => localStorage.setItem(J, e), Ie = (e) => localStorage.setItem(Pe, e), Le = () => {
|
|
1291
|
+
let e = localStorage.getItem(J);
|
|
1283
1292
|
return e && `${e.substring(0, 20)}`, e;
|
|
1284
|
-
},
|
|
1285
|
-
localStorage.removeItem(
|
|
1286
|
-
},
|
|
1287
|
-
let e =
|
|
1293
|
+
}, Re = () => localStorage.getItem(Pe), ze = () => {
|
|
1294
|
+
localStorage.removeItem(J), localStorage.removeItem(Pe);
|
|
1295
|
+
}, Be = () => {
|
|
1296
|
+
let e = q(), t = Ne();
|
|
1288
1297
|
sessionStorage.setItem("oauth_state", t), sessionStorage.setItem("oauth_return_url", window.location.href);
|
|
1289
1298
|
let n = new URL(`${e.apiURL}/oauth/auth`);
|
|
1290
1299
|
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();
|
|
1291
|
-
},
|
|
1300
|
+
}, Ve = (e) => {
|
|
1292
1301
|
try {
|
|
1293
1302
|
let t = e.split(".");
|
|
1294
1303
|
if (t.length !== 3) return !0;
|
|
@@ -1297,11 +1306,11 @@ var je = "puzzmo_sim_api_mode", B = "http://localhost:8911", Me = "https://api.p
|
|
|
1297
1306
|
} catch (e) {
|
|
1298
1307
|
return !0;
|
|
1299
1308
|
}
|
|
1300
|
-
},
|
|
1309
|
+
}, He = function() {
|
|
1301
1310
|
var e = t(function* () {
|
|
1302
|
-
let e =
|
|
1311
|
+
let e = Re();
|
|
1303
1312
|
if (!e) return !1;
|
|
1304
|
-
let t =
|
|
1313
|
+
let t = q();
|
|
1305
1314
|
try {
|
|
1306
1315
|
let n = new URLSearchParams({
|
|
1307
1316
|
grant_type: "refresh_token",
|
|
@@ -1315,9 +1324,9 @@ var je = "puzzmo_sim_api_mode", B = "http://localhost:8911", Me = "https://api.p
|
|
|
1315
1324
|
if (!r.ok) return r.statusText, !1;
|
|
1316
1325
|
let i = yield r.json(), a = i.access_token || i.accessToken;
|
|
1317
1326
|
if (!a) return !1;
|
|
1318
|
-
|
|
1327
|
+
Fe(a);
|
|
1319
1328
|
let o = i.refresh_token || i.refreshToken;
|
|
1320
|
-
return o &&
|
|
1329
|
+
return o && Ie(o), !0;
|
|
1321
1330
|
} catch (e) {
|
|
1322
1331
|
return !1;
|
|
1323
1332
|
}
|
|
@@ -1325,9 +1334,9 @@ var je = "puzzmo_sim_api_mode", B = "http://localhost:8911", Me = "https://api.p
|
|
|
1325
1334
|
return function() {
|
|
1326
1335
|
return e.apply(this, arguments);
|
|
1327
1336
|
};
|
|
1328
|
-
}(),
|
|
1337
|
+
}(), Ue = function() {
|
|
1329
1338
|
var e = t(function* (e, t) {
|
|
1330
|
-
let n =
|
|
1339
|
+
let n = q(), r = sessionStorage.getItem("oauth_state");
|
|
1331
1340
|
if (!r || r !== t) return null;
|
|
1332
1341
|
sessionStorage.removeItem("oauth_state");
|
|
1333
1342
|
try {
|
|
@@ -1349,13 +1358,13 @@ var je = "puzzmo_sim_api_mode", B = "http://localhost:8911", Me = "https://api.p
|
|
|
1349
1358
|
return function(t, n) {
|
|
1350
1359
|
return e.apply(this, arguments);
|
|
1351
1360
|
};
|
|
1352
|
-
}(),
|
|
1361
|
+
}(), We = function() {
|
|
1353
1362
|
var e = t(function* (e, t = {}) {
|
|
1354
|
-
let n =
|
|
1363
|
+
let n = q(), r = Le();
|
|
1355
1364
|
if (!r) throw Error("Not authenticated");
|
|
1356
|
-
if (
|
|
1357
|
-
if (r =
|
|
1358
|
-
} else throw
|
|
1365
|
+
if (Ve(r)) if (yield He()) {
|
|
1366
|
+
if (r = Le(), !r) throw Error("Token refresh succeeded but no token available");
|
|
1367
|
+
} else throw ze(), Error("Session expired. Please log in again.");
|
|
1359
1368
|
let i = yield fetch(`${n.apiURL}/graphql`, {
|
|
1360
1369
|
method: "POST",
|
|
1361
1370
|
headers: {
|
|
@@ -1374,7 +1383,7 @@ var je = "puzzmo_sim_api_mode", B = "http://localhost:8911", Me = "https://api.p
|
|
|
1374
1383
|
return function(t) {
|
|
1375
1384
|
return e.apply(this, arguments);
|
|
1376
1385
|
};
|
|
1377
|
-
}(),
|
|
1386
|
+
}(), Ge = (e) => {
|
|
1378
1387
|
try {
|
|
1379
1388
|
let t = e.split(".");
|
|
1380
1389
|
return t.length, t.length === 3 ? JSON.parse(atob(t[1])) : null;
|
|
@@ -1382,15 +1391,15 @@ var je = "puzzmo_sim_api_mode", B = "http://localhost:8911", Me = "https://api.p
|
|
|
1382
1391
|
return null;
|
|
1383
1392
|
}
|
|
1384
1393
|
};
|
|
1385
|
-
function
|
|
1394
|
+
function Ke() {
|
|
1386
1395
|
let e = !1;
|
|
1387
1396
|
return {
|
|
1388
1397
|
id: "auth",
|
|
1389
1398
|
label: "Auth",
|
|
1390
1399
|
render() {
|
|
1391
|
-
let e =
|
|
1400
|
+
let e = Le(), t = !!e, n = G(), r = n === "dev" ? W : Ae, i = `<button class="simulator-btn tiny" id="auth-dev-toggle" style="display: none;">${n === "dev" ? "Using Dev" : "Dev"}</button>`;
|
|
1392
1401
|
if (t) {
|
|
1393
|
-
let t =
|
|
1402
|
+
let t = Ge(e), n = t != null && t.exp ? (/* @__PURE__ */ new Date(t.exp * 1e3)).toLocaleString() : "Unknown", a = !!Re(), o = a ? Ge(Re()) : null, s = o != null && o.exp ? (/* @__PURE__ */ new Date(o.exp * 1e3)).toLocaleString() : null;
|
|
1394
1403
|
return `
|
|
1395
1404
|
<div class="simulator-section">
|
|
1396
1405
|
<div class="simulator-section-title auth-title-row">
|
|
@@ -1431,7 +1440,7 @@ function Ge() {
|
|
|
1431
1440
|
</div>
|
|
1432
1441
|
<p class="auth-description">
|
|
1433
1442
|
Login with your Puzzmo account to make authenticated API requests.
|
|
1434
|
-
${n === "dev" ? `<br><strong>Using local dev server:</strong> ${
|
|
1443
|
+
${n === "dev" ? `<br><strong>Using local dev server:</strong> ${W}` : ""}
|
|
1435
1444
|
</p>
|
|
1436
1445
|
<div class="simulator-row">
|
|
1437
1446
|
<button class="simulator-btn primary" id="auth-login">Login with Puzzmo</button>
|
|
@@ -1442,21 +1451,21 @@ function Ge() {
|
|
|
1442
1451
|
},
|
|
1443
1452
|
bind(n) {
|
|
1444
1453
|
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");
|
|
1445
|
-
e ?
|
|
1446
|
-
e && c && (c.style.display = "",
|
|
1454
|
+
e ? K && c && (c.style.display = "", G() === "dev" && c.classList.add("active")) : (e = !0, Me().then((e) => {
|
|
1455
|
+
e && c && (c.style.display = "", G() === "dev" && c.classList.add("active"));
|
|
1447
1456
|
})), c == null || c.addEventListener("click", () => {
|
|
1448
|
-
|
|
1457
|
+
je(G() === "dev" ? "prod" : "dev"), ze(), window.location.reload();
|
|
1449
1458
|
}), r == null || r.addEventListener("click", () => {
|
|
1450
|
-
|
|
1459
|
+
Be();
|
|
1451
1460
|
}), i == null || i.addEventListener("click", () => {
|
|
1452
|
-
|
|
1461
|
+
ze(), window.location.reload();
|
|
1453
1462
|
}), a == null || a.addEventListener("click", t(function* () {
|
|
1454
|
-
a.disabled = !0, a.textContent = "Refreshing...", (yield
|
|
1463
|
+
a.disabled = !0, a.textContent = "Refreshing...", (yield He()) ? window.location.reload() : (a.textContent = "Refresh Failed", a.disabled = !1);
|
|
1455
1464
|
})), o == null || o.addEventListener("click", t(function* () {
|
|
1456
1465
|
if (s) {
|
|
1457
1466
|
s.innerHTML = "<div class=\"loading\">Loading...</div>";
|
|
1458
1467
|
try {
|
|
1459
|
-
let t = yield
|
|
1468
|
+
let t = yield We("\n query {\n currentUser {\n id\n username\n usernameID\n name\n }\n }\n ");
|
|
1460
1469
|
if (t.errors) {
|
|
1461
1470
|
var e;
|
|
1462
1471
|
s.innerHTML = `<div class="error">Error: ${((e = t.errors[0]) == null ? void 0 : e.message) || "Unknown error"}</div>`;
|
|
@@ -1478,13 +1487,13 @@ function Ge() {
|
|
|
1478
1487
|
if (n && r) {
|
|
1479
1488
|
let t = e.getElement("#auth-status");
|
|
1480
1489
|
t && (t.innerHTML = "<span class=\"indicator waiting\"></span><span>Exchanging code...</span>");
|
|
1481
|
-
let i = yield
|
|
1490
|
+
let i = yield Ue(n, r);
|
|
1482
1491
|
if (window.history.replaceState({}, "", window.location.pathname), i) {
|
|
1483
1492
|
let e = i.access_token || i.accessToken;
|
|
1484
1493
|
if (e) {
|
|
1485
|
-
|
|
1494
|
+
Fe(e);
|
|
1486
1495
|
let t = i.refresh_token || i.refreshToken;
|
|
1487
|
-
t &&
|
|
1496
|
+
t && Ie(t);
|
|
1488
1497
|
}
|
|
1489
1498
|
window.location.reload();
|
|
1490
1499
|
} else {
|
|
@@ -1496,9 +1505,9 @@ function Ge() {
|
|
|
1496
1505
|
}
|
|
1497
1506
|
};
|
|
1498
1507
|
}
|
|
1499
|
-
var
|
|
1500
|
-
localStorage.removeItem(
|
|
1501
|
-
},
|
|
1508
|
+
var qe = "puzzmo_sim_api_mode", Je = "http://localhost:8911", Ye = "https://api.puzzmo.com", Xe = "puzzmo_sim_oauth_token", Ze = "puzzmo_sim_oauth_refresh_token", Qe = () => localStorage.getItem(qe) === "dev" ? "dev" : "prod", $e = () => localStorage.getItem(Xe), et = () => localStorage.getItem(Ze), tt = (e) => localStorage.setItem(Xe, e), nt = (e) => localStorage.setItem(Ze, e), rt = () => {
|
|
1509
|
+
localStorage.removeItem(Xe), localStorage.removeItem(Ze);
|
|
1510
|
+
}, it = (e) => {
|
|
1502
1511
|
try {
|
|
1503
1512
|
let t = e.split(".");
|
|
1504
1513
|
if (t.length !== 3) return !0;
|
|
@@ -1507,11 +1516,11 @@ var Ke = "puzzmo_sim_api_mode", qe = "http://localhost:8911", Je = "https://api.
|
|
|
1507
1516
|
} catch (e) {
|
|
1508
1517
|
return !0;
|
|
1509
1518
|
}
|
|
1510
|
-
},
|
|
1519
|
+
}, at = function() {
|
|
1511
1520
|
var e = t(function* () {
|
|
1512
|
-
let e =
|
|
1521
|
+
let e = et();
|
|
1513
1522
|
if (!e) return !1;
|
|
1514
|
-
let t =
|
|
1523
|
+
let t = Qe() === "dev" ? Je : Ye;
|
|
1515
1524
|
try {
|
|
1516
1525
|
let n = new URLSearchParams({
|
|
1517
1526
|
grant_type: "refresh_token",
|
|
@@ -1525,9 +1534,9 @@ var Ke = "puzzmo_sim_api_mode", qe = "http://localhost:8911", Je = "https://api.
|
|
|
1525
1534
|
if (!r.ok) return !1;
|
|
1526
1535
|
let i = yield r.json(), a = i.access_token || i.accessToken;
|
|
1527
1536
|
if (!a) return !1;
|
|
1528
|
-
|
|
1537
|
+
tt(a);
|
|
1529
1538
|
let o = i.refresh_token || i.refreshToken;
|
|
1530
|
-
return o &&
|
|
1539
|
+
return o && nt(o), !0;
|
|
1531
1540
|
} catch (e) {
|
|
1532
1541
|
return !1;
|
|
1533
1542
|
}
|
|
@@ -1535,13 +1544,13 @@ var Ke = "puzzmo_sim_api_mode", qe = "http://localhost:8911", Je = "https://api.
|
|
|
1535
1544
|
return function() {
|
|
1536
1545
|
return e.apply(this, arguments);
|
|
1537
1546
|
};
|
|
1538
|
-
}(),
|
|
1547
|
+
}(), ot = function() {
|
|
1539
1548
|
var e = t(function* (e, t = {}) {
|
|
1540
|
-
let n =
|
|
1549
|
+
let n = Qe() === "dev" ? Je : Ye, r = $e();
|
|
1541
1550
|
if (!r) throw Error("Not authenticated");
|
|
1542
|
-
if (
|
|
1543
|
-
if (r =
|
|
1544
|
-
} else throw
|
|
1551
|
+
if (it(r)) if (yield at()) {
|
|
1552
|
+
if (r = $e(), !r) throw Error("Token refresh succeeded but no token available");
|
|
1553
|
+
} else throw rt(), Error("Session expired. Please log in again.");
|
|
1545
1554
|
let i = yield fetch(`${n}/graphql`, {
|
|
1546
1555
|
method: "POST",
|
|
1547
1556
|
headers: {
|
|
@@ -1560,19 +1569,19 @@ var Ke = "puzzmo_sim_api_mode", qe = "http://localhost:8911", Je = "https://api.
|
|
|
1560
1569
|
return function(t) {
|
|
1561
1570
|
return e.apply(this, arguments);
|
|
1562
1571
|
};
|
|
1563
|
-
}(),
|
|
1572
|
+
}(), st = "\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", ct = "\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", lt = (e, t) => {
|
|
1564
1573
|
let n = t - 1, r = Math.floor(n / 31), i = n % 31, a = [...e];
|
|
1565
1574
|
for (; a.length <= r;) a.push(0);
|
|
1566
1575
|
return a[r] = a[r] ^ 1 << i, a;
|
|
1567
1576
|
};
|
|
1568
|
-
const
|
|
1569
|
-
function
|
|
1577
|
+
const ut = () => !!$e();
|
|
1578
|
+
function dt() {
|
|
1570
1579
|
let n = null, r = !1, i = null, a = function() {
|
|
1571
1580
|
var e = t(function* (e) {
|
|
1572
1581
|
r = !0, i = null;
|
|
1573
1582
|
try {
|
|
1574
1583
|
var t;
|
|
1575
|
-
let r = yield
|
|
1584
|
+
let r = yield ot(st, { slug: e });
|
|
1576
1585
|
if (r.errors) {
|
|
1577
1586
|
var a;
|
|
1578
1587
|
i = ((a = r.errors[0]) == null ? void 0 : a.message) || "Unknown error", n = null;
|
|
@@ -1589,10 +1598,10 @@ function st() {
|
|
|
1589
1598
|
}(), o = function() {
|
|
1590
1599
|
var r = t(function* (t) {
|
|
1591
1600
|
if (!n) return;
|
|
1592
|
-
let r =
|
|
1601
|
+
let r = lt(n.featuresArr, t);
|
|
1593
1602
|
try {
|
|
1594
1603
|
var i;
|
|
1595
|
-
let t = yield
|
|
1604
|
+
let t = yield ot(ct, {
|
|
1596
1605
|
gameSlug: n.slug,
|
|
1597
1606
|
input: { featuresArr: r }
|
|
1598
1607
|
});
|
|
@@ -1640,7 +1649,7 @@ function st() {
|
|
|
1640
1649
|
id: "features",
|
|
1641
1650
|
label: "Features",
|
|
1642
1651
|
render() {
|
|
1643
|
-
return
|
|
1652
|
+
return ut() ? `
|
|
1644
1653
|
<div class="features-view-container">
|
|
1645
1654
|
<div class="simulator-section">
|
|
1646
1655
|
<div class="simulator-section-title">Game Features</div>
|
|
@@ -1681,7 +1690,7 @@ function st() {
|
|
|
1681
1690
|
e && (yield d(e));
|
|
1682
1691
|
})), i == null || i.addEventListener("keypress", (e) => {
|
|
1683
1692
|
e.key === "Enter" && (r == null || r.click());
|
|
1684
|
-
}), console.log("[FeaturesView] bind called, ctx.gameSlug:", e.gameSlug, "slugInput:", i), e.gameSlug && i && (i.value = e.gameSlug,
|
|
1693
|
+
}), console.log("[FeaturesView] bind called, ctx.gameSlug:", e.gameSlug, "slugInput:", i), e.gameSlug && i && (i.value = e.gameSlug, ut() && !n && d(e.gameSlug)), u();
|
|
1685
1694
|
},
|
|
1686
1695
|
onActivate(e) {
|
|
1687
1696
|
let t = e.getElement("#simulator-tab-features");
|
|
@@ -1689,8 +1698,141 @@ function st() {
|
|
|
1689
1698
|
}
|
|
1690
1699
|
};
|
|
1691
1700
|
}
|
|
1701
|
+
/**
|
|
1702
|
+
* The on-screen keyboard, drawn under the game at the size the real host draws it, so a game can be
|
|
1703
|
+
* checked against the space it actually gets on a touch device.
|
|
1704
|
+
*
|
|
1705
|
+
* The sizes here — both heights, the key widths, the row split, the drag-cursor thresholds — are
|
|
1706
|
+
* mirrored from `@puzzmo-com/keyboard` (PlayGameKeyboard.tsx, Letter.tsx), which is what puzzmo.com
|
|
1707
|
+
* renders. That package is workspace-private and React; this one is published to npm with a single
|
|
1708
|
+
* dependency, so it cannot be imported. The numbers have to be kept in step by hand.
|
|
1709
|
+
*
|
|
1710
|
+
* The wireframe styling is deliberate: only the box model is faithful, so only the box model is
|
|
1711
|
+
* drawn. Key icons, press animation, key repeat, haptics and the game's own `keyStyles`/`kbdStyles`
|
|
1712
|
+
* are all dropped rather than approximated.
|
|
1713
|
+
*/
|
|
1714
|
+
/** Space the keys occupy. */
|
|
1715
|
+
var ft = 200, pt = 24;
|
|
1716
|
+
/** What the keyboard takes off the bottom of the game, and what the game must lay out without. */
|
|
1717
|
+
const Y = ft + pt;
|
|
1718
|
+
/** Drag-cursor thresholds, from useKeyboardCursor in @puzzmo-com/keyboard. */
|
|
1719
|
+
var mt = 6, ht = 2.5, gt = 100, _t = (e, t) => e ? "14.7%" : t ? "17.85%" : "9.75%", X = (e, t) => {
|
|
1720
|
+
let n = e.replace("#", ""), r = n.length === 3 ? [...n].map((e) => e + e).join("") : n, i = parseInt(r, 16);
|
|
1721
|
+
return r.length !== 6 || Number.isNaN(i) ? e : `rgba(${i >> 16 & 255}, ${i >> 8 & 255}, ${i & 255}, ${t})`;
|
|
1722
|
+
}, vt = (e) => e.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<"), yt = (e) => e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
1723
|
+
function bt(e) {
|
|
1724
|
+
let { theme: t, sendToGame: n } = e, r = !1, i = null, a = null, o = document.createElement("style");
|
|
1725
|
+
o.id = "sim-docked-kbd-page-style", o.textContent = `
|
|
1726
|
+
html.sim-kbd-docked #simulator {
|
|
1727
|
+
bottom: ${Y + 4}px;
|
|
1728
|
+
}
|
|
1729
|
+
`;
|
|
1730
|
+
/** The element the game mounted into: `#root` per the SDK's page template, else the page's first element. */
|
|
1731
|
+
let s = () => {
|
|
1732
|
+
var e;
|
|
1733
|
+
return (e = document.getElementById("root")) == null ? document.body.firstElementChild : e;
|
|
1734
|
+
}, c = null, l = () => {
|
|
1735
|
+
let e = s();
|
|
1736
|
+
if (!e || c) return;
|
|
1737
|
+
let { height: t, maxHeight: n, position: r } = e.style;
|
|
1738
|
+
c = () => {
|
|
1739
|
+
e.style.height = t, e.style.maxHeight = n, e.style.position = r, c = null;
|
|
1740
|
+
}, e.style.height = `calc(100% - ${Y}px)`, e.style.maxHeight = `calc(100% - ${Y}px)`, getComputedStyle(e).position === "static" && (e.style.position = "relative");
|
|
1741
|
+
}, u = (e, n) => {
|
|
1742
|
+
var r, i;
|
|
1743
|
+
let a = (r = n.symbols[e]) == null ? e : r, o = n.disabled.includes(e), s = n.highlight.includes(e), c = (i = n.flexGrowSymbols) == null ? void 0 : i.includes(e), l = [
|
|
1744
|
+
`width:${_t(n.l.includes(e), n.xl.includes(e))}`,
|
|
1745
|
+
`flex:${c ? "1 0 auto" : "0 1 auto"}`,
|
|
1746
|
+
"height:100%",
|
|
1747
|
+
"display:flex",
|
|
1748
|
+
"align-items:center",
|
|
1749
|
+
"justify-content:center",
|
|
1750
|
+
"padding:0 3px 12px",
|
|
1751
|
+
"position:relative",
|
|
1752
|
+
o ? "pointer-events:none" : ""
|
|
1753
|
+
].filter(Boolean).join(";"), u = [
|
|
1754
|
+
"display:flex",
|
|
1755
|
+
"align-items:center",
|
|
1756
|
+
"justify-content:center",
|
|
1757
|
+
"width:100%",
|
|
1758
|
+
"height:100%",
|
|
1759
|
+
"box-sizing:border-box",
|
|
1760
|
+
"border-radius:3px",
|
|
1761
|
+
"overflow:hidden",
|
|
1762
|
+
"background:transparent",
|
|
1763
|
+
"pointer-events:none",
|
|
1764
|
+
`border:${o ? `1px dashed ${X(t.fg, .25)}` : s ? `2px solid ${X(t.fg, .75)}` : `1px solid ${X(t.fg, .4)}`}`
|
|
1765
|
+
].join(";"), d = [
|
|
1766
|
+
"font:11px/1 Menlo, Monaco, Consolas, monospace",
|
|
1767
|
+
"letter-spacing:0.5px",
|
|
1768
|
+
"text-transform:uppercase",
|
|
1769
|
+
"white-space:nowrap",
|
|
1770
|
+
`color:${X(t.fg, o ? .3 : .65)}`
|
|
1771
|
+
].join(";");
|
|
1772
|
+
return `<div class="sim-docked-kbd-key" data-key="${vt(e)}" style="${l}">
|
|
1773
|
+
<div class="sim-docked-kbd-key-inner" style="${u}"><div style="${d}">${yt(a)}</div></div>
|
|
1774
|
+
</div>`;
|
|
1775
|
+
}, d = (e) => {
|
|
1776
|
+
let n = e.layout.filter((e) => !!e), r = `calc(100% / ${n.length})`;
|
|
1777
|
+
return `${n.map((t, n) => {
|
|
1778
|
+
var i, a;
|
|
1779
|
+
return `<div style="${`height:${r};display:flex;flex-direction:row;align-items:center;justify-content:${(i = (a = e.rowPositioning) == null ? void 0 : a[n]) == null ? "center" : i}`}">${[...t].map((t) => u(t, e)).join("")}</div>`;
|
|
1780
|
+
}).join("")}${`<div id="sim-docked-kbd-cursor" style="position:absolute;inset:0;z-index:1;background:${X(t.fg, .12)};opacity:0;transition:opacity 0.1s ease-in-out;pointer-events:none"></div>`}`;
|
|
1781
|
+
}, f = !1, p = [0, 0], m = null, h = 0, g = null, _ = null, v = (e) => {
|
|
1782
|
+
let t = a == null ? void 0 : a.querySelector("#sim-docked-kbd-cursor");
|
|
1783
|
+
t && (t.style.opacity = e ? "0.5" : "0");
|
|
1784
|
+
}, y = () => {
|
|
1785
|
+
f = !1, p = [0, 0], m = null, h = 0, g = null, _ = null, v(!1);
|
|
1786
|
+
}, b = (e) => {
|
|
1787
|
+
var t, n;
|
|
1788
|
+
return (t = (n = document.elementFromPoint(e.clientX, e.clientY)) == null || (n = n.closest(".sim-docked-kbd-key")) == null ? void 0 : n.getAttribute("data-key")) == null ? null : t;
|
|
1789
|
+
}, x = (e) => {
|
|
1790
|
+
_ = b(e), a == null || a.setPointerCapture(e.pointerId);
|
|
1791
|
+
}, ee = (e) => {
|
|
1792
|
+
!(i != null && i.supportsDragCursor) || !_ || m && m.clientX === e.clientX && m.clientY === e.clientY || (m && m.pointerId !== e.pointerId && (h = 0, g = null), g || (g = Date.now()), f || (h += 1, h >= mt && Date.now() - g >= gt && (f = !0, v(!0))), f && m && (p = [p[0] + (e.clientX - m.clientX) * ht, p[1] + (e.clientY - m.clientY) * ht]), m = {
|
|
1793
|
+
clientX: e.clientX,
|
|
1794
|
+
clientY: e.clientY,
|
|
1795
|
+
pointerId: e.pointerId
|
|
1796
|
+
}, f && n("KEYBOARD_CURSOR_CHANGE", { position: p }));
|
|
1797
|
+
}, S = (e) => {
|
|
1798
|
+
f ? n("KEYBOARD_CURSOR_END", {}) : _ && b(e) === _ && n("KEYBOARD_KEY_PRESS", { key: _ }), y();
|
|
1799
|
+
}, C = () => {
|
|
1800
|
+
a || !i || (a = document.createElement("div"), a.id = "sim-docked-kbd", a.style.cssText = [
|
|
1801
|
+
"position:fixed",
|
|
1802
|
+
"left:0",
|
|
1803
|
+
"right:0",
|
|
1804
|
+
"bottom:0",
|
|
1805
|
+
`height:${Y}px`,
|
|
1806
|
+
"box-sizing:border-box",
|
|
1807
|
+
"padding-top:8px",
|
|
1808
|
+
`padding-bottom:${pt}px`,
|
|
1809
|
+
"display:flex",
|
|
1810
|
+
"flex-direction:column",
|
|
1811
|
+
"z-index:999998",
|
|
1812
|
+
"touch-action:none",
|
|
1813
|
+
"user-select:none",
|
|
1814
|
+
"-webkit-user-select:none",
|
|
1815
|
+
`background:${t.a_bg}`,
|
|
1816
|
+
`border-top:1px solid ${X(t.fg, .2)}`
|
|
1817
|
+
].join(";"), a.innerHTML = d(i), a.addEventListener("pointerdown", x), a.addEventListener("pointermove", ee), a.addEventListener("pointerup", S), a.addEventListener("pointercancel", () => y()), a.addEventListener("contextmenu", (e) => e.preventDefault()), document.body.appendChild(a), o.isConnected || document.head.appendChild(o), document.documentElement.classList.add("sim-kbd-docked"), l());
|
|
1818
|
+
}, te = () => {
|
|
1819
|
+
a && (a.remove(), a = null, document.documentElement.classList.remove("sim-kbd-docked"), c == null || c(), y());
|
|
1820
|
+
}, ne = () => {
|
|
1821
|
+
if (!r || !i) return te();
|
|
1822
|
+
if (!a) return C();
|
|
1823
|
+
a.innerHTML = d(i), v(f);
|
|
1824
|
+
};
|
|
1825
|
+
return {
|
|
1826
|
+
setEnabled(e) {
|
|
1827
|
+
r = e, ne();
|
|
1828
|
+
},
|
|
1829
|
+
setConfig(e) {
|
|
1830
|
+
i = e, ne();
|
|
1831
|
+
}
|
|
1832
|
+
};
|
|
1833
|
+
}
|
|
1692
1834
|
/** Renders a single keyboard key as an HTML button string */
|
|
1693
|
-
var
|
|
1835
|
+
var xt = (e, t) => {
|
|
1694
1836
|
var n, r;
|
|
1695
1837
|
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);
|
|
1696
1838
|
return `<button class="${[
|
|
@@ -1701,35 +1843,50 @@ var ct = (e, t) => {
|
|
|
1701
1843
|
c ? "l" : "",
|
|
1702
1844
|
l ? "grow" : ""
|
|
1703
1845
|
].filter(Boolean).join(" ")}" data-key="${e}" ${a ? "disabled" : ""}>${i}</button>`;
|
|
1704
|
-
},
|
|
1705
|
-
function
|
|
1706
|
-
let e = null, t = () => e ?
|
|
1846
|
+
}, St = (e) => `<div class="sim-kb">${e.layout.filter((e) => e != null).map((t) => `<div class="sim-kb-row">${[...t].map((t) => xt(t, e)).join("")}</div>`).join("")}</div>`;
|
|
1847
|
+
function Ct() {
|
|
1848
|
+
let e = null, t = null, n = (t) => e ? t ? `<div class="sim-kb-empty">Shown under the game at production size, taking ${Y}px off the bottom.<br>Uncheck to preview the layout here instead.</div>` : St(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>";
|
|
1707
1849
|
return {
|
|
1708
1850
|
id: "kbd",
|
|
1709
1851
|
label: "Kbd",
|
|
1710
1852
|
render() {
|
|
1711
1853
|
return `
|
|
1712
1854
|
<div class="keyboard-view-container">
|
|
1855
|
+
<div class="simulator-field">
|
|
1856
|
+
<label class="sim-settings-row">
|
|
1857
|
+
<input type="checkbox" id="sim-kb-dock" />
|
|
1858
|
+
<span class="simulator-label">Show keyboard under game</span>
|
|
1859
|
+
</label>
|
|
1860
|
+
</div>
|
|
1713
1861
|
<div id="sim-kb-content">
|
|
1714
|
-
${
|
|
1862
|
+
${n(!1)}
|
|
1715
1863
|
</div>
|
|
1716
1864
|
</div>
|
|
1717
1865
|
`;
|
|
1718
1866
|
},
|
|
1719
1867
|
bind(e) {
|
|
1720
|
-
|
|
1868
|
+
t != null || (t = bt({
|
|
1869
|
+
theme: e.state.selectedTheme,
|
|
1870
|
+
sendToGame: e.sendToGame
|
|
1871
|
+
})), t.setEnabled(e.state.keyboardDocked);
|
|
1872
|
+
let n = e.getElement("#sim-kb-dock");
|
|
1873
|
+
n && (n.checked = e.state.keyboardDocked, n.addEventListener("change", () => {
|
|
1874
|
+
e.state.keyboardDocked = n.checked, m(n.checked), t == null || t.setEnabled(n.checked), r(e);
|
|
1875
|
+
})), wt(e);
|
|
1721
1876
|
},
|
|
1722
|
-
onMessage(n,
|
|
1723
|
-
var
|
|
1724
|
-
|
|
1725
|
-
e = !(!(r == null || (a = r.layout) == null) && a.length) || r.layout.every((e) => !e) ? null : r;
|
|
1726
|
-
let o = i.getElement("#sim-kb-content");
|
|
1727
|
-
o && (o.innerHTML = t(), dt(i)), i.updateBadge("kbd", void 0);
|
|
1877
|
+
onMessage(n, i, a) {
|
|
1878
|
+
var o;
|
|
1879
|
+
n === "KEYBOARD_UPDATE_CONFIG" && (e = !(!(i == null || (o = i.layout) == null) && o.length) || i.layout.every((e) => !e) ? null : i, t == null || t.setConfig(e), r(a));
|
|
1728
1880
|
}
|
|
1729
1881
|
};
|
|
1882
|
+
/** Re-render the tab's own content (not the dock) and rebind its keys. */
|
|
1883
|
+
function r(e) {
|
|
1884
|
+
let t = e.getElement("#sim-kb-content");
|
|
1885
|
+
t && (t.innerHTML = n(e.state.keyboardDocked), wt(e));
|
|
1886
|
+
}
|
|
1730
1887
|
}
|
|
1731
1888
|
/** Attach click handlers to all rendered keys */
|
|
1732
|
-
function
|
|
1889
|
+
function wt(e) {
|
|
1733
1890
|
var t;
|
|
1734
1891
|
let n = (t = e.getElement("#sim-kb-content")) == null ? void 0 : t.querySelectorAll(".sim-kb-key");
|
|
1735
1892
|
n == null || n.forEach((t) => {
|
|
@@ -1744,15 +1901,15 @@ function dt(e) {
|
|
|
1744
1901
|
* change values (persisted to localStorage and pushed to the game as SETTINGS_UPDATE, matching the
|
|
1745
1902
|
* production host) and reflects UPDATE_SETTINGS_FROM_EMBED writes coming from the game.
|
|
1746
1903
|
*/
|
|
1747
|
-
function
|
|
1904
|
+
function Tt() {
|
|
1748
1905
|
let t = (e) => {
|
|
1749
1906
|
let t = e.state.settingsComponents;
|
|
1750
|
-
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) =>
|
|
1907
|
+
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) => Et(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>`;
|
|
1751
1908
|
}, n = (e) => {
|
|
1752
1909
|
let n = e.getElement("#sim-settings-content");
|
|
1753
1910
|
n && (n.innerHTML = t(e), i(e));
|
|
1754
1911
|
}, r = (e) => {
|
|
1755
|
-
|
|
1912
|
+
S(e.state.gameSettings), e.sendToGame("SETTINGS_UPDATE", e.state.gameSettings);
|
|
1756
1913
|
}, i = (t) => {
|
|
1757
1914
|
var i;
|
|
1758
1915
|
let a = t.getElement("#sim-settings-content");
|
|
@@ -1768,7 +1925,7 @@ function ft() {
|
|
|
1768
1925
|
});
|
|
1769
1926
|
}), (i = a.querySelector("#sim-settings-reset")) == null || i.addEventListener("click", () => {
|
|
1770
1927
|
var e;
|
|
1771
|
-
|
|
1928
|
+
C(), t.state.gameSettings = Dt((e = t.state.settingsComponents) == null ? [] : e), r(t), n(t);
|
|
1772
1929
|
}));
|
|
1773
1930
|
};
|
|
1774
1931
|
return {
|
|
@@ -1783,21 +1940,21 @@ function ft() {
|
|
|
1783
1940
|
onMessage(t, r, i) {
|
|
1784
1941
|
if (t === "INITIALIZE_SETTINGS") {
|
|
1785
1942
|
var a;
|
|
1786
|
-
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),
|
|
1943
|
+
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), S(i.state.gameSettings), n(i);
|
|
1787
1944
|
return;
|
|
1788
1945
|
}
|
|
1789
|
-
t === "UPDATE_SETTINGS_FROM_EMBED" && (i.state.gameSettings = e(e({}, i.state.gameSettings), r == null ? void 0 : r.settings),
|
|
1946
|
+
t === "UPDATE_SETTINGS_FROM_EMBED" && (i.state.gameSettings = e(e({}, i.state.gameSettings), r == null ? void 0 : r.settings), S(i.state.gameSettings), n(i));
|
|
1790
1947
|
}
|
|
1791
1948
|
};
|
|
1792
1949
|
}
|
|
1793
1950
|
/** Renders a single settings UI component as HTML, reading its current value from `settings` */
|
|
1794
|
-
function
|
|
1951
|
+
function Et(e, t) {
|
|
1795
1952
|
switch (e.type) {
|
|
1796
1953
|
case "title": return `<div class="sim-settings-heading">${Q(e.value)}</div>`;
|
|
1797
1954
|
case "subtitle": return `<div class="sim-settings-subheading">${Q(e.value)}</div>`;
|
|
1798
1955
|
case "paragraph": return `<p class="sim-settings-paragraph">${Q(e.value)}</p>`;
|
|
1799
1956
|
case "separator": return "<div class=\"simulator-divider\"></div>";
|
|
1800
|
-
case "split": return `<div class="sim-settings-split">${e.content.map((e) =>
|
|
1957
|
+
case "split": return `<div class="sim-settings-split">${e.content.map((e) => Et(e, t)).join("")}</div>`;
|
|
1801
1958
|
case "boolean": {
|
|
1802
1959
|
var n;
|
|
1803
1960
|
let r = ((n = t[e.name]) == null ? e.defaultValue : n) ? "checked" : "", i = e.subtitle ? `<div class="sim-settings-subtitle">${Q(e.subtitle)}</div>` : "";
|
|
@@ -1865,9 +2022,9 @@ function Z(e) {
|
|
|
1865
2022
|
return `<span class="simulator-label">${Q(e.title)}</span>${t}`;
|
|
1866
2023
|
}
|
|
1867
2024
|
/** Collects name → defaultValue pairs from components, recursing into split groups */
|
|
1868
|
-
function
|
|
2025
|
+
function Dt(e) {
|
|
1869
2026
|
let t = {};
|
|
1870
|
-
for (let n of e) n.type === "split" ? Object.assign(t,
|
|
2027
|
+
for (let n of e) n.type === "split" ? Object.assign(t, Dt(n.content)) : "name" in n && (t[n.name] = n.defaultValue);
|
|
1871
2028
|
return t;
|
|
1872
2029
|
}
|
|
1873
2030
|
function Q(e) {
|
|
@@ -1875,11 +2032,11 @@ function Q(e) {
|
|
|
1875
2032
|
}
|
|
1876
2033
|
var $ = null;
|
|
1877
2034
|
/** True when the game is embedded in the real Puzzmo app, which sets `?developer=true` on the iframe. */
|
|
1878
|
-
function
|
|
2035
|
+
function Ot() {
|
|
1879
2036
|
return typeof window > "u" ? !1 : new URLSearchParams(window.location.search).has("developer");
|
|
1880
2037
|
}
|
|
1881
2038
|
/** Inert instance returned when the simulator declines to boot (the app is the host). */
|
|
1882
|
-
var
|
|
2039
|
+
var kt = {
|
|
1883
2040
|
updateFixtures: () => {},
|
|
1884
2041
|
sendToGame: () => {},
|
|
1885
2042
|
loadPuzzle: function() {
|
|
@@ -1928,28 +2085,28 @@ var gt = {
|
|
|
1928
2085
|
* Fixtures are loaded as raw strings and passed to the game verbatim (any text format works; the game parses it).
|
|
1929
2086
|
* This will show dropdowns in the Ctrl tab to select category and puzzle.
|
|
1930
2087
|
*/
|
|
1931
|
-
function
|
|
2088
|
+
function At(e = {}) {
|
|
1932
2089
|
var n, r, i;
|
|
1933
|
-
if (
|
|
2090
|
+
if (Ot()) return console.log("[Simulator] developer=true in URL — running inside the Puzzmo app, skipping simulator boot"), kt;
|
|
1934
2091
|
if (console.log("[Simulator] createSimulator called with config:", {
|
|
1935
2092
|
slug: e.slug,
|
|
1936
2093
|
hasFixtures: !!e.fixtures
|
|
1937
2094
|
}), $) return e.fixtures && (console.log("[Simulator] Instance already exists, updating fixtures"), $.updateFixtures(e.fixtures)), $;
|
|
1938
|
-
let a = (n = e.autoStart) == null ? !0 : n, o = e.fixtures ?
|
|
1939
|
-
|
|
1940
|
-
|
|
2095
|
+
let a = (n = e.autoStart) == null ? !0 : n, o = e.fixtures ? oe(e.fixtures) : null, s = o ? Array.from(o.keys()).sort() : [], c = me(), l = Ce(), u = [
|
|
2096
|
+
ce(),
|
|
2097
|
+
le(),
|
|
1941
2098
|
c,
|
|
1942
|
-
|
|
1943
|
-
|
|
2099
|
+
he(),
|
|
2100
|
+
ge(),
|
|
1944
2101
|
l,
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
2102
|
+
Te(),
|
|
2103
|
+
De(e.hostContextPresets),
|
|
2104
|
+
Ke(),
|
|
2105
|
+
dt(),
|
|
2106
|
+
Ct(),
|
|
2107
|
+
Tt(),
|
|
1951
2108
|
...(r = e.views) == null ? [] : r
|
|
1952
|
-
], d = u.map((e) => e.id), f =
|
|
2109
|
+
], d = u.map((e) => e.id), f = ee(e, s, d), p = {
|
|
1953
2110
|
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>",
|
|
1954
2111
|
play: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><polygon points=\"2,1 9,5 2,9\"/></svg>",
|
|
1955
2112
|
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>",
|
|
@@ -1957,7 +2114,7 @@ function _t(e = {}) {
|
|
|
1957
2114
|
minimize: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><rect x=\"1\" y=\"4\" width=\"8\" height=\"2\"/></svg>",
|
|
1958
2115
|
expand: "<svg width=\"8\" height=\"8\" viewBox=\"0 0 8 8\" fill=\"currentColor\"><polygon points=\"1,1 7,4 1,7\"/></svg>"
|
|
1959
2116
|
}, m = document.createElement("div");
|
|
1960
|
-
m.id = "simulator", m.dataset.puzzmoBuild =
|
|
2117
|
+
m.id = "simulator", m.dataset.puzzmoBuild = se, m.innerHTML = `
|
|
1961
2118
|
<style>
|
|
1962
2119
|
:root {
|
|
1963
2120
|
--sim-bg: #1a1a2e;
|
|
@@ -3304,27 +3461,27 @@ function _t(e = {}) {
|
|
|
3304
3461
|
</div>
|
|
3305
3462
|
</div>
|
|
3306
3463
|
`, document.body.appendChild(m);
|
|
3307
|
-
let
|
|
3308
|
-
|
|
3309
|
-
},
|
|
3310
|
-
let n =
|
|
3311
|
-
n && (n.textContent = e), r && (r.className = `indicator ${t}`, r.textContent = i),
|
|
3312
|
-
},
|
|
3313
|
-
t && t !== "0" ?
|
|
3314
|
-
},
|
|
3464
|
+
let h = m.querySelector("#simulator-panel"), g = m.querySelector("#simulator-header"), _ = m.querySelector("#simulator-header-indicator"), v = m.querySelector("#simulator-header-status-text"), y = m.querySelector("#simulator-header-pause"), b = m.querySelector("#simulator-header-retry"), x = m.querySelector("#simulator-header-settings"), S = m.querySelector("#simulator-toggle"), C = m.querySelector("#simulator-timer"), w = m.querySelector("#simulator-tabs"), T = m.querySelector("#simulator-content"), E = (e) => m.querySelector(e), D = (e) => {
|
|
3465
|
+
y.innerHTML = e ? p.play : p.pause, y.title = e ? "Resume" : "Pause";
|
|
3466
|
+
}, O = (e, t) => {
|
|
3467
|
+
let n = E("#simulator-status .text"), r = E("#simulator-status .indicator"), i = t === "complete" ? "✓" : "";
|
|
3468
|
+
n && (n.textContent = e), r && (r.className = `indicator ${t}`, r.textContent = i), _.className = t, _.textContent = i, v.textContent = e;
|
|
3469
|
+
}, k = (e, t) => {
|
|
3470
|
+
t && t !== "0" ? C.innerHTML = `${e}<span class="penalty">+${t}</span>` : C.textContent = e;
|
|
3471
|
+
}, A = (e) => {
|
|
3315
3472
|
var t;
|
|
3316
|
-
f.activeTab = e,
|
|
3473
|
+
f.activeTab = e, T.classList.remove("hidden"), ne(e), w.querySelectorAll(".simulator-tab").forEach((t) => {
|
|
3317
3474
|
t.classList.toggle("active", t.getAttribute("data-tab") === e);
|
|
3318
3475
|
}), m.querySelectorAll(".simulator-tab-content").forEach((t) => {
|
|
3319
3476
|
t.classList.toggle("active", t.id === `simulator-tab-${e}`);
|
|
3320
|
-
}),
|
|
3477
|
+
}), x.classList.toggle("active", e === "auth");
|
|
3321
3478
|
let n = u.find((t) => t.id === e);
|
|
3322
|
-
n == null || (t = n.onActivate) == null || t.call(n,
|
|
3323
|
-
},
|
|
3324
|
-
f.isCollapsed = e,
|
|
3325
|
-
},
|
|
3326
|
-
l.updatePreview(
|
|
3327
|
-
},
|
|
3479
|
+
n == null || (t = n.onActivate) == null || t.call(n, L);
|
|
3480
|
+
}, j = (e) => {
|
|
3481
|
+
f.isCollapsed = e, h.classList.toggle("collapsed", e), te(e), e ? (T.classList.add("hidden"), w.querySelectorAll(".simulator-tab").forEach((e) => e.classList.remove("active"))) : A(f.activeTab);
|
|
3482
|
+
}, M = () => {
|
|
3483
|
+
l.updatePreview(L);
|
|
3484
|
+
}, N = function() {
|
|
3328
3485
|
var e = t(function* () {
|
|
3329
3486
|
var e, t;
|
|
3330
3487
|
if (f.appliedPuzzleOverride !== null) return f.appliedPuzzleOverride;
|
|
@@ -3338,58 +3495,58 @@ function _t(e = {}) {
|
|
|
3338
3495
|
category: n,
|
|
3339
3496
|
puzzle: i
|
|
3340
3497
|
}), f.originalPuzzle = a;
|
|
3341
|
-
let c =
|
|
3342
|
-
return c && (c.value = f.originalPuzzle), f.activeTab === "thumb" &&
|
|
3498
|
+
let c = E("#simulator-puzzle");
|
|
3499
|
+
return c && (c.value = f.originalPuzzle), f.activeTab === "thumb" && M(), f.puzzleData;
|
|
3343
3500
|
});
|
|
3344
3501
|
return function() {
|
|
3345
3502
|
return e.apply(this, arguments);
|
|
3346
3503
|
};
|
|
3347
|
-
}(),
|
|
3348
|
-
c.addLogEntry(e,
|
|
3349
|
-
}),
|
|
3350
|
-
|
|
3351
|
-
},
|
|
3504
|
+
}(), P = re((e) => {
|
|
3505
|
+
c.addLogEntry(e, L);
|
|
3506
|
+
}), F = (e, t) => {
|
|
3507
|
+
ie(e, t, P);
|
|
3508
|
+
}, I = (e, t) => {
|
|
3352
3509
|
let n = m.querySelector(`[data-badge="${e}"]`);
|
|
3353
3510
|
n && (n.textContent = t && t > 0 ? String(t) : "");
|
|
3354
|
-
},
|
|
3511
|
+
}, L = {
|
|
3355
3512
|
state: f,
|
|
3356
|
-
getElement:
|
|
3357
|
-
sendToGame:
|
|
3358
|
-
logMessage:
|
|
3359
|
-
loadPuzzle:
|
|
3360
|
-
updateStatus:
|
|
3361
|
-
updateTimer:
|
|
3362
|
-
setCollapsed:
|
|
3363
|
-
switchTab:
|
|
3364
|
-
updateThumbnail:
|
|
3365
|
-
updateBadge:
|
|
3513
|
+
getElement: E,
|
|
3514
|
+
sendToGame: F,
|
|
3515
|
+
logMessage: P.log,
|
|
3516
|
+
loadPuzzle: N,
|
|
3517
|
+
updateStatus: O,
|
|
3518
|
+
updateTimer: k,
|
|
3519
|
+
setCollapsed: j,
|
|
3520
|
+
switchTab: A,
|
|
3521
|
+
updateThumbnail: M,
|
|
3522
|
+
updateBadge: I,
|
|
3366
3523
|
fixtures: o,
|
|
3367
3524
|
fixtureCategories: s,
|
|
3368
3525
|
gameSlug: (i = e.slug) == null ? null : i
|
|
3369
3526
|
};
|
|
3370
|
-
console.log("[Simulator] Context created with gameSlug:",
|
|
3527
|
+
console.log("[Simulator] Context created with gameSlug:", L.gameSlug), u.forEach((e) => e.bind(L)), w.querySelectorAll(".simulator-tab").forEach((e) => {
|
|
3371
3528
|
e.addEventListener("click", () => {
|
|
3372
3529
|
let t = e.getAttribute("data-tab");
|
|
3373
|
-
|
|
3530
|
+
A(t), I(t, 0);
|
|
3374
3531
|
});
|
|
3375
|
-
}),
|
|
3376
|
-
e.stopPropagation(),
|
|
3377
|
-
}),
|
|
3378
|
-
e.stopPropagation(), f.isPaused ? (
|
|
3379
|
-
let t =
|
|
3532
|
+
}), S.addEventListener("click", (e) => {
|
|
3533
|
+
e.stopPropagation(), j(!0);
|
|
3534
|
+
}), y.addEventListener("click", (e) => {
|
|
3535
|
+
e.stopPropagation(), f.isPaused ? (F("RESUME_GAME", {}), f.isPaused = !1, D(!1), O("Running", "ready")) : (F("PAUSE_GAME", {}), f.isPaused = !0, D(!0), O("Paused", "paused"));
|
|
3536
|
+
let t = E("#simulator-pause");
|
|
3380
3537
|
t && (t.textContent = f.isPaused ? "Resume" : "Pause");
|
|
3381
|
-
}),
|
|
3382
|
-
e.stopPropagation(),
|
|
3383
|
-
let t =
|
|
3538
|
+
}), b.addEventListener("click", (e) => {
|
|
3539
|
+
e.stopPropagation(), F("RETRY_PUZZLE", {}), f.hasStarted = !1, f.isPaused = !1, D(!1), y.disabled = !0, O("Ready to retry", "ready");
|
|
3540
|
+
let t = E("#simulator-pause"), n = E("#simulator-start");
|
|
3384
3541
|
t && (t.disabled = !0, t.textContent = "Pause"), n && (n.textContent = "Start");
|
|
3385
|
-
}),
|
|
3386
|
-
e.stopPropagation(), f.isCollapsed &&
|
|
3387
|
-
}),
|
|
3388
|
-
f.isCollapsed && e.target !==
|
|
3389
|
-
}), f.isCollapsed ||
|
|
3390
|
-
let
|
|
3391
|
-
(
|
|
3392
|
-
let
|
|
3542
|
+
}), x.addEventListener("click", (e) => {
|
|
3543
|
+
e.stopPropagation(), f.isCollapsed && j(!1), A("auth");
|
|
3544
|
+
}), g.addEventListener("click", (e) => {
|
|
3545
|
+
f.isCollapsed && e.target !== S && j(!1);
|
|
3546
|
+
}), f.isCollapsed || A(f.activeTab);
|
|
3547
|
+
let R = new URLSearchParams(window.location.search);
|
|
3548
|
+
(R.has("code") || R.has("error")) && (j(!1), A("auth"));
|
|
3549
|
+
let z = (e) => ({
|
|
3393
3550
|
userState: {
|
|
3394
3551
|
gameSettings: { "proto-game": f.gameSettings },
|
|
3395
3552
|
id: "simulator-user",
|
|
@@ -3430,42 +3587,42 @@ function _t(e = {}) {
|
|
|
3430
3587
|
theme: f.selectedTheme,
|
|
3431
3588
|
hostContext: f.hostContext,
|
|
3432
3589
|
appRuntimeContract: "1.0"
|
|
3433
|
-
}),
|
|
3590
|
+
}), B = function() {
|
|
3434
3591
|
var e = t(function* () {
|
|
3435
|
-
|
|
3592
|
+
O("Loading puzzle...", "waiting");
|
|
3436
3593
|
try {
|
|
3437
|
-
let e =
|
|
3438
|
-
|
|
3594
|
+
let e = z(yield N());
|
|
3595
|
+
O("Sending READY_DATA...", "waiting"), F("READY_DATA", e), O("Waiting for game to load...", "waiting");
|
|
3439
3596
|
} catch (e) {
|
|
3440
|
-
|
|
3597
|
+
O(`Error: ${e}`, "paused");
|
|
3441
3598
|
}
|
|
3442
3599
|
});
|
|
3443
3600
|
return function() {
|
|
3444
3601
|
return e.apply(this, arguments);
|
|
3445
3602
|
};
|
|
3446
|
-
}(),
|
|
3447
|
-
console.log("Simulator: Game loaded, ready to start"),
|
|
3603
|
+
}(), V = () => {
|
|
3604
|
+
console.log("Simulator: Game loaded, ready to start"), b.disabled = !1, u.forEach((e) => {
|
|
3448
3605
|
var t;
|
|
3449
|
-
return (t = e.onMessage) == null ? void 0 : t.call(e, "READY_GAME_LOADED", void 0,
|
|
3606
|
+
return (t = e.onMessage) == null ? void 0 : t.call(e, "READY_GAME_LOADED", void 0, L);
|
|
3450
3607
|
}), a && !f.hasStarted && setTimeout(() => {
|
|
3451
|
-
let e =
|
|
3452
|
-
e == null || e.click(),
|
|
3608
|
+
let e = E("#simulator-start");
|
|
3609
|
+
e == null || e.click(), y.disabled = !1, f.hasStarted = !0, O("Running", "ready");
|
|
3453
3610
|
}, 100);
|
|
3454
3611
|
};
|
|
3455
|
-
return
|
|
3612
|
+
return ae((e, t) => {
|
|
3456
3613
|
var n, r;
|
|
3457
3614
|
if (e === "READY") {
|
|
3458
|
-
console.log("Simulator: Received READY from game"),
|
|
3615
|
+
console.log("Simulator: Received READY from game"), B();
|
|
3459
3616
|
return;
|
|
3460
3617
|
}
|
|
3461
3618
|
if (e === "READY_GAME_LOADED") {
|
|
3462
|
-
|
|
3619
|
+
V();
|
|
3463
3620
|
return;
|
|
3464
3621
|
}
|
|
3465
3622
|
if (e === "TIMER_TICK") {
|
|
3466
3623
|
if (t != null && t.display) {
|
|
3467
3624
|
let [e, n] = t.display;
|
|
3468
|
-
|
|
3625
|
+
k(e, n);
|
|
3469
3626
|
}
|
|
3470
3627
|
return;
|
|
3471
3628
|
}
|
|
@@ -3476,28 +3633,28 @@ function _t(e = {}) {
|
|
|
3476
3633
|
}
|
|
3477
3634
|
u.forEach((n) => {
|
|
3478
3635
|
var r;
|
|
3479
|
-
return (r = n.onMessage) == null ? void 0 : r.call(n, e, t,
|
|
3636
|
+
return (r = n.onMessage) == null ? void 0 : r.call(n, e, t, L);
|
|
3480
3637
|
});
|
|
3481
3638
|
let i = (n = t == null || (r = t.input) == null ? void 0 : r.boardState) == null ? t == null ? void 0 : t.boardState : n;
|
|
3482
|
-
e === "UPLOAD_NEW_GAME_STATE" && i && (f.currentInputStr = i, f.activeTab === "thumb" &&
|
|
3483
|
-
},
|
|
3639
|
+
e === "UPLOAD_NEW_GAME_STATE" && i && (f.currentInputStr = i, f.activeTab === "thumb" && M(), console.log("Simulator: Game state uploaded", t)), e === "GAME_COMPLETED" && (console.log("Simulator: Game completed!", t), y.disabled = !0, f.hasStarted = !1, O("Completed!", "complete"));
|
|
3640
|
+
}, P), console.log("Simulator initialized"), $ = {
|
|
3484
3641
|
updateFixtures: (e) => {
|
|
3485
|
-
o =
|
|
3642
|
+
o = oe(e), s = Array.from(o.keys()).sort(), L.fixtures = o, L.fixtureCategories = s;
|
|
3486
3643
|
let t = localStorage.getItem("simulator-fixture-category");
|
|
3487
3644
|
if (!f.selectedCategory || !s.includes(f.selectedCategory)) {
|
|
3488
3645
|
var n;
|
|
3489
3646
|
f.selectedCategory = t && s.includes(t) ? t : (n = s[0]) == null ? null : n;
|
|
3490
3647
|
}
|
|
3491
3648
|
let r = u.find((e) => e.id === "ctrl");
|
|
3492
|
-
r == null || r.bind(
|
|
3649
|
+
r == null || r.bind(L), console.log("Simulator: Fixtures updated", {
|
|
3493
3650
|
categories: s,
|
|
3494
3651
|
selectedCategory: f.selectedCategory
|
|
3495
3652
|
});
|
|
3496
3653
|
},
|
|
3497
|
-
sendToGame:
|
|
3498
|
-
loadPuzzle:
|
|
3654
|
+
sendToGame: F,
|
|
3655
|
+
loadPuzzle: N
|
|
3499
3656
|
}, $;
|
|
3500
3657
|
}
|
|
3501
|
-
export {
|
|
3658
|
+
export { se as n, At as t };
|
|
3502
3659
|
|
|
3503
|
-
//# sourceMappingURL=createSimulator-
|
|
3660
|
+
//# sourceMappingURL=createSimulator-bJ1qCLmt.js.map
|