@puzzmo/sdk 1.0.51 → 1.0.53
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-B-96QGck.cjs → createSimulator-CB_nIwbm.cjs} +44 -32
- package/dist/createSimulator-CB_nIwbm.cjs.map +1 -0
- package/dist/{createSimulator-BauFqDvn.js → createSimulator-bJ1qCLmt.js} +466 -300
- package/dist/createSimulator-bJ1qCLmt.js.map +1 -0
- package/dist/simulator/createSimulator.d.ts.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.d.ts +1 -0
- package/dist/simulator/index.d.ts.map +1 -1
- package/dist/simulator/index.js +2 -2
- package/dist/simulator/marker.d.ts +10 -0
- package/dist/simulator/marker.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 +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-B-96QGck.cjs.map +0 -1
- package/dist/createSimulator-BauFqDvn.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 oe(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 ce(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 le(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 E(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,11 +572,20 @@ function D(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
|
}
|
|
570
|
-
|
|
579
|
+
/**
|
|
580
|
+
* Sentinel string stamped onto the simulator's root element so build tooling can spot a simulator
|
|
581
|
+
* that leaked into a shipped game bundle. Minifiers rewrite identifiers but never string contents,
|
|
582
|
+
* so this literal survives into dist.
|
|
583
|
+
*
|
|
584
|
+
* `puzzmo games validate` greps build output for it — keep it in sync with the copy in
|
|
585
|
+
* packages/cli/src/util/lintDist.ts.
|
|
586
|
+
*/
|
|
587
|
+
const se = "puzzmo-simulator-dev-only-do-not-ship";
|
|
588
|
+
function ce() {
|
|
571
589
|
return {
|
|
572
590
|
id: "ctrl",
|
|
573
591
|
label: "Ctrl",
|
|
@@ -582,19 +600,19 @@ function ue() {
|
|
|
582
600
|
selectedCategory: e.state.selectedCategory,
|
|
583
601
|
selectedPuzzle: e.state.selectedPuzzle
|
|
584
602
|
}), e.fixtures && e.fixtureCategories.length > 0 && i) {
|
|
585
|
-
i.innerHTML =
|
|
603
|
+
i.innerHTML = j(e.fixtureCategories, e.state.selectedCategory);
|
|
586
604
|
let t = e.getElement("#simulator-fixture-category"), n = e.getElement("#simulator-fixture-puzzle");
|
|
587
605
|
if (t && n && e.state.selectedCategory) {
|
|
588
|
-
e.state.selectedPuzzle =
|
|
589
|
-
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);
|
|
590
608
|
console.log("Simulator: Loading fixture puzzle", {
|
|
591
609
|
category: e.state.selectedCategory,
|
|
592
610
|
puzzle: e.state.selectedPuzzle,
|
|
593
611
|
hasPuzzleData: !!r
|
|
594
|
-
}), r && (e.state.appliedPuzzleOverride === null && (e.state.puzzleData = r, e.state.originalPuzzle = r), e.state.selectedCategory &&
|
|
595
|
-
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();
|
|
596
614
|
}), n.addEventListener("change", () => {
|
|
597
|
-
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();
|
|
598
616
|
});
|
|
599
617
|
}
|
|
600
618
|
}
|
|
@@ -620,10 +638,10 @@ function ue() {
|
|
|
620
638
|
* Inlined here (rather than shared with the rest of the monorepo) because the SDK ships to OSS and
|
|
621
639
|
* must stay self-contained.
|
|
622
640
|
*/
|
|
623
|
-
function
|
|
641
|
+
function P(e) {
|
|
624
642
|
var t;
|
|
625
643
|
if (typeof e != "string") return e;
|
|
626
|
-
let n = (t =
|
|
644
|
+
let n = (t = F(e)) == null ? {
|
|
627
645
|
width: 800,
|
|
628
646
|
height: 800
|
|
629
647
|
} : t;
|
|
@@ -634,7 +652,7 @@ function k(e) {
|
|
|
634
652
|
};
|
|
635
653
|
}
|
|
636
654
|
/** Reads an SVG's intrinsic size from its `viewBox` (preferred) or its `width`/`height` attributes. */
|
|
637
|
-
function
|
|
655
|
+
function F(e) {
|
|
638
656
|
var t, n, r, i;
|
|
639
657
|
let a = e.indexOf("<svg");
|
|
640
658
|
if (a === -1) return;
|
|
@@ -652,9 +670,9 @@ function A(e) {
|
|
|
652
670
|
height: u
|
|
653
671
|
};
|
|
654
672
|
}
|
|
655
|
-
var
|
|
673
|
+
var I = "simulator-saved-states";
|
|
656
674
|
/** Find thumbnail function on globalThis (looks for functions ending in "Thumbnail") */
|
|
657
|
-
function
|
|
675
|
+
function L() {
|
|
658
676
|
let e = globalThis;
|
|
659
677
|
for (let t of Object.keys(e)) if (t.endsWith("Thumbnail") && typeof e[t] == "function") return {
|
|
660
678
|
name: t,
|
|
@@ -663,8 +681,8 @@ function M() {
|
|
|
663
681
|
return null;
|
|
664
682
|
}
|
|
665
683
|
/** Generate a small thumbnail SVG for a given input string */
|
|
666
|
-
function
|
|
667
|
-
let n =
|
|
684
|
+
function R(e, t) {
|
|
685
|
+
let n = L();
|
|
668
686
|
if (!n) return "";
|
|
669
687
|
try {
|
|
670
688
|
var r;
|
|
@@ -674,19 +692,19 @@ function N(e, t) {
|
|
|
674
692
|
strict: !0,
|
|
675
693
|
renderHost: "game"
|
|
676
694
|
};
|
|
677
|
-
return
|
|
695
|
+
return P(n.fn(i, t, a)).svg;
|
|
678
696
|
} catch (e) {
|
|
679
697
|
return "";
|
|
680
698
|
}
|
|
681
699
|
}
|
|
682
|
-
var
|
|
683
|
-
function
|
|
700
|
+
var z = [];
|
|
701
|
+
function B(e, t = 8) {
|
|
684
702
|
let n = 14 * t + 8 + 4;
|
|
685
703
|
e.style.height = "auto";
|
|
686
704
|
let r = Math.min(Math.max(e.scrollHeight, 40), n);
|
|
687
705
|
e.style.height = `${r}px`;
|
|
688
706
|
}
|
|
689
|
-
function
|
|
707
|
+
function le() {
|
|
690
708
|
let e = "", t = "";
|
|
691
709
|
return {
|
|
692
710
|
id: "data",
|
|
@@ -704,18 +722,18 @@ function de() {
|
|
|
704
722
|
let i = n.getElement(".data-view-container");
|
|
705
723
|
i == null || i.querySelectorAll(".data-subtab-content").forEach((e) => {
|
|
706
724
|
e.classList.toggle("active", e.id === `data-subtab-${t}`);
|
|
707
|
-
}), t === "edit" ?
|
|
725
|
+
}), t === "edit" ? de(n) : t === "history" ? H(n) : t === "saves" && U(n);
|
|
708
726
|
});
|
|
709
727
|
});
|
|
710
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");
|
|
711
729
|
setTimeout(() => {
|
|
712
|
-
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);
|
|
713
731
|
}, 0), i == null || i.addEventListener("input", () => {
|
|
714
|
-
|
|
732
|
+
B(i);
|
|
715
733
|
let t = i.value !== e;
|
|
716
734
|
l && (l.disabled = !t);
|
|
717
735
|
}), a == null || a.addEventListener("input", () => {
|
|
718
|
-
|
|
736
|
+
B(a);
|
|
719
737
|
let e = a.value !== t;
|
|
720
738
|
d && (d.disabled = !e);
|
|
721
739
|
}), o == null || o.addEventListener("click", () => {
|
|
@@ -723,7 +741,7 @@ function de() {
|
|
|
723
741
|
c("puzzle"), n.updateStatus("Restoring fixture puzzle...", "waiting"), window.location.reload();
|
|
724
742
|
return;
|
|
725
743
|
}
|
|
726
|
-
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));
|
|
727
745
|
}), l == null || l.addEventListener("click", () => {
|
|
728
746
|
if (i) {
|
|
729
747
|
if (!s("puzzle", i.value)) {
|
|
@@ -737,7 +755,7 @@ function de() {
|
|
|
737
755
|
c("input"), n.updateStatus("Clearing input...", "waiting"), window.location.reload();
|
|
738
756
|
return;
|
|
739
757
|
}
|
|
740
|
-
a && (a.value = t,
|
|
758
|
+
a && (a.value = t, B(a), d && (d.disabled = !0));
|
|
741
759
|
}), d == null || d.addEventListener("click", () => {
|
|
742
760
|
if (a) {
|
|
743
761
|
if (!s("input", a.value)) {
|
|
@@ -749,87 +767,87 @@ function de() {
|
|
|
749
767
|
});
|
|
750
768
|
let f = n.getElement("#simulator-history-clear");
|
|
751
769
|
f == null || f.addEventListener("click", () => {
|
|
752
|
-
|
|
770
|
+
z = [], H(n);
|
|
753
771
|
});
|
|
754
772
|
let p = n.getElement("#simulator-save-name"), m = n.getElement("#simulator-save-btn");
|
|
755
773
|
m == null || m.addEventListener("click", () => {
|
|
756
774
|
if (!p || !p.value.trim()) return;
|
|
757
|
-
let e =
|
|
775
|
+
let e = V(), t = {
|
|
758
776
|
name: p.value.trim(),
|
|
759
777
|
puzzleStr: n.state.originalPuzzle,
|
|
760
778
|
inputStr: n.state.currentInputStr,
|
|
761
779
|
timestamp: Date.now()
|
|
762
780
|
};
|
|
763
|
-
e.push(t), localStorage.setItem(
|
|
764
|
-
}),
|
|
781
|
+
e.push(t), localStorage.setItem(I, JSON.stringify(e)), p.value = "", U(n);
|
|
782
|
+
}), U(n);
|
|
765
783
|
},
|
|
766
784
|
onActivate(n) {
|
|
767
|
-
e = n.state.originalPuzzle, t = n.state.currentInputStr,
|
|
785
|
+
e = n.state.originalPuzzle, t = n.state.currentInputStr, de(n), H(n);
|
|
768
786
|
},
|
|
769
787
|
onMessage(e, n, r) {
|
|
770
788
|
var i, a;
|
|
771
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;
|
|
772
790
|
if (e === "UPLOAD_NEW_GAME_STATE" && c) {
|
|
773
|
-
if (r.state.currentInputStr = c,
|
|
774
|
-
|
|
791
|
+
if (r.state.currentInputStr = c, z.length === 0 || z[z.length - 1].value !== c) {
|
|
792
|
+
z.push({
|
|
775
793
|
value: c,
|
|
776
794
|
timestamp: Date.now()
|
|
777
|
-
}),
|
|
795
|
+
}), z.length > 100 && (z = z.slice(-100));
|
|
778
796
|
let e = r.getElement("#data-subtab-history");
|
|
779
|
-
e != null && e.classList.contains("active") &&
|
|
797
|
+
e != null && e.classList.contains("active") && H(r);
|
|
780
798
|
}
|
|
781
|
-
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));
|
|
782
800
|
}
|
|
783
801
|
}
|
|
784
802
|
};
|
|
785
803
|
}
|
|
786
|
-
function
|
|
804
|
+
function V() {
|
|
787
805
|
try {
|
|
788
|
-
let e = localStorage.getItem(
|
|
806
|
+
let e = localStorage.getItem(I);
|
|
789
807
|
return e ? JSON.parse(e) : [];
|
|
790
808
|
} catch (e) {
|
|
791
809
|
return [];
|
|
792
810
|
}
|
|
793
811
|
}
|
|
794
|
-
function
|
|
812
|
+
function H(e) {
|
|
795
813
|
let t = e.getElement("#simulator-history-list");
|
|
796
814
|
if (t) {
|
|
797
|
-
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) {
|
|
798
816
|
t.innerHTML = "<div class=\"simulator-empty\">No history yet</div>";
|
|
799
817
|
return;
|
|
800
818
|
}
|
|
801
|
-
t.innerHTML = [...
|
|
802
|
-
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;
|
|
803
821
|
return `
|
|
804
822
|
<div class="history-item" data-history-idx="${r}">
|
|
805
|
-
<div class="history-item-thumb">${
|
|
823
|
+
<div class="history-item-thumb">${R(e, t.value)}</div>
|
|
806
824
|
<div class="history-item-content">
|
|
807
825
|
<div class="history-item-header">
|
|
808
826
|
<span class="history-item-num">#${r + 1}</span>
|
|
809
827
|
<span class="history-item-time">${i}</span>
|
|
810
828
|
<button class="simulator-btn tiny history-restore-btn" data-history-idx="${r}">Restore</button>
|
|
811
829
|
</div>
|
|
812
|
-
<div class="history-item-preview">${
|
|
830
|
+
<div class="history-item-preview">${ue(a)}</div>
|
|
813
831
|
</div>
|
|
814
832
|
</div>
|
|
815
833
|
`;
|
|
816
834
|
}).join(""), t.querySelectorAll(".history-restore-btn").forEach((t) => {
|
|
817
835
|
t.addEventListener("click", (t) => {
|
|
818
|
-
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];
|
|
819
837
|
if (r) {
|
|
820
838
|
let t = e.getElement(".data-subtab[data-subtab=\"edit\"]");
|
|
821
839
|
t == null || t.click();
|
|
822
840
|
let n = e.getElement("#simulator-input"), i = e.getElement("#simulator-input-apply");
|
|
823
|
-
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");
|
|
824
842
|
}
|
|
825
843
|
});
|
|
826
844
|
});
|
|
827
845
|
}
|
|
828
846
|
}
|
|
829
|
-
function
|
|
847
|
+
function U(e) {
|
|
830
848
|
let t = e.getElement("#simulator-saves-list");
|
|
831
849
|
if (!t) return;
|
|
832
|
-
let n =
|
|
850
|
+
let n = V();
|
|
833
851
|
if (n.length === 0) {
|
|
834
852
|
t.innerHTML = "<div class=\"simulator-empty\">No saved states</div>";
|
|
835
853
|
return;
|
|
@@ -839,7 +857,7 @@ function R(e) {
|
|
|
839
857
|
return `
|
|
840
858
|
<div class="save-item">
|
|
841
859
|
<div class="save-item-header">
|
|
842
|
-
<span class="save-item-name">${
|
|
860
|
+
<span class="save-item-name">${ue(e.name)}</span>
|
|
843
861
|
<span class="save-item-time">${i} ${a}</span>
|
|
844
862
|
</div>
|
|
845
863
|
<div class="save-item-actions">
|
|
@@ -862,25 +880,25 @@ function R(e) {
|
|
|
862
880
|
}), t.querySelectorAll(".save-delete-btn").forEach((t) => {
|
|
863
881
|
t.addEventListener("click", (t) => {
|
|
864
882
|
let r = parseInt(t.target.getAttribute("data-save-idx") || "0"), i = n.filter((e, t) => t !== r);
|
|
865
|
-
localStorage.setItem(
|
|
883
|
+
localStorage.setItem(I, JSON.stringify(i)), U(e);
|
|
866
884
|
});
|
|
867
885
|
});
|
|
868
886
|
}
|
|
869
|
-
function
|
|
887
|
+
function ue(e) {
|
|
870
888
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
871
889
|
}
|
|
872
|
-
function
|
|
890
|
+
function de(e) {
|
|
873
891
|
let t = e.getElement("#simulator-puzzle"), n = e.getElement("#simulator-input"), r = e.getElement("#simulator-puzzle-apply"), i = e.getElement("#simulator-input-apply");
|
|
874
|
-
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);
|
|
875
893
|
}
|
|
876
|
-
function
|
|
894
|
+
function fe(e) {
|
|
877
895
|
let t = e.getElement("#simulator-puzzle-override-tag"), n = e.getElement("#simulator-input-override-tag");
|
|
878
896
|
t && (t.hidden = e.state.appliedPuzzleOverride === null), n && (n.hidden = e.state.appliedInputOverride === null);
|
|
879
897
|
}
|
|
880
|
-
function
|
|
898
|
+
function pe(e) {
|
|
881
899
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
882
900
|
}
|
|
883
|
-
function
|
|
901
|
+
function me() {
|
|
884
902
|
let e = 0;
|
|
885
903
|
return {
|
|
886
904
|
id: "msgs",
|
|
@@ -907,7 +925,7 @@ function ge() {
|
|
|
907
925
|
<span class="simulator-msg-type">${t.direction === "out" ? "→" : "←"} ${t.type}</span>
|
|
908
926
|
<span class="simulator-msg-time">${t.time}</span>
|
|
909
927
|
</div>
|
|
910
|
-
${a ? `<div class="simulator-msg-data">${
|
|
928
|
+
${a ? `<div class="simulator-msg-data">${pe(a)}</div>` : ""}
|
|
911
929
|
`;
|
|
912
930
|
let o = i.querySelector(".simulator-msg-data");
|
|
913
931
|
for (o && o.addEventListener("click", () => {
|
|
@@ -918,7 +936,7 @@ function ge() {
|
|
|
918
936
|
}
|
|
919
937
|
};
|
|
920
938
|
}
|
|
921
|
-
function
|
|
939
|
+
function he() {
|
|
922
940
|
return {
|
|
923
941
|
id: "done",
|
|
924
942
|
label: "Done",
|
|
@@ -955,7 +973,7 @@ function _e() {
|
|
|
955
973
|
}
|
|
956
974
|
};
|
|
957
975
|
}
|
|
958
|
-
function
|
|
976
|
+
function ge() {
|
|
959
977
|
let e = [], t = () => (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", { hour12: !1 }), n = (e) => {
|
|
960
978
|
let { checkpointName: t, augConfig: n, time: r } = e, i = n == null ? void 0 : n.deeds;
|
|
961
979
|
return `
|
|
@@ -1006,7 +1024,7 @@ function ve() {
|
|
|
1006
1024
|
};
|
|
1007
1025
|
}
|
|
1008
1026
|
/** Find thumbnail function on globalThis (looks for functions ending in "Thumbnail") */
|
|
1009
|
-
function
|
|
1027
|
+
function _e() {
|
|
1010
1028
|
let e = globalThis;
|
|
1011
1029
|
for (let t of Object.keys(e)) if (t.endsWith("Thumbnail") && typeof e[t] == "function") return {
|
|
1012
1030
|
name: t,
|
|
@@ -1015,23 +1033,23 @@ function ye() {
|
|
|
1015
1033
|
return null;
|
|
1016
1034
|
}
|
|
1017
1035
|
/** The bundle's `getShareString` (if any), exposed to the sim via vite.ts's bundle loader. */
|
|
1018
|
-
function
|
|
1036
|
+
function ve() {
|
|
1019
1037
|
let e = globalThis.getShareString;
|
|
1020
1038
|
return typeof e == "function" ? e : null;
|
|
1021
1039
|
}
|
|
1022
|
-
function
|
|
1040
|
+
function ye(e) {
|
|
1023
1041
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
1024
1042
|
}
|
|
1025
|
-
function
|
|
1043
|
+
function be() {
|
|
1026
1044
|
let e = /* @__PURE__ */ new Date();
|
|
1027
1045
|
return `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`;
|
|
1028
1046
|
}
|
|
1029
|
-
function
|
|
1047
|
+
function xe(e) {
|
|
1030
1048
|
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
1031
1049
|
}
|
|
1032
1050
|
/** Shown when Preview Kind = Text but the bundle doesn't export `getShareString`. */
|
|
1033
|
-
var
|
|
1034
|
-
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() {
|
|
1035
1053
|
return {
|
|
1036
1054
|
id: "thumb",
|
|
1037
1055
|
label: "Thumb",
|
|
@@ -1053,12 +1071,12 @@ function Te() {
|
|
|
1053
1071
|
o == null || o.querySelectorAll(".simulator-segmented-btn").forEach((t) => {
|
|
1054
1072
|
t.addEventListener("click", () => {
|
|
1055
1073
|
let n = t.dataset.previewKind;
|
|
1056
|
-
!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());
|
|
1057
1075
|
});
|
|
1058
|
-
}), n && (e.state.renderHost || (e.state.renderHost = "game",
|
|
1059
|
-
e.state.renderHost = n.value,
|
|
1060
|
-
})), r && (e.state.renderContext || (e.state.renderContext = "preview",
|
|
1061
|
-
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();
|
|
1062
1080
|
})), c(), s();
|
|
1063
1081
|
},
|
|
1064
1082
|
onActivate(e) {
|
|
@@ -1067,26 +1085,26 @@ function Te() {
|
|
|
1067
1085
|
updatePreview: (e) => {
|
|
1068
1086
|
let t = e.getElement("#simulator-thumb-preview"), n = e.getElement("#simulator-thumb-fn");
|
|
1069
1087
|
if (t == null || t.style.setProperty("--sim-thumb-bg", e.state.selectedTheme.g_bg), e.state.previewKind === "text") {
|
|
1070
|
-
let s =
|
|
1088
|
+
let s = ve();
|
|
1071
1089
|
if (!s) {
|
|
1072
|
-
t && (t.innerHTML =
|
|
1090
|
+
t && (t.innerHTML = Se), n && (n.textContent = "");
|
|
1073
1091
|
return;
|
|
1074
1092
|
}
|
|
1075
1093
|
n && (n.textContent = "Using: getShareString()");
|
|
1076
1094
|
try {
|
|
1077
1095
|
var r, i, a, o;
|
|
1078
|
-
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), {
|
|
1079
1097
|
puzzleString: (a = e.state.puzzleData) == null ? "" : a,
|
|
1080
|
-
dateKey:
|
|
1098
|
+
dateKey: be(),
|
|
1081
1099
|
gameplaySlug: `simulator:${n}`
|
|
1082
1100
|
}), l = (o = c == null ? void 0 : c.str) == null ? "" : o;
|
|
1083
|
-
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>`);
|
|
1084
1102
|
} catch (e) {
|
|
1085
1103
|
console.error("Simulator: Share string error", e), t && (t.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
|
|
1086
1104
|
}
|
|
1087
1105
|
return;
|
|
1088
1106
|
}
|
|
1089
|
-
let s =
|
|
1107
|
+
let s = _e();
|
|
1090
1108
|
if (!s) {
|
|
1091
1109
|
t && (t.innerHTML = "<span class=\"simulator-empty\">No thumbnail function found</span>"), n && (n.textContent = "");
|
|
1092
1110
|
return;
|
|
@@ -1100,7 +1118,7 @@ function Te() {
|
|
|
1100
1118
|
strict: !0,
|
|
1101
1119
|
renderHost: e.state.renderHost,
|
|
1102
1120
|
renderContext: e.state.renderContext
|
|
1103
|
-
}, { svg: i } =
|
|
1121
|
+
}, { svg: i } = P(s.fn(n, e.state.currentInputStr, r));
|
|
1104
1122
|
t && (t.innerHTML = i);
|
|
1105
1123
|
} catch (e) {
|
|
1106
1124
|
console.error("Simulator: Thumbnail error", e), t && (t.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
|
|
@@ -1109,7 +1127,7 @@ function Te() {
|
|
|
1109
1127
|
};
|
|
1110
1128
|
}
|
|
1111
1129
|
/** Generate theme preview HTML showing key colors */
|
|
1112
|
-
function
|
|
1130
|
+
function we(e) {
|
|
1113
1131
|
let t = [
|
|
1114
1132
|
e.key,
|
|
1115
1133
|
e.subBrand,
|
|
@@ -1120,7 +1138,7 @@ function Ee(e) {
|
|
|
1120
1138
|
].map((e) => `<div class="simulator-theme-preview-cell" style="background: ${e}"></div>`).join("");
|
|
1121
1139
|
return `<div class="simulator-theme-preview" style="background: ${e.g_bg}">${t}</div>`;
|
|
1122
1140
|
}
|
|
1123
|
-
function
|
|
1141
|
+
function Te() {
|
|
1124
1142
|
return {
|
|
1125
1143
|
id: "theme",
|
|
1126
1144
|
label: "Theme",
|
|
@@ -1132,17 +1150,17 @@ function De() {
|
|
|
1132
1150
|
t && n.forEach((n) => {
|
|
1133
1151
|
let r = document.createElement("div");
|
|
1134
1152
|
r.className = `simulator-theme-item${n.name === e.state.selectedTheme.name ? " selected" : ""}`, r.innerHTML = `
|
|
1135
|
-
${
|
|
1153
|
+
${we(n)}
|
|
1136
1154
|
<div class="simulator-theme-name">${n.name}</div>
|
|
1137
1155
|
<div class="simulator-theme-type">${n.type}</div>
|
|
1138
1156
|
`, r.addEventListener("click", () => {
|
|
1139
|
-
console.log("Simulator: Theme changed, reloading...", n.name),
|
|
1157
|
+
console.log("Simulator: Theme changed, reloading...", n.name), w(n.name), window.location.reload();
|
|
1140
1158
|
}), t.appendChild(r);
|
|
1141
1159
|
});
|
|
1142
1160
|
}
|
|
1143
1161
|
};
|
|
1144
1162
|
}
|
|
1145
|
-
var
|
|
1163
|
+
var Ee = [
|
|
1146
1164
|
{
|
|
1147
1165
|
name: "app (desktop)",
|
|
1148
1166
|
context: [{
|
|
@@ -1189,8 +1207,8 @@ var Oe = [
|
|
|
1189
1207
|
* The bootstrap is only read at game boot, so applying a change persists it to localStorage and
|
|
1190
1208
|
* restarts (reloads) the page — the same flow as the Theme tab.
|
|
1191
1209
|
*/
|
|
1192
|
-
function
|
|
1193
|
-
let t = [...
|
|
1210
|
+
function De(e = []) {
|
|
1211
|
+
let t = [...Ee, ...e];
|
|
1194
1212
|
return {
|
|
1195
1213
|
id: "host",
|
|
1196
1214
|
label: "Host",
|
|
@@ -1207,7 +1225,7 @@ function ke(e = []) {
|
|
|
1207
1225
|
<div class="host-note" id="host-source"></div>
|
|
1208
1226
|
<select class="simulator-select" id="host-presets">
|
|
1209
1227
|
<option value="">Preset…</option>
|
|
1210
|
-
${t.map((e, t) => `<option value="${t}">${
|
|
1228
|
+
${t.map((e, t) => `<option value="${t}">${Oe(e.name)}</option>`).join("")}
|
|
1211
1229
|
</select>
|
|
1212
1230
|
<textarea class="simulator-textarea" id="host-json" spellcheck="false"></textarea>
|
|
1213
1231
|
<div class="host-actions">
|
|
@@ -1244,42 +1262,42 @@ function ke(e = []) {
|
|
|
1244
1262
|
};
|
|
1245
1263
|
}
|
|
1246
1264
|
/** Minimal HTML-escape so preset names can't break the simulator markup. */
|
|
1247
|
-
function
|
|
1265
|
+
function Oe(e) {
|
|
1248
1266
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
1249
1267
|
}
|
|
1250
|
-
var
|
|
1251
|
-
localStorage.setItem(
|
|
1252
|
-
},
|
|
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() {
|
|
1253
1271
|
var e = t(function* () {
|
|
1254
|
-
if (
|
|
1272
|
+
if (K !== null) return K;
|
|
1255
1273
|
try {
|
|
1256
|
-
let e = new AbortController(), t = setTimeout(() => e.abort(), 1e3), n = yield fetch(`${
|
|
1257
|
-
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;
|
|
1258
1276
|
} catch (e) {
|
|
1259
|
-
return
|
|
1277
|
+
return K = !1, !1;
|
|
1260
1278
|
}
|
|
1261
1279
|
});
|
|
1262
1280
|
return function() {
|
|
1263
1281
|
return e.apply(this, arguments);
|
|
1264
1282
|
};
|
|
1265
|
-
}(),
|
|
1266
|
-
apiURL:
|
|
1283
|
+
}(), q = () => ({
|
|
1284
|
+
apiURL: G() === "dev" ? W : Ae,
|
|
1267
1285
|
clientID: "protosdk:oauthclient",
|
|
1268
1286
|
redirectUri: `${window.location.origin}/oauth/callback`
|
|
1269
|
-
}),
|
|
1287
|
+
}), Ne = () => {
|
|
1270
1288
|
let e = new Uint8Array(32);
|
|
1271
1289
|
return crypto.getRandomValues(e), Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
1272
|
-
},
|
|
1273
|
-
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);
|
|
1274
1292
|
return e && `${e.substring(0, 20)}`, e;
|
|
1275
|
-
},
|
|
1276
|
-
localStorage.removeItem(
|
|
1277
|
-
},
|
|
1278
|
-
let e =
|
|
1293
|
+
}, Re = () => localStorage.getItem(Pe), ze = () => {
|
|
1294
|
+
localStorage.removeItem(J), localStorage.removeItem(Pe);
|
|
1295
|
+
}, Be = () => {
|
|
1296
|
+
let e = q(), t = Ne();
|
|
1279
1297
|
sessionStorage.setItem("oauth_state", t), sessionStorage.setItem("oauth_return_url", window.location.href);
|
|
1280
1298
|
let n = new URL(`${e.apiURL}/oauth/auth`);
|
|
1281
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();
|
|
1282
|
-
},
|
|
1300
|
+
}, Ve = (e) => {
|
|
1283
1301
|
try {
|
|
1284
1302
|
let t = e.split(".");
|
|
1285
1303
|
if (t.length !== 3) return !0;
|
|
@@ -1288,11 +1306,11 @@ var je = "puzzmo_sim_api_mode", z = "http://localhost:8911", Me = "https://api.p
|
|
|
1288
1306
|
} catch (e) {
|
|
1289
1307
|
return !0;
|
|
1290
1308
|
}
|
|
1291
|
-
},
|
|
1309
|
+
}, He = function() {
|
|
1292
1310
|
var e = t(function* () {
|
|
1293
|
-
let e =
|
|
1311
|
+
let e = Re();
|
|
1294
1312
|
if (!e) return !1;
|
|
1295
|
-
let t =
|
|
1313
|
+
let t = q();
|
|
1296
1314
|
try {
|
|
1297
1315
|
let n = new URLSearchParams({
|
|
1298
1316
|
grant_type: "refresh_token",
|
|
@@ -1306,9 +1324,9 @@ var je = "puzzmo_sim_api_mode", z = "http://localhost:8911", Me = "https://api.p
|
|
|
1306
1324
|
if (!r.ok) return r.statusText, !1;
|
|
1307
1325
|
let i = yield r.json(), a = i.access_token || i.accessToken;
|
|
1308
1326
|
if (!a) return !1;
|
|
1309
|
-
|
|
1327
|
+
Fe(a);
|
|
1310
1328
|
let o = i.refresh_token || i.refreshToken;
|
|
1311
|
-
return o &&
|
|
1329
|
+
return o && Ie(o), !0;
|
|
1312
1330
|
} catch (e) {
|
|
1313
1331
|
return !1;
|
|
1314
1332
|
}
|
|
@@ -1316,9 +1334,9 @@ var je = "puzzmo_sim_api_mode", z = "http://localhost:8911", Me = "https://api.p
|
|
|
1316
1334
|
return function() {
|
|
1317
1335
|
return e.apply(this, arguments);
|
|
1318
1336
|
};
|
|
1319
|
-
}(),
|
|
1337
|
+
}(), Ue = function() {
|
|
1320
1338
|
var e = t(function* (e, t) {
|
|
1321
|
-
let n =
|
|
1339
|
+
let n = q(), r = sessionStorage.getItem("oauth_state");
|
|
1322
1340
|
if (!r || r !== t) return null;
|
|
1323
1341
|
sessionStorage.removeItem("oauth_state");
|
|
1324
1342
|
try {
|
|
@@ -1340,13 +1358,13 @@ var je = "puzzmo_sim_api_mode", z = "http://localhost:8911", Me = "https://api.p
|
|
|
1340
1358
|
return function(t, n) {
|
|
1341
1359
|
return e.apply(this, arguments);
|
|
1342
1360
|
};
|
|
1343
|
-
}(),
|
|
1361
|
+
}(), We = function() {
|
|
1344
1362
|
var e = t(function* (e, t = {}) {
|
|
1345
|
-
let n =
|
|
1363
|
+
let n = q(), r = Le();
|
|
1346
1364
|
if (!r) throw Error("Not authenticated");
|
|
1347
|
-
if (
|
|
1348
|
-
if (r =
|
|
1349
|
-
} 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.");
|
|
1350
1368
|
let i = yield fetch(`${n.apiURL}/graphql`, {
|
|
1351
1369
|
method: "POST",
|
|
1352
1370
|
headers: {
|
|
@@ -1365,7 +1383,7 @@ var je = "puzzmo_sim_api_mode", z = "http://localhost:8911", Me = "https://api.p
|
|
|
1365
1383
|
return function(t) {
|
|
1366
1384
|
return e.apply(this, arguments);
|
|
1367
1385
|
};
|
|
1368
|
-
}(),
|
|
1386
|
+
}(), Ge = (e) => {
|
|
1369
1387
|
try {
|
|
1370
1388
|
let t = e.split(".");
|
|
1371
1389
|
return t.length, t.length === 3 ? JSON.parse(atob(t[1])) : null;
|
|
@@ -1373,15 +1391,15 @@ var je = "puzzmo_sim_api_mode", z = "http://localhost:8911", Me = "https://api.p
|
|
|
1373
1391
|
return null;
|
|
1374
1392
|
}
|
|
1375
1393
|
};
|
|
1376
|
-
function
|
|
1394
|
+
function Ke() {
|
|
1377
1395
|
let e = !1;
|
|
1378
1396
|
return {
|
|
1379
1397
|
id: "auth",
|
|
1380
1398
|
label: "Auth",
|
|
1381
1399
|
render() {
|
|
1382
|
-
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>`;
|
|
1383
1401
|
if (t) {
|
|
1384
|
-
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;
|
|
1385
1403
|
return `
|
|
1386
1404
|
<div class="simulator-section">
|
|
1387
1405
|
<div class="simulator-section-title auth-title-row">
|
|
@@ -1422,7 +1440,7 @@ function We() {
|
|
|
1422
1440
|
</div>
|
|
1423
1441
|
<p class="auth-description">
|
|
1424
1442
|
Login with your Puzzmo account to make authenticated API requests.
|
|
1425
|
-
${n === "dev" ? `<br><strong>Using local dev server:</strong> ${
|
|
1443
|
+
${n === "dev" ? `<br><strong>Using local dev server:</strong> ${W}` : ""}
|
|
1426
1444
|
</p>
|
|
1427
1445
|
<div class="simulator-row">
|
|
1428
1446
|
<button class="simulator-btn primary" id="auth-login">Login with Puzzmo</button>
|
|
@@ -1433,21 +1451,21 @@ function We() {
|
|
|
1433
1451
|
},
|
|
1434
1452
|
bind(n) {
|
|
1435
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");
|
|
1436
|
-
e ?
|
|
1437
|
-
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"));
|
|
1438
1456
|
})), c == null || c.addEventListener("click", () => {
|
|
1439
|
-
|
|
1457
|
+
je(G() === "dev" ? "prod" : "dev"), ze(), window.location.reload();
|
|
1440
1458
|
}), r == null || r.addEventListener("click", () => {
|
|
1441
|
-
|
|
1459
|
+
Be();
|
|
1442
1460
|
}), i == null || i.addEventListener("click", () => {
|
|
1443
|
-
|
|
1461
|
+
ze(), window.location.reload();
|
|
1444
1462
|
}), a == null || a.addEventListener("click", t(function* () {
|
|
1445
|
-
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);
|
|
1446
1464
|
})), o == null || o.addEventListener("click", t(function* () {
|
|
1447
1465
|
if (s) {
|
|
1448
1466
|
s.innerHTML = "<div class=\"loading\">Loading...</div>";
|
|
1449
1467
|
try {
|
|
1450
|
-
let t = yield
|
|
1468
|
+
let t = yield We("\n query {\n currentUser {\n id\n username\n usernameID\n name\n }\n }\n ");
|
|
1451
1469
|
if (t.errors) {
|
|
1452
1470
|
var e;
|
|
1453
1471
|
s.innerHTML = `<div class="error">Error: ${((e = t.errors[0]) == null ? void 0 : e.message) || "Unknown error"}</div>`;
|
|
@@ -1469,13 +1487,13 @@ function We() {
|
|
|
1469
1487
|
if (n && r) {
|
|
1470
1488
|
let t = e.getElement("#auth-status");
|
|
1471
1489
|
t && (t.innerHTML = "<span class=\"indicator waiting\"></span><span>Exchanging code...</span>");
|
|
1472
|
-
let i = yield
|
|
1490
|
+
let i = yield Ue(n, r);
|
|
1473
1491
|
if (window.history.replaceState({}, "", window.location.pathname), i) {
|
|
1474
1492
|
let e = i.access_token || i.accessToken;
|
|
1475
1493
|
if (e) {
|
|
1476
|
-
|
|
1494
|
+
Fe(e);
|
|
1477
1495
|
let t = i.refresh_token || i.refreshToken;
|
|
1478
|
-
t &&
|
|
1496
|
+
t && Ie(t);
|
|
1479
1497
|
}
|
|
1480
1498
|
window.location.reload();
|
|
1481
1499
|
} else {
|
|
@@ -1487,9 +1505,9 @@ function We() {
|
|
|
1487
1505
|
}
|
|
1488
1506
|
};
|
|
1489
1507
|
}
|
|
1490
|
-
var
|
|
1491
|
-
localStorage.removeItem(
|
|
1492
|
-
},
|
|
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) => {
|
|
1493
1511
|
try {
|
|
1494
1512
|
let t = e.split(".");
|
|
1495
1513
|
if (t.length !== 3) return !0;
|
|
@@ -1498,11 +1516,11 @@ var Ge = "puzzmo_sim_api_mode", Ke = "http://localhost:8911", qe = "https://api.
|
|
|
1498
1516
|
} catch (e) {
|
|
1499
1517
|
return !0;
|
|
1500
1518
|
}
|
|
1501
|
-
},
|
|
1519
|
+
}, at = function() {
|
|
1502
1520
|
var e = t(function* () {
|
|
1503
|
-
let e =
|
|
1521
|
+
let e = et();
|
|
1504
1522
|
if (!e) return !1;
|
|
1505
|
-
let t =
|
|
1523
|
+
let t = Qe() === "dev" ? Je : Ye;
|
|
1506
1524
|
try {
|
|
1507
1525
|
let n = new URLSearchParams({
|
|
1508
1526
|
grant_type: "refresh_token",
|
|
@@ -1516,9 +1534,9 @@ var Ge = "puzzmo_sim_api_mode", Ke = "http://localhost:8911", qe = "https://api.
|
|
|
1516
1534
|
if (!r.ok) return !1;
|
|
1517
1535
|
let i = yield r.json(), a = i.access_token || i.accessToken;
|
|
1518
1536
|
if (!a) return !1;
|
|
1519
|
-
|
|
1537
|
+
tt(a);
|
|
1520
1538
|
let o = i.refresh_token || i.refreshToken;
|
|
1521
|
-
return o &&
|
|
1539
|
+
return o && nt(o), !0;
|
|
1522
1540
|
} catch (e) {
|
|
1523
1541
|
return !1;
|
|
1524
1542
|
}
|
|
@@ -1526,13 +1544,13 @@ var Ge = "puzzmo_sim_api_mode", Ke = "http://localhost:8911", qe = "https://api.
|
|
|
1526
1544
|
return function() {
|
|
1527
1545
|
return e.apply(this, arguments);
|
|
1528
1546
|
};
|
|
1529
|
-
}(),
|
|
1547
|
+
}(), ot = function() {
|
|
1530
1548
|
var e = t(function* (e, t = {}) {
|
|
1531
|
-
let n =
|
|
1549
|
+
let n = Qe() === "dev" ? Je : Ye, r = $e();
|
|
1532
1550
|
if (!r) throw Error("Not authenticated");
|
|
1533
|
-
if (
|
|
1534
|
-
if (r =
|
|
1535
|
-
} 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.");
|
|
1536
1554
|
let i = yield fetch(`${n}/graphql`, {
|
|
1537
1555
|
method: "POST",
|
|
1538
1556
|
headers: {
|
|
@@ -1551,19 +1569,19 @@ var Ge = "puzzmo_sim_api_mode", Ke = "http://localhost:8911", qe = "https://api.
|
|
|
1551
1569
|
return function(t) {
|
|
1552
1570
|
return e.apply(this, arguments);
|
|
1553
1571
|
};
|
|
1554
|
-
}(),
|
|
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) => {
|
|
1555
1573
|
let n = t - 1, r = Math.floor(n / 31), i = n % 31, a = [...e];
|
|
1556
1574
|
for (; a.length <= r;) a.push(0);
|
|
1557
1575
|
return a[r] = a[r] ^ 1 << i, a;
|
|
1558
1576
|
};
|
|
1559
|
-
const
|
|
1560
|
-
function
|
|
1577
|
+
const ut = () => !!$e();
|
|
1578
|
+
function dt() {
|
|
1561
1579
|
let n = null, r = !1, i = null, a = function() {
|
|
1562
1580
|
var e = t(function* (e) {
|
|
1563
1581
|
r = !0, i = null;
|
|
1564
1582
|
try {
|
|
1565
1583
|
var t;
|
|
1566
|
-
let r = yield
|
|
1584
|
+
let r = yield ot(st, { slug: e });
|
|
1567
1585
|
if (r.errors) {
|
|
1568
1586
|
var a;
|
|
1569
1587
|
i = ((a = r.errors[0]) == null ? void 0 : a.message) || "Unknown error", n = null;
|
|
@@ -1580,10 +1598,10 @@ function ot() {
|
|
|
1580
1598
|
}(), o = function() {
|
|
1581
1599
|
var r = t(function* (t) {
|
|
1582
1600
|
if (!n) return;
|
|
1583
|
-
let r =
|
|
1601
|
+
let r = lt(n.featuresArr, t);
|
|
1584
1602
|
try {
|
|
1585
1603
|
var i;
|
|
1586
|
-
let t = yield
|
|
1604
|
+
let t = yield ot(ct, {
|
|
1587
1605
|
gameSlug: n.slug,
|
|
1588
1606
|
input: { featuresArr: r }
|
|
1589
1607
|
});
|
|
@@ -1631,7 +1649,7 @@ function ot() {
|
|
|
1631
1649
|
id: "features",
|
|
1632
1650
|
label: "Features",
|
|
1633
1651
|
render() {
|
|
1634
|
-
return
|
|
1652
|
+
return ut() ? `
|
|
1635
1653
|
<div class="features-view-container">
|
|
1636
1654
|
<div class="simulator-section">
|
|
1637
1655
|
<div class="simulator-section-title">Game Features</div>
|
|
@@ -1672,7 +1690,7 @@ function ot() {
|
|
|
1672
1690
|
e && (yield d(e));
|
|
1673
1691
|
})), i == null || i.addEventListener("keypress", (e) => {
|
|
1674
1692
|
e.key === "Enter" && (r == null || r.click());
|
|
1675
|
-
}), 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();
|
|
1676
1694
|
},
|
|
1677
1695
|
onActivate(e) {
|
|
1678
1696
|
let t = e.getElement("#simulator-tab-features");
|
|
@@ -1680,8 +1698,141 @@ function ot() {
|
|
|
1680
1698
|
}
|
|
1681
1699
|
};
|
|
1682
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
|
+
}
|
|
1683
1834
|
/** Renders a single keyboard key as an HTML button string */
|
|
1684
|
-
var
|
|
1835
|
+
var xt = (e, t) => {
|
|
1685
1836
|
var n, r;
|
|
1686
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);
|
|
1687
1838
|
return `<button class="${[
|
|
@@ -1692,35 +1843,50 @@ var st = (e, t) => {
|
|
|
1692
1843
|
c ? "l" : "",
|
|
1693
1844
|
l ? "grow" : ""
|
|
1694
1845
|
].filter(Boolean).join(" ")}" data-key="${e}" ${a ? "disabled" : ""}>${i}</button>`;
|
|
1695
|
-
},
|
|
1696
|
-
function
|
|
1697
|
-
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>";
|
|
1698
1849
|
return {
|
|
1699
1850
|
id: "kbd",
|
|
1700
1851
|
label: "Kbd",
|
|
1701
1852
|
render() {
|
|
1702
1853
|
return `
|
|
1703
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>
|
|
1704
1861
|
<div id="sim-kb-content">
|
|
1705
|
-
${
|
|
1862
|
+
${n(!1)}
|
|
1706
1863
|
</div>
|
|
1707
1864
|
</div>
|
|
1708
1865
|
`;
|
|
1709
1866
|
},
|
|
1710
1867
|
bind(e) {
|
|
1711
|
-
|
|
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);
|
|
1712
1876
|
},
|
|
1713
|
-
onMessage(n,
|
|
1714
|
-
var
|
|
1715
|
-
|
|
1716
|
-
e = !(!(r == null || (a = r.layout) == null) && a.length) || r.layout.every((e) => !e) ? null : r;
|
|
1717
|
-
let o = i.getElement("#sim-kb-content");
|
|
1718
|
-
o && (o.innerHTML = t(), ut(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));
|
|
1719
1880
|
}
|
|
1720
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
|
+
}
|
|
1721
1887
|
}
|
|
1722
1888
|
/** Attach click handlers to all rendered keys */
|
|
1723
|
-
function
|
|
1889
|
+
function wt(e) {
|
|
1724
1890
|
var t;
|
|
1725
1891
|
let n = (t = e.getElement("#sim-kb-content")) == null ? void 0 : t.querySelectorAll(".sim-kb-key");
|
|
1726
1892
|
n == null || n.forEach((t) => {
|
|
@@ -1735,15 +1901,15 @@ function ut(e) {
|
|
|
1735
1901
|
* change values (persisted to localStorage and pushed to the game as SETTINGS_UPDATE, matching the
|
|
1736
1902
|
* production host) and reflects UPDATE_SETTINGS_FROM_EMBED writes coming from the game.
|
|
1737
1903
|
*/
|
|
1738
|
-
function
|
|
1904
|
+
function Tt() {
|
|
1739
1905
|
let t = (e) => {
|
|
1740
1906
|
let t = e.state.settingsComponents;
|
|
1741
|
-
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>`;
|
|
1742
1908
|
}, n = (e) => {
|
|
1743
1909
|
let n = e.getElement("#sim-settings-content");
|
|
1744
1910
|
n && (n.innerHTML = t(e), i(e));
|
|
1745
1911
|
}, r = (e) => {
|
|
1746
|
-
|
|
1912
|
+
S(e.state.gameSettings), e.sendToGame("SETTINGS_UPDATE", e.state.gameSettings);
|
|
1747
1913
|
}, i = (t) => {
|
|
1748
1914
|
var i;
|
|
1749
1915
|
let a = t.getElement("#sim-settings-content");
|
|
@@ -1759,7 +1925,7 @@ function dt() {
|
|
|
1759
1925
|
});
|
|
1760
1926
|
}), (i = a.querySelector("#sim-settings-reset")) == null || i.addEventListener("click", () => {
|
|
1761
1927
|
var e;
|
|
1762
|
-
|
|
1928
|
+
C(), t.state.gameSettings = Dt((e = t.state.settingsComponents) == null ? [] : e), r(t), n(t);
|
|
1763
1929
|
}));
|
|
1764
1930
|
};
|
|
1765
1931
|
return {
|
|
@@ -1774,21 +1940,21 @@ function dt() {
|
|
|
1774
1940
|
onMessage(t, r, i) {
|
|
1775
1941
|
if (t === "INITIALIZE_SETTINGS") {
|
|
1776
1942
|
var a;
|
|
1777
|
-
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);
|
|
1778
1944
|
return;
|
|
1779
1945
|
}
|
|
1780
|
-
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));
|
|
1781
1947
|
}
|
|
1782
1948
|
};
|
|
1783
1949
|
}
|
|
1784
1950
|
/** Renders a single settings UI component as HTML, reading its current value from `settings` */
|
|
1785
|
-
function
|
|
1951
|
+
function Et(e, t) {
|
|
1786
1952
|
switch (e.type) {
|
|
1787
1953
|
case "title": return `<div class="sim-settings-heading">${Q(e.value)}</div>`;
|
|
1788
1954
|
case "subtitle": return `<div class="sim-settings-subheading">${Q(e.value)}</div>`;
|
|
1789
1955
|
case "paragraph": return `<p class="sim-settings-paragraph">${Q(e.value)}</p>`;
|
|
1790
1956
|
case "separator": return "<div class=\"simulator-divider\"></div>";
|
|
1791
|
-
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>`;
|
|
1792
1958
|
case "boolean": {
|
|
1793
1959
|
var n;
|
|
1794
1960
|
let r = ((n = t[e.name]) == null ? e.defaultValue : n) ? "checked" : "", i = e.subtitle ? `<div class="sim-settings-subtitle">${Q(e.subtitle)}</div>` : "";
|
|
@@ -1856,9 +2022,9 @@ function Z(e) {
|
|
|
1856
2022
|
return `<span class="simulator-label">${Q(e.title)}</span>${t}`;
|
|
1857
2023
|
}
|
|
1858
2024
|
/** Collects name → defaultValue pairs from components, recursing into split groups */
|
|
1859
|
-
function
|
|
2025
|
+
function Dt(e) {
|
|
1860
2026
|
let t = {};
|
|
1861
|
-
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);
|
|
1862
2028
|
return t;
|
|
1863
2029
|
}
|
|
1864
2030
|
function Q(e) {
|
|
@@ -1866,11 +2032,11 @@ function Q(e) {
|
|
|
1866
2032
|
}
|
|
1867
2033
|
var $ = null;
|
|
1868
2034
|
/** True when the game is embedded in the real Puzzmo app, which sets `?developer=true` on the iframe. */
|
|
1869
|
-
function
|
|
2035
|
+
function Ot() {
|
|
1870
2036
|
return typeof window > "u" ? !1 : new URLSearchParams(window.location.search).has("developer");
|
|
1871
2037
|
}
|
|
1872
2038
|
/** Inert instance returned when the simulator declines to boot (the app is the host). */
|
|
1873
|
-
var
|
|
2039
|
+
var kt = {
|
|
1874
2040
|
updateFixtures: () => {},
|
|
1875
2041
|
sendToGame: () => {},
|
|
1876
2042
|
loadPuzzle: function() {
|
|
@@ -1919,28 +2085,28 @@ var ht = {
|
|
|
1919
2085
|
* Fixtures are loaded as raw strings and passed to the game verbatim (any text format works; the game parses it).
|
|
1920
2086
|
* This will show dropdowns in the Ctrl tab to select category and puzzle.
|
|
1921
2087
|
*/
|
|
1922
|
-
function
|
|
2088
|
+
function At(e = {}) {
|
|
1923
2089
|
var n, r, i;
|
|
1924
|
-
if (
|
|
2090
|
+
if (Ot()) return console.log("[Simulator] developer=true in URL — running inside the Puzzmo app, skipping simulator boot"), kt;
|
|
1925
2091
|
if (console.log("[Simulator] createSimulator called with config:", {
|
|
1926
2092
|
slug: e.slug,
|
|
1927
2093
|
hasFixtures: !!e.fixtures
|
|
1928
2094
|
}), $) return e.fixtures && (console.log("[Simulator] Instance already exists, updating fixtures"), $.updateFixtures(e.fixtures)), $;
|
|
1929
|
-
let a = (n = e.autoStart) == null ? !0 : n, o = e.fixtures ?
|
|
1930
|
-
|
|
1931
|
-
|
|
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(),
|
|
1932
2098
|
c,
|
|
1933
|
-
|
|
1934
|
-
|
|
2099
|
+
he(),
|
|
2100
|
+
ge(),
|
|
1935
2101
|
l,
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
ot(),
|
|
1940
|
-
lt(),
|
|
2102
|
+
Te(),
|
|
2103
|
+
De(e.hostContextPresets),
|
|
2104
|
+
Ke(),
|
|
1941
2105
|
dt(),
|
|
2106
|
+
Ct(),
|
|
2107
|
+
Tt(),
|
|
1942
2108
|
...(r = e.views) == null ? [] : r
|
|
1943
|
-
], d = u.map((e) => e.id), f =
|
|
2109
|
+
], d = u.map((e) => e.id), f = ee(e, s, d), p = {
|
|
1944
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>",
|
|
1945
2111
|
play: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><polygon points=\"2,1 9,5 2,9\"/></svg>",
|
|
1946
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>",
|
|
@@ -1948,7 +2114,7 @@ function gt(e = {}) {
|
|
|
1948
2114
|
minimize: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><rect x=\"1\" y=\"4\" width=\"8\" height=\"2\"/></svg>",
|
|
1949
2115
|
expand: "<svg width=\"8\" height=\"8\" viewBox=\"0 0 8 8\" fill=\"currentColor\"><polygon points=\"1,1 7,4 1,7\"/></svg>"
|
|
1950
2116
|
}, m = document.createElement("div");
|
|
1951
|
-
m.id = "simulator", m.innerHTML = `
|
|
2117
|
+
m.id = "simulator", m.dataset.puzzmoBuild = se, m.innerHTML = `
|
|
1952
2118
|
<style>
|
|
1953
2119
|
:root {
|
|
1954
2120
|
--sim-bg: #1a1a2e;
|
|
@@ -3295,27 +3461,27 @@ function gt(e = {}) {
|
|
|
3295
3461
|
</div>
|
|
3296
3462
|
</div>
|
|
3297
3463
|
`, document.body.appendChild(m);
|
|
3298
|
-
let
|
|
3299
|
-
|
|
3300
|
-
},
|
|
3301
|
-
let n =
|
|
3302
|
-
n && (n.textContent = e), r && (r.className = `indicator ${t}`, r.textContent = i),
|
|
3303
|
-
},
|
|
3304
|
-
t && t !== "0" ?
|
|
3305
|
-
},
|
|
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) => {
|
|
3306
3472
|
var t;
|
|
3307
|
-
f.activeTab = e,
|
|
3473
|
+
f.activeTab = e, T.classList.remove("hidden"), ne(e), w.querySelectorAll(".simulator-tab").forEach((t) => {
|
|
3308
3474
|
t.classList.toggle("active", t.getAttribute("data-tab") === e);
|
|
3309
3475
|
}), m.querySelectorAll(".simulator-tab-content").forEach((t) => {
|
|
3310
3476
|
t.classList.toggle("active", t.id === `simulator-tab-${e}`);
|
|
3311
|
-
}),
|
|
3477
|
+
}), x.classList.toggle("active", e === "auth");
|
|
3312
3478
|
let n = u.find((t) => t.id === e);
|
|
3313
|
-
n == null || (t = n.onActivate) == null || t.call(n,
|
|
3314
|
-
},
|
|
3315
|
-
f.isCollapsed = e,
|
|
3316
|
-
},
|
|
3317
|
-
l.updatePreview(
|
|
3318
|
-
},
|
|
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() {
|
|
3319
3485
|
var e = t(function* () {
|
|
3320
3486
|
var e, t;
|
|
3321
3487
|
if (f.appliedPuzzleOverride !== null) return f.appliedPuzzleOverride;
|
|
@@ -3329,58 +3495,58 @@ function gt(e = {}) {
|
|
|
3329
3495
|
category: n,
|
|
3330
3496
|
puzzle: i
|
|
3331
3497
|
}), f.originalPuzzle = a;
|
|
3332
|
-
let c =
|
|
3333
|
-
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;
|
|
3334
3500
|
});
|
|
3335
3501
|
return function() {
|
|
3336
3502
|
return e.apply(this, arguments);
|
|
3337
3503
|
};
|
|
3338
|
-
}(),
|
|
3339
|
-
c.addLogEntry(e,
|
|
3340
|
-
}),
|
|
3341
|
-
|
|
3342
|
-
},
|
|
3504
|
+
}(), P = re((e) => {
|
|
3505
|
+
c.addLogEntry(e, L);
|
|
3506
|
+
}), F = (e, t) => {
|
|
3507
|
+
ie(e, t, P);
|
|
3508
|
+
}, I = (e, t) => {
|
|
3343
3509
|
let n = m.querySelector(`[data-badge="${e}"]`);
|
|
3344
3510
|
n && (n.textContent = t && t > 0 ? String(t) : "");
|
|
3345
|
-
},
|
|
3511
|
+
}, L = {
|
|
3346
3512
|
state: f,
|
|
3347
|
-
getElement:
|
|
3348
|
-
sendToGame:
|
|
3349
|
-
logMessage:
|
|
3350
|
-
loadPuzzle:
|
|
3351
|
-
updateStatus:
|
|
3352
|
-
updateTimer:
|
|
3353
|
-
setCollapsed:
|
|
3354
|
-
switchTab:
|
|
3355
|
-
updateThumbnail:
|
|
3356
|
-
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,
|
|
3357
3523
|
fixtures: o,
|
|
3358
3524
|
fixtureCategories: s,
|
|
3359
3525
|
gameSlug: (i = e.slug) == null ? null : i
|
|
3360
3526
|
};
|
|
3361
|
-
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) => {
|
|
3362
3528
|
e.addEventListener("click", () => {
|
|
3363
3529
|
let t = e.getAttribute("data-tab");
|
|
3364
|
-
|
|
3530
|
+
A(t), I(t, 0);
|
|
3365
3531
|
});
|
|
3366
|
-
}),
|
|
3367
|
-
e.stopPropagation(),
|
|
3368
|
-
}),
|
|
3369
|
-
e.stopPropagation(), f.isPaused ? (
|
|
3370
|
-
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");
|
|
3371
3537
|
t && (t.textContent = f.isPaused ? "Resume" : "Pause");
|
|
3372
|
-
}),
|
|
3373
|
-
e.stopPropagation(),
|
|
3374
|
-
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");
|
|
3375
3541
|
t && (t.disabled = !0, t.textContent = "Pause"), n && (n.textContent = "Start");
|
|
3376
|
-
}),
|
|
3377
|
-
e.stopPropagation(), f.isCollapsed &&
|
|
3378
|
-
}),
|
|
3379
|
-
f.isCollapsed && e.target !==
|
|
3380
|
-
}), f.isCollapsed ||
|
|
3381
|
-
let
|
|
3382
|
-
(
|
|
3383
|
-
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) => ({
|
|
3384
3550
|
userState: {
|
|
3385
3551
|
gameSettings: { "proto-game": f.gameSettings },
|
|
3386
3552
|
id: "simulator-user",
|
|
@@ -3421,42 +3587,42 @@ function gt(e = {}) {
|
|
|
3421
3587
|
theme: f.selectedTheme,
|
|
3422
3588
|
hostContext: f.hostContext,
|
|
3423
3589
|
appRuntimeContract: "1.0"
|
|
3424
|
-
}),
|
|
3590
|
+
}), B = function() {
|
|
3425
3591
|
var e = t(function* () {
|
|
3426
|
-
|
|
3592
|
+
O("Loading puzzle...", "waiting");
|
|
3427
3593
|
try {
|
|
3428
|
-
let e =
|
|
3429
|
-
|
|
3594
|
+
let e = z(yield N());
|
|
3595
|
+
O("Sending READY_DATA...", "waiting"), F("READY_DATA", e), O("Waiting for game to load...", "waiting");
|
|
3430
3596
|
} catch (e) {
|
|
3431
|
-
|
|
3597
|
+
O(`Error: ${e}`, "paused");
|
|
3432
3598
|
}
|
|
3433
3599
|
});
|
|
3434
3600
|
return function() {
|
|
3435
3601
|
return e.apply(this, arguments);
|
|
3436
3602
|
};
|
|
3437
|
-
}(),
|
|
3438
|
-
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) => {
|
|
3439
3605
|
var t;
|
|
3440
|
-
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);
|
|
3441
3607
|
}), a && !f.hasStarted && setTimeout(() => {
|
|
3442
|
-
let e =
|
|
3443
|
-
e == null || e.click(),
|
|
3608
|
+
let e = E("#simulator-start");
|
|
3609
|
+
e == null || e.click(), y.disabled = !1, f.hasStarted = !0, O("Running", "ready");
|
|
3444
3610
|
}, 100);
|
|
3445
3611
|
};
|
|
3446
|
-
return
|
|
3612
|
+
return ae((e, t) => {
|
|
3447
3613
|
var n, r;
|
|
3448
3614
|
if (e === "READY") {
|
|
3449
|
-
console.log("Simulator: Received READY from game"),
|
|
3615
|
+
console.log("Simulator: Received READY from game"), B();
|
|
3450
3616
|
return;
|
|
3451
3617
|
}
|
|
3452
3618
|
if (e === "READY_GAME_LOADED") {
|
|
3453
|
-
|
|
3619
|
+
V();
|
|
3454
3620
|
return;
|
|
3455
3621
|
}
|
|
3456
3622
|
if (e === "TIMER_TICK") {
|
|
3457
3623
|
if (t != null && t.display) {
|
|
3458
3624
|
let [e, n] = t.display;
|
|
3459
|
-
|
|
3625
|
+
k(e, n);
|
|
3460
3626
|
}
|
|
3461
3627
|
return;
|
|
3462
3628
|
}
|
|
@@ -3467,28 +3633,28 @@ function gt(e = {}) {
|
|
|
3467
3633
|
}
|
|
3468
3634
|
u.forEach((n) => {
|
|
3469
3635
|
var r;
|
|
3470
|
-
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);
|
|
3471
3637
|
});
|
|
3472
3638
|
let i = (n = t == null || (r = t.input) == null ? void 0 : r.boardState) == null ? t == null ? void 0 : t.boardState : n;
|
|
3473
|
-
e === "UPLOAD_NEW_GAME_STATE" && i && (f.currentInputStr = i, f.activeTab === "thumb" &&
|
|
3474
|
-
},
|
|
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"), $ = {
|
|
3475
3641
|
updateFixtures: (e) => {
|
|
3476
|
-
o =
|
|
3642
|
+
o = oe(e), s = Array.from(o.keys()).sort(), L.fixtures = o, L.fixtureCategories = s;
|
|
3477
3643
|
let t = localStorage.getItem("simulator-fixture-category");
|
|
3478
3644
|
if (!f.selectedCategory || !s.includes(f.selectedCategory)) {
|
|
3479
3645
|
var n;
|
|
3480
3646
|
f.selectedCategory = t && s.includes(t) ? t : (n = s[0]) == null ? null : n;
|
|
3481
3647
|
}
|
|
3482
3648
|
let r = u.find((e) => e.id === "ctrl");
|
|
3483
|
-
r == null || r.bind(
|
|
3649
|
+
r == null || r.bind(L), console.log("Simulator: Fixtures updated", {
|
|
3484
3650
|
categories: s,
|
|
3485
3651
|
selectedCategory: f.selectedCategory
|
|
3486
3652
|
});
|
|
3487
3653
|
},
|
|
3488
|
-
sendToGame:
|
|
3489
|
-
loadPuzzle:
|
|
3654
|
+
sendToGame: F,
|
|
3655
|
+
loadPuzzle: N
|
|
3490
3656
|
}, $;
|
|
3491
3657
|
}
|
|
3492
|
-
export {
|
|
3658
|
+
export { se as n, At as t };
|
|
3493
3659
|
|
|
3494
|
-
//# sourceMappingURL=createSimulator-
|
|
3660
|
+
//# sourceMappingURL=createSimulator-bJ1qCLmt.js.map
|