@puzzmo/sdk 1.0.43 → 1.0.45
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-rAf4hsaw.js → createSimulator-CRoIrAmo.js} +383 -312
- package/dist/createSimulator-CRoIrAmo.js.map +1 -0
- package/dist/{createSimulator-DjUNtpMH.cjs → createSimulator-gQ2ZBexI.cjs} +49 -32
- package/dist/createSimulator-gQ2ZBexI.cjs.map +1 -0
- package/dist/simulator/createSimulator.d.ts.map +1 -1
- 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 +12 -0
- package/dist/simulator/state.d.ts.map +1 -1
- package/dist/simulator/state.spec.d.ts +2 -0
- package/dist/simulator/state.spec.d.ts.map +1 -0
- package/dist/simulator/styles.d.ts +1 -1
- package/dist/simulator/styles.d.ts.map +1 -1
- package/dist/simulator/types.d.ts +4 -0
- package/dist/simulator/types.d.ts.map +1 -1
- package/dist/simulator/views/CtrlView.d.ts.map +1 -1
- package/dist/simulator/views/DataView.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/createSimulator-DjUNtpMH.cjs.map +0 -1
- package/dist/createSimulator-rAf4hsaw.js.map +0 -1
|
@@ -317,9 +317,41 @@ var r = {
|
|
|
317
317
|
previewKind: "simulator-preview-kind",
|
|
318
318
|
gameSettings: "simulator-game-settings",
|
|
319
319
|
hostContext: "simulator-host-context"
|
|
320
|
-
};
|
|
320
|
+
}, i = "simulator-override:";
|
|
321
|
+
/**
|
|
322
|
+
* Overrides are scoped to the page that applied them. localStorage is per-origin but a dev server
|
|
323
|
+
* commonly hosts many games from one origin (each at its own /games/<name>/ path), and an input
|
|
324
|
+
* string is only meaningful to the game it came from.
|
|
325
|
+
*/
|
|
326
|
+
function a(e) {
|
|
327
|
+
return `${i}${e}:${(window.location.pathname || "/").replace(/\/index\.html$/, "").replace(/\/+$/, "") || "/"}`;
|
|
328
|
+
}
|
|
329
|
+
/** The applied override for this page, or null when nothing has been applied. "" is a real value. */
|
|
330
|
+
function o(e) {
|
|
331
|
+
try {
|
|
332
|
+
return localStorage.getItem(a(e));
|
|
333
|
+
} catch (e) {
|
|
334
|
+
return null;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
/** False when the write failed — private-mode storage, or a board state over the origin's quota. */
|
|
338
|
+
function s(e, t) {
|
|
339
|
+
try {
|
|
340
|
+
return localStorage.setItem(a(e), t), !0;
|
|
341
|
+
} catch (e) {
|
|
342
|
+
return !1;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
function c(e) {
|
|
346
|
+
try {
|
|
347
|
+
localStorage.removeItem(a(e));
|
|
348
|
+
} catch (e) {}
|
|
349
|
+
}
|
|
350
|
+
function l() {
|
|
351
|
+
c("puzzle"), c("input");
|
|
352
|
+
}
|
|
321
353
|
/** The Host tab's persisted `hostContext` override, or null when the tab hasn't set one. */
|
|
322
|
-
function
|
|
354
|
+
function u() {
|
|
323
355
|
let e = localStorage.getItem(r.hostContext);
|
|
324
356
|
if (!e) return null;
|
|
325
357
|
try {
|
|
@@ -328,13 +360,13 @@ function i() {
|
|
|
328
360
|
} catch (e) {}
|
|
329
361
|
return null;
|
|
330
362
|
}
|
|
331
|
-
function
|
|
363
|
+
function d(e) {
|
|
332
364
|
localStorage.setItem(r.hostContext, JSON.stringify(e));
|
|
333
365
|
}
|
|
334
|
-
function
|
|
366
|
+
function f() {
|
|
335
367
|
localStorage.removeItem(r.hostContext);
|
|
336
368
|
}
|
|
337
|
-
function
|
|
369
|
+
function p() {
|
|
338
370
|
let e = localStorage.getItem(r.gameSettings);
|
|
339
371
|
if (!e) return {};
|
|
340
372
|
try {
|
|
@@ -343,7 +375,7 @@ function s() {
|
|
|
343
375
|
} catch (e) {}
|
|
344
376
|
return {};
|
|
345
377
|
}
|
|
346
|
-
function
|
|
378
|
+
function m() {
|
|
347
379
|
let e = localStorage.getItem(r.theme);
|
|
348
380
|
if (e) {
|
|
349
381
|
let t = n.find((t) => t.name === e);
|
|
@@ -351,16 +383,16 @@ function c() {
|
|
|
351
383
|
}
|
|
352
384
|
return n[0];
|
|
353
385
|
}
|
|
354
|
-
function
|
|
386
|
+
function ee(e) {
|
|
355
387
|
var t;
|
|
356
388
|
let n = localStorage.getItem(r.tab);
|
|
357
389
|
return n && e.includes(n) ? n : (t = e[0]) == null ? "ctrl" : t;
|
|
358
390
|
}
|
|
359
|
-
function
|
|
391
|
+
function te(e) {
|
|
360
392
|
let t = localStorage.getItem(r.collapsed);
|
|
361
393
|
return t === null ? e : t === "true";
|
|
362
394
|
}
|
|
363
|
-
function
|
|
395
|
+
function h() {
|
|
364
396
|
let e = localStorage.getItem(r.renderHost);
|
|
365
397
|
return e && [
|
|
366
398
|
"game",
|
|
@@ -368,10 +400,10 @@ function d() {
|
|
|
368
400
|
"opengraph"
|
|
369
401
|
].includes(e) ? e : "game";
|
|
370
402
|
}
|
|
371
|
-
function
|
|
403
|
+
function ne() {
|
|
372
404
|
return localStorage.getItem(r.previewKind) === "text" ? "text" : "image";
|
|
373
405
|
}
|
|
374
|
-
function
|
|
406
|
+
function g() {
|
|
375
407
|
let e = localStorage.getItem(r.renderContext);
|
|
376
408
|
if (e && [
|
|
377
409
|
"preview",
|
|
@@ -380,68 +412,70 @@ function p() {
|
|
|
380
412
|
"timeline"
|
|
381
413
|
].includes(e)) return e;
|
|
382
414
|
}
|
|
383
|
-
function
|
|
384
|
-
var
|
|
385
|
-
let
|
|
415
|
+
function _(e, t, n) {
|
|
416
|
+
var i, a, s;
|
|
417
|
+
let c = localStorage.getItem(r.fixtureCategory), l = localStorage.getItem(r.fixturePuzzle), d = u(), f = o("puzzle"), _ = o("input");
|
|
386
418
|
return {
|
|
387
|
-
hostContext: (
|
|
419
|
+
hostContext: (i = d == null ? e.hostContext : d) == null ? [{
|
|
388
420
|
type: "app",
|
|
389
421
|
layout: "desktop",
|
|
390
422
|
host: null
|
|
391
|
-
}] :
|
|
392
|
-
hostContextIsOverridden:
|
|
393
|
-
isCollapsed:
|
|
423
|
+
}] : i,
|
|
424
|
+
hostContextIsOverridden: d !== null,
|
|
425
|
+
isCollapsed: te((a = e.collapsed) == null ? !0 : a),
|
|
394
426
|
isPaused: !1,
|
|
395
427
|
hasStarted: !1,
|
|
396
|
-
activeTab:
|
|
397
|
-
puzzleData:
|
|
398
|
-
originalPuzzle: "",
|
|
399
|
-
currentInputStr: "",
|
|
428
|
+
activeTab: ee(n),
|
|
429
|
+
puzzleData: f,
|
|
430
|
+
originalPuzzle: f == null ? "" : f,
|
|
431
|
+
currentInputStr: _ == null ? "" : _,
|
|
432
|
+
appliedPuzzleOverride: f,
|
|
433
|
+
appliedInputOverride: _,
|
|
400
434
|
completionData: null,
|
|
401
|
-
selectedTheme:
|
|
402
|
-
selectedCategory:
|
|
403
|
-
selectedPuzzle:
|
|
404
|
-
renderHost:
|
|
405
|
-
renderContext:
|
|
406
|
-
previewKind:
|
|
407
|
-
gameSettings:
|
|
435
|
+
selectedTheme: m(),
|
|
436
|
+
selectedCategory: c && t.includes(c) ? c : (s = t[0]) == null ? null : s,
|
|
437
|
+
selectedPuzzle: l == null ? null : l,
|
|
438
|
+
renderHost: h(),
|
|
439
|
+
renderContext: g(),
|
|
440
|
+
previewKind: ne(),
|
|
441
|
+
gameSettings: p(),
|
|
408
442
|
settingsComponents: null
|
|
409
443
|
};
|
|
410
444
|
}
|
|
411
|
-
function
|
|
445
|
+
function v(e) {
|
|
412
446
|
localStorage.setItem(r.gameSettings, JSON.stringify(e));
|
|
413
447
|
}
|
|
414
|
-
function
|
|
448
|
+
function y() {
|
|
415
449
|
localStorage.removeItem(r.gameSettings);
|
|
416
450
|
}
|
|
417
|
-
function
|
|
451
|
+
function re(e) {
|
|
418
452
|
localStorage.setItem(r.collapsed, String(e));
|
|
419
453
|
}
|
|
420
|
-
function
|
|
454
|
+
function ie(e) {
|
|
421
455
|
localStorage.setItem(r.tab, e);
|
|
422
456
|
}
|
|
423
|
-
function
|
|
457
|
+
function ae(e) {
|
|
424
458
|
localStorage.setItem(r.theme, e);
|
|
425
459
|
}
|
|
426
|
-
function
|
|
460
|
+
function b(e) {
|
|
427
461
|
localStorage.setItem(r.fixtureCategory, e);
|
|
428
462
|
}
|
|
429
|
-
function
|
|
463
|
+
function x(e) {
|
|
430
464
|
localStorage.setItem(r.fixturePuzzle, e);
|
|
431
465
|
}
|
|
432
|
-
function
|
|
466
|
+
function S() {
|
|
433
467
|
localStorage.removeItem(r.fixturePuzzle);
|
|
434
468
|
}
|
|
435
|
-
function
|
|
469
|
+
function C(e) {
|
|
436
470
|
e ? localStorage.setItem(r.renderHost, e) : localStorage.removeItem(r.renderHost);
|
|
437
471
|
}
|
|
438
|
-
function
|
|
472
|
+
function w(e) {
|
|
439
473
|
localStorage.setItem(r.previewKind, e);
|
|
440
474
|
}
|
|
441
|
-
function
|
|
475
|
+
function T(e) {
|
|
442
476
|
e ? localStorage.setItem(r.renderContext, e) : localStorage.removeItem(r.renderContext);
|
|
443
477
|
}
|
|
444
|
-
function
|
|
478
|
+
function oe(e) {
|
|
445
479
|
let t = [];
|
|
446
480
|
return {
|
|
447
481
|
log(n, r, i) {
|
|
@@ -466,13 +500,13 @@ function re(e) {
|
|
|
466
500
|
}
|
|
467
501
|
};
|
|
468
502
|
}
|
|
469
|
-
function
|
|
503
|
+
function se(e, t, n) {
|
|
470
504
|
console.log("Simulator sending:", e, t), n == null || n.log(e, t, "out"), window.postMessage({
|
|
471
505
|
type: e,
|
|
472
506
|
data: t
|
|
473
507
|
}, "*");
|
|
474
508
|
}
|
|
475
|
-
function
|
|
509
|
+
function ce(e, t) {
|
|
476
510
|
let n = (n) => {
|
|
477
511
|
var r, i, a;
|
|
478
512
|
if (!(!(n == null || (r = n.data) == null) && r.type)) return;
|
|
@@ -482,7 +516,7 @@ function ae(e, t) {
|
|
|
482
516
|
return window.addEventListener("message", n), () => window.removeEventListener("message", n);
|
|
483
517
|
}
|
|
484
518
|
/** Parse fixture imports into a structured format: { category: { filename: data } } */
|
|
485
|
-
function
|
|
519
|
+
function le(e) {
|
|
486
520
|
let t = /* @__PURE__ */ new Map();
|
|
487
521
|
console.log("Simulator: Parsing fixtures", Object.keys(e));
|
|
488
522
|
for (let [o, s] of Object.entries(e)) {
|
|
@@ -501,7 +535,7 @@ function oe(e) {
|
|
|
501
535
|
}), t;
|
|
502
536
|
}
|
|
503
537
|
/** Render fixture selector HTML */
|
|
504
|
-
function
|
|
538
|
+
function E(e, t) {
|
|
505
539
|
return e.length === 0 ? "" : `
|
|
506
540
|
<div class="simulator-fixtures">
|
|
507
541
|
<div class="simulator-field">
|
|
@@ -518,7 +552,7 @@ function C(e, t) {
|
|
|
518
552
|
`;
|
|
519
553
|
}
|
|
520
554
|
/** Update puzzle select options based on selected category */
|
|
521
|
-
function
|
|
555
|
+
function D(e, t, n, r) {
|
|
522
556
|
let i = t.get(n);
|
|
523
557
|
if (!i) return null;
|
|
524
558
|
let a = Array.from(i.keys()), o = r;
|
|
@@ -529,11 +563,11 @@ function w(e, t, n, r) {
|
|
|
529
563
|
return e.innerHTML = a.map((e) => `<option value="${e}" ${e === o ? "selected" : ""}>${e}</option>`).join(""), o;
|
|
530
564
|
}
|
|
531
565
|
/** Get puzzle data from fixtures */
|
|
532
|
-
function
|
|
566
|
+
function O(e, t, n) {
|
|
533
567
|
var r, i;
|
|
534
568
|
return !t || !n || (r = (i = e.get(t)) == null ? void 0 : i.get(n)) == null ? null : r;
|
|
535
569
|
}
|
|
536
|
-
function
|
|
570
|
+
function ue() {
|
|
537
571
|
return {
|
|
538
572
|
id: "ctrl",
|
|
539
573
|
label: "Ctrl",
|
|
@@ -548,19 +582,19 @@ function se() {
|
|
|
548
582
|
selectedCategory: e.state.selectedCategory,
|
|
549
583
|
selectedPuzzle: e.state.selectedPuzzle
|
|
550
584
|
}), e.fixtures && e.fixtureCategories.length > 0 && i) {
|
|
551
|
-
i.innerHTML =
|
|
585
|
+
i.innerHTML = E(e.fixtureCategories, e.state.selectedCategory);
|
|
552
586
|
let t = e.getElement("#simulator-fixture-category"), n = e.getElement("#simulator-fixture-puzzle");
|
|
553
587
|
if (t && n && e.state.selectedCategory) {
|
|
554
|
-
e.state.selectedPuzzle =
|
|
555
|
-
let r =
|
|
588
|
+
e.state.selectedPuzzle = D(n, e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
|
|
589
|
+
let r = O(e.fixtures, e.state.selectedCategory, e.state.selectedPuzzle);
|
|
556
590
|
console.log("Simulator: Loading fixture puzzle", {
|
|
557
591
|
category: e.state.selectedCategory,
|
|
558
592
|
puzzle: e.state.selectedPuzzle,
|
|
559
593
|
hasPuzzleData: !!r
|
|
560
|
-
}), r && (e.state.puzzleData = r, e.state.originalPuzzle = r, e.state.selectedCategory &&
|
|
561
|
-
console.log("Simulator: Category changed, reloading...", t.value),
|
|
594
|
+
}), r && (e.state.appliedPuzzleOverride === null && (e.state.puzzleData = r, e.state.originalPuzzle = r), e.state.selectedCategory && b(e.state.selectedCategory), e.state.selectedPuzzle && x(e.state.selectedPuzzle)), t.addEventListener("change", () => {
|
|
595
|
+
console.log("Simulator: Category changed, reloading...", t.value), l(), b(t.value), S(), window.location.reload();
|
|
562
596
|
}), n.addEventListener("change", () => {
|
|
563
|
-
console.log("Simulator: Puzzle changed, reloading...", n.value),
|
|
597
|
+
console.log("Simulator: Puzzle changed, reloading...", n.value), l(), x(n.value), window.location.reload();
|
|
564
598
|
});
|
|
565
599
|
}
|
|
566
600
|
}
|
|
@@ -586,10 +620,10 @@ function se() {
|
|
|
586
620
|
* Inlined here (rather than shared with the rest of the monorepo) because the SDK ships to OSS and
|
|
587
621
|
* must stay self-contained.
|
|
588
622
|
*/
|
|
589
|
-
function
|
|
623
|
+
function k(e) {
|
|
590
624
|
var t;
|
|
591
625
|
if (typeof e != "string") return e;
|
|
592
|
-
let n = (t =
|
|
626
|
+
let n = (t = A(e)) == null ? {
|
|
593
627
|
width: 800,
|
|
594
628
|
height: 800
|
|
595
629
|
} : t;
|
|
@@ -600,7 +634,7 @@ function E(e) {
|
|
|
600
634
|
};
|
|
601
635
|
}
|
|
602
636
|
/** Reads an SVG's intrinsic size from its `viewBox` (preferred) or its `width`/`height` attributes. */
|
|
603
|
-
function
|
|
637
|
+
function A(e) {
|
|
604
638
|
var t, n, r, i;
|
|
605
639
|
let a = e.indexOf("<svg");
|
|
606
640
|
if (a === -1) return;
|
|
@@ -618,9 +652,9 @@ function D(e) {
|
|
|
618
652
|
height: u
|
|
619
653
|
};
|
|
620
654
|
}
|
|
621
|
-
var
|
|
655
|
+
var j = "simulator-saved-states";
|
|
622
656
|
/** Find thumbnail function on globalThis (looks for functions ending in "Thumbnail") */
|
|
623
|
-
function
|
|
657
|
+
function M() {
|
|
624
658
|
let e = globalThis;
|
|
625
659
|
for (let t of Object.keys(e)) if (t.endsWith("Thumbnail") && typeof e[t] == "function") return {
|
|
626
660
|
name: t,
|
|
@@ -629,8 +663,8 @@ function k() {
|
|
|
629
663
|
return null;
|
|
630
664
|
}
|
|
631
665
|
/** Generate a small thumbnail SVG for a given input string */
|
|
632
|
-
function
|
|
633
|
-
let n =
|
|
666
|
+
function N(e, t) {
|
|
667
|
+
let n = M();
|
|
634
668
|
if (!n) return "";
|
|
635
669
|
try {
|
|
636
670
|
var r;
|
|
@@ -640,25 +674,25 @@ function A(e, t) {
|
|
|
640
674
|
strict: !0,
|
|
641
675
|
renderHost: "game"
|
|
642
676
|
};
|
|
643
|
-
return
|
|
677
|
+
return k(n.fn(i, t, a)).svg;
|
|
644
678
|
} catch (e) {
|
|
645
679
|
return "";
|
|
646
680
|
}
|
|
647
681
|
}
|
|
648
|
-
var
|
|
649
|
-
function
|
|
682
|
+
var P = [];
|
|
683
|
+
function F(e, t = 8) {
|
|
650
684
|
let n = 14 * t + 8 + 4;
|
|
651
685
|
e.style.height = "auto";
|
|
652
686
|
let r = Math.min(Math.max(e.scrollHeight, 40), n);
|
|
653
687
|
e.style.height = `${r}px`;
|
|
654
688
|
}
|
|
655
|
-
function
|
|
689
|
+
function de() {
|
|
656
690
|
let e = "", t = "";
|
|
657
691
|
return {
|
|
658
692
|
id: "data",
|
|
659
693
|
label: "Data",
|
|
660
694
|
render() {
|
|
661
|
-
return "\n <div class=\"data-view-container\">\n <div class=\"data-subtabs\">\n <button class=\"data-subtab active\" data-subtab=\"edit\">Edit</button>\n <button class=\"data-subtab\" data-subtab=\"history\">History</button>\n <button class=\"data-subtab\" data-subtab=\"saves\">Saves</button>\n </div>\n\n <div class=\"data-subtab-content active\" id=\"data-subtab-edit\">\n <div class=\"simulator-field\">\n <label class=\"simulator-label\"
|
|
695
|
+
return "\n <div class=\"data-view-container\">\n <div class=\"data-subtabs\">\n <button class=\"data-subtab active\" data-subtab=\"edit\">Edit</button>\n <button class=\"data-subtab\" data-subtab=\"history\">History</button>\n <button class=\"data-subtab\" data-subtab=\"saves\">Saves</button>\n </div>\n\n <div class=\"data-subtab-content active\" id=\"data-subtab-edit\">\n <div class=\"simulator-field\">\n <label class=\"simulator-label\">\n Puzzle String<span class=\"simulator-override-tag\" id=\"simulator-puzzle-override-tag\" hidden>applied</span>\n </label>\n <textarea class=\"simulator-textarea auto-resize\" id=\"simulator-puzzle\" placeholder=\"Loading...\"></textarea>\n <div class=\"simulator-row\">\n <button class=\"simulator-btn subtle\" id=\"simulator-puzzle-reset\">Reset</button>\n <button class=\"simulator-btn primary\" id=\"simulator-puzzle-apply\" disabled>Apply</button>\n </div>\n </div>\n <div class=\"simulator-divider\"></div>\n <div class=\"simulator-field\">\n <label class=\"simulator-label\">\n Input String<span class=\"simulator-override-tag\" id=\"simulator-input-override-tag\" hidden>applied</span>\n </label>\n <textarea class=\"simulator-textarea auto-resize\" id=\"simulator-input\" placeholder=\"No input yet...\"></textarea>\n <div class=\"simulator-row\">\n <button class=\"simulator-btn subtle\" id=\"simulator-input-reset\">Reset</button>\n <button class=\"simulator-btn primary\" id=\"simulator-input-apply\" disabled>Apply</button>\n </div>\n </div>\n </div>\n\n <div class=\"data-subtab-content\" id=\"data-subtab-history\">\n <div class=\"history-header\">\n <span class=\"simulator-label\">Input String Timeline</span>\n <button class=\"simulator-btn tiny\" id=\"simulator-history-clear\">Clear</button>\n </div>\n <div class=\"history-list\" id=\"simulator-history-list\">\n <div class=\"simulator-empty\">No history yet</div>\n </div>\n </div>\n\n <div class=\"data-subtab-content\" id=\"data-subtab-saves\">\n <div class=\"save-new\">\n <input type=\"text\" class=\"simulator-input\" id=\"simulator-save-name\" placeholder=\"Save name...\" />\n <button class=\"simulator-btn primary\" id=\"simulator-save-btn\">Save</button>\n </div>\n <div class=\"simulator-divider\"></div>\n <div class=\"saves-list\" id=\"simulator-saves-list\">\n <div class=\"simulator-empty\">No saved states</div>\n </div>\n </div>\n </div>\n ";
|
|
662
696
|
},
|
|
663
697
|
bind(n) {
|
|
664
698
|
let r = n.getElement(".data-subtabs");
|
|
@@ -670,113 +704,132 @@ function ce() {
|
|
|
670
704
|
let i = n.getElement(".data-view-container");
|
|
671
705
|
i == null || i.querySelectorAll(".data-subtab-content").forEach((e) => {
|
|
672
706
|
e.classList.toggle("active", e.id === `data-subtab-${t}`);
|
|
673
|
-
}), t === "edit" ?
|
|
707
|
+
}), t === "edit" ? pe(n) : t === "history" ? L(n) : t === "saves" && R(n);
|
|
674
708
|
});
|
|
675
709
|
});
|
|
676
|
-
let i = n.getElement("#simulator-puzzle"), a = n.getElement("#simulator-input"), o = n.getElement("#simulator-puzzle-reset"),
|
|
710
|
+
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");
|
|
677
711
|
setTimeout(() => {
|
|
678
|
-
i && n.state.originalPuzzle && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle,
|
|
712
|
+
i && n.state.originalPuzzle && document.activeElement !== i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle, F(i)), a && n.state.currentInputStr && document.activeElement !== a && (a.value = n.state.currentInputStr, t = n.state.currentInputStr, F(a)), me(n);
|
|
679
713
|
}, 0), i == null || i.addEventListener("input", () => {
|
|
680
|
-
|
|
714
|
+
F(i);
|
|
681
715
|
let t = i.value !== e;
|
|
682
|
-
|
|
716
|
+
l && (l.disabled = !t);
|
|
683
717
|
}), a == null || a.addEventListener("input", () => {
|
|
684
|
-
|
|
718
|
+
F(a);
|
|
685
719
|
let e = a.value !== t;
|
|
686
|
-
|
|
720
|
+
d && (d.disabled = !e);
|
|
687
721
|
}), o == null || o.addEventListener("click", () => {
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
722
|
+
if (n.state.appliedPuzzleOverride !== null) {
|
|
723
|
+
c("puzzle"), n.updateStatus("Restoring fixture puzzle...", "waiting"), window.location.reload();
|
|
724
|
+
return;
|
|
725
|
+
}
|
|
726
|
+
i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle, F(i), l && (l.disabled = !0));
|
|
693
727
|
}), l == null || l.addEventListener("click", () => {
|
|
694
|
-
|
|
728
|
+
if (i) {
|
|
729
|
+
if (!s("puzzle", i.value)) {
|
|
730
|
+
n.updateStatus("Could not store puzzle — storage unavailable", "paused");
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
c("input"), l.disabled = !0, n.updateStatus("Applying puzzle...", "waiting"), window.location.reload();
|
|
734
|
+
}
|
|
735
|
+
}), u == null || u.addEventListener("click", () => {
|
|
736
|
+
if (n.state.appliedInputOverride !== null) {
|
|
737
|
+
c("input"), n.updateStatus("Clearing input...", "waiting"), window.location.reload();
|
|
738
|
+
return;
|
|
739
|
+
}
|
|
740
|
+
a && (a.value = t, F(a), d && (d.disabled = !0));
|
|
741
|
+
}), d == null || d.addEventListener("click", () => {
|
|
742
|
+
if (a) {
|
|
743
|
+
if (!s("input", a.value)) {
|
|
744
|
+
n.updateStatus("Could not store input — storage unavailable", "paused");
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
747
|
+
d.disabled = !0, n.updateStatus("Applying input...", "waiting"), window.location.reload();
|
|
748
|
+
}
|
|
695
749
|
});
|
|
696
750
|
let f = n.getElement("#simulator-history-clear");
|
|
697
751
|
f == null || f.addEventListener("click", () => {
|
|
698
|
-
|
|
752
|
+
P = [], L(n);
|
|
699
753
|
});
|
|
700
754
|
let p = n.getElement("#simulator-save-name"), m = n.getElement("#simulator-save-btn");
|
|
701
755
|
m == null || m.addEventListener("click", () => {
|
|
702
756
|
if (!p || !p.value.trim()) return;
|
|
703
|
-
let e =
|
|
757
|
+
let e = I(), t = {
|
|
704
758
|
name: p.value.trim(),
|
|
705
759
|
puzzleStr: n.state.originalPuzzle,
|
|
706
760
|
inputStr: n.state.currentInputStr,
|
|
707
761
|
timestamp: Date.now()
|
|
708
762
|
};
|
|
709
|
-
e.push(t), localStorage.setItem(
|
|
710
|
-
}),
|
|
763
|
+
e.push(t), localStorage.setItem(j, JSON.stringify(e)), p.value = "", R(n);
|
|
764
|
+
}), R(n);
|
|
711
765
|
},
|
|
712
766
|
onActivate(n) {
|
|
713
|
-
e = n.state.originalPuzzle, t = n.state.currentInputStr,
|
|
767
|
+
e = n.state.originalPuzzle, t = n.state.currentInputStr, pe(n), L(n);
|
|
714
768
|
},
|
|
715
769
|
onMessage(e, n, r) {
|
|
716
770
|
var i, a;
|
|
717
771
|
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;
|
|
718
772
|
if (e === "UPLOAD_NEW_GAME_STATE" && c) {
|
|
719
|
-
if (r.state.currentInputStr = c,
|
|
720
|
-
|
|
773
|
+
if (r.state.currentInputStr = c, P.length === 0 || P[P.length - 1].value !== c) {
|
|
774
|
+
P.push({
|
|
721
775
|
value: c,
|
|
722
776
|
timestamp: Date.now()
|
|
723
|
-
}),
|
|
777
|
+
}), P.length > 100 && (P = P.slice(-100));
|
|
724
778
|
let e = r.getElement("#data-subtab-history");
|
|
725
|
-
e != null && e.classList.contains("active") &&
|
|
779
|
+
e != null && e.classList.contains("active") && L(r);
|
|
726
780
|
}
|
|
727
|
-
o && (o.value
|
|
781
|
+
o && document.activeElement !== o && (o.value !== c && (o.value = c, F(o)), t = c, s && (s.disabled = !0));
|
|
728
782
|
}
|
|
729
783
|
}
|
|
730
784
|
};
|
|
731
785
|
}
|
|
732
|
-
function
|
|
786
|
+
function I() {
|
|
733
787
|
try {
|
|
734
|
-
let e = localStorage.getItem(
|
|
788
|
+
let e = localStorage.getItem(j);
|
|
735
789
|
return e ? JSON.parse(e) : [];
|
|
736
790
|
} catch (e) {
|
|
737
791
|
return [];
|
|
738
792
|
}
|
|
739
793
|
}
|
|
740
|
-
function
|
|
794
|
+
function L(e) {
|
|
741
795
|
let t = e.getElement("#simulator-history-list");
|
|
742
796
|
if (t) {
|
|
743
|
-
if (t.style.setProperty("--history-thumb-bg", e.state.selectedTheme.a_bg),
|
|
797
|
+
if (t.style.setProperty("--history-thumb-bg", e.state.selectedTheme.a_bg), P.length === 0) {
|
|
744
798
|
t.innerHTML = "<div class=\"simulator-empty\">No history yet</div>";
|
|
745
799
|
return;
|
|
746
800
|
}
|
|
747
|
-
t.innerHTML = [...
|
|
748
|
-
let r =
|
|
801
|
+
t.innerHTML = [...P].reverse().map((t, n) => {
|
|
802
|
+
let r = P.length - 1 - n, i = new Date(t.timestamp).toLocaleTimeString(), a = t.value.length > 60 ? t.value.slice(0, 60) + "..." : t.value;
|
|
749
803
|
return `
|
|
750
804
|
<div class="history-item" data-history-idx="${r}">
|
|
751
|
-
<div class="history-item-thumb">${
|
|
805
|
+
<div class="history-item-thumb">${N(e, t.value)}</div>
|
|
752
806
|
<div class="history-item-content">
|
|
753
807
|
<div class="history-item-header">
|
|
754
808
|
<span class="history-item-num">#${r + 1}</span>
|
|
755
809
|
<span class="history-item-time">${i}</span>
|
|
756
810
|
<button class="simulator-btn tiny history-restore-btn" data-history-idx="${r}">Restore</button>
|
|
757
811
|
</div>
|
|
758
|
-
<div class="history-item-preview">${
|
|
812
|
+
<div class="history-item-preview">${fe(a)}</div>
|
|
759
813
|
</div>
|
|
760
814
|
</div>
|
|
761
815
|
`;
|
|
762
816
|
}).join(""), t.querySelectorAll(".history-restore-btn").forEach((t) => {
|
|
763
817
|
t.addEventListener("click", (t) => {
|
|
764
|
-
let n = parseInt(t.target.getAttribute("data-history-idx") || "0"), r =
|
|
818
|
+
let n = parseInt(t.target.getAttribute("data-history-idx") || "0"), r = P[n];
|
|
765
819
|
if (r) {
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
n == null || n.click();
|
|
820
|
+
let t = e.getElement(".data-subtab[data-subtab=\"edit\"]");
|
|
821
|
+
t == null || t.click();
|
|
822
|
+
let n = e.getElement("#simulator-input"), i = e.getElement("#simulator-input-apply");
|
|
823
|
+
n && (n.value = r.value, F(n)), i && (i.disabled = !1), e.updateStatus("Input restored — press Apply to load it", "ready");
|
|
771
824
|
}
|
|
772
825
|
});
|
|
773
826
|
});
|
|
774
827
|
}
|
|
775
828
|
}
|
|
776
|
-
function
|
|
829
|
+
function R(e) {
|
|
777
830
|
let t = e.getElement("#simulator-saves-list");
|
|
778
831
|
if (!t) return;
|
|
779
|
-
let n =
|
|
832
|
+
let n = I();
|
|
780
833
|
if (n.length === 0) {
|
|
781
834
|
t.innerHTML = "<div class=\"simulator-empty\">No saved states</div>";
|
|
782
835
|
return;
|
|
@@ -786,7 +839,7 @@ function F(e) {
|
|
|
786
839
|
return `
|
|
787
840
|
<div class="save-item">
|
|
788
841
|
<div class="save-item-header">
|
|
789
|
-
<span class="save-item-name">${
|
|
842
|
+
<span class="save-item-name">${fe(e.name)}</span>
|
|
790
843
|
<span class="save-item-time">${i} ${a}</span>
|
|
791
844
|
</div>
|
|
792
845
|
<div class="save-item-actions">
|
|
@@ -799,31 +852,35 @@ function F(e) {
|
|
|
799
852
|
t.addEventListener("click", (t) => {
|
|
800
853
|
let r = n[parseInt(t.target.getAttribute("data-save-idx") || "0")];
|
|
801
854
|
if (r) {
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
855
|
+
if (!s("puzzle", r.puzzleStr) || !s("input", r.inputStr)) {
|
|
856
|
+
l(), e.updateStatus(`Could not load "${r.name}" — storage unavailable`, "paused");
|
|
857
|
+
return;
|
|
858
|
+
}
|
|
859
|
+
e.updateStatus(`Loading: ${r.name}`, "waiting"), window.location.reload();
|
|
807
860
|
}
|
|
808
861
|
});
|
|
809
862
|
}), t.querySelectorAll(".save-delete-btn").forEach((t) => {
|
|
810
863
|
t.addEventListener("click", (t) => {
|
|
811
864
|
let r = parseInt(t.target.getAttribute("data-save-idx") || "0"), i = n.filter((e, t) => t !== r);
|
|
812
|
-
localStorage.setItem(
|
|
865
|
+
localStorage.setItem(j, JSON.stringify(i)), R(e);
|
|
813
866
|
});
|
|
814
867
|
});
|
|
815
868
|
}
|
|
816
|
-
function
|
|
869
|
+
function fe(e) {
|
|
817
870
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
818
871
|
}
|
|
819
|
-
function
|
|
872
|
+
function pe(e) {
|
|
820
873
|
let t = e.getElement("#simulator-puzzle"), n = e.getElement("#simulator-input"), r = e.getElement("#simulator-puzzle-apply"), i = e.getElement("#simulator-input-apply");
|
|
821
|
-
t && e.state.originalPuzzle && (t.value = e.state.originalPuzzle,
|
|
874
|
+
t && e.state.originalPuzzle && (t.value = e.state.originalPuzzle, F(t), r && (r.disabled = !0)), n && (n.value = e.state.currentInputStr, F(n), i && (i.disabled = !0)), me(e);
|
|
822
875
|
}
|
|
823
|
-
function
|
|
876
|
+
function me(e) {
|
|
877
|
+
let t = e.getElement("#simulator-puzzle-override-tag"), n = e.getElement("#simulator-input-override-tag");
|
|
878
|
+
t && (t.hidden = e.state.appliedPuzzleOverride === null), n && (n.hidden = e.state.appliedInputOverride === null);
|
|
879
|
+
}
|
|
880
|
+
function he(e) {
|
|
824
881
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
825
882
|
}
|
|
826
|
-
function
|
|
883
|
+
function ge() {
|
|
827
884
|
let e = 0;
|
|
828
885
|
return {
|
|
829
886
|
id: "msgs",
|
|
@@ -850,7 +907,7 @@ function le() {
|
|
|
850
907
|
<span class="simulator-msg-type">${t.direction === "out" ? "→" : "←"} ${t.type}</span>
|
|
851
908
|
<span class="simulator-msg-time">${t.time}</span>
|
|
852
909
|
</div>
|
|
853
|
-
${a ? `<div class="simulator-msg-data">${
|
|
910
|
+
${a ? `<div class="simulator-msg-data">${he(a)}</div>` : ""}
|
|
854
911
|
`;
|
|
855
912
|
let o = i.querySelector(".simulator-msg-data");
|
|
856
913
|
for (o && o.addEventListener("click", () => {
|
|
@@ -861,7 +918,7 @@ function le() {
|
|
|
861
918
|
}
|
|
862
919
|
};
|
|
863
920
|
}
|
|
864
|
-
function
|
|
921
|
+
function _e() {
|
|
865
922
|
return {
|
|
866
923
|
id: "done",
|
|
867
924
|
label: "Done",
|
|
@@ -898,7 +955,7 @@ function ue() {
|
|
|
898
955
|
}
|
|
899
956
|
};
|
|
900
957
|
}
|
|
901
|
-
function
|
|
958
|
+
function ve() {
|
|
902
959
|
let e = [], t = () => (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", { hour12: !1 }), n = (e) => {
|
|
903
960
|
let { checkpointName: t, augConfig: n, time: r } = e, i = n == null ? void 0 : n.deeds;
|
|
904
961
|
return `
|
|
@@ -949,7 +1006,7 @@ function de() {
|
|
|
949
1006
|
};
|
|
950
1007
|
}
|
|
951
1008
|
/** Find thumbnail function on globalThis (looks for functions ending in "Thumbnail") */
|
|
952
|
-
function
|
|
1009
|
+
function ye() {
|
|
953
1010
|
let e = globalThis;
|
|
954
1011
|
for (let t of Object.keys(e)) if (t.endsWith("Thumbnail") && typeof e[t] == "function") return {
|
|
955
1012
|
name: t,
|
|
@@ -958,23 +1015,23 @@ function fe() {
|
|
|
958
1015
|
return null;
|
|
959
1016
|
}
|
|
960
1017
|
/** The bundle's `getShareString` (if any), exposed to the sim via vite.ts's bundle loader. */
|
|
961
|
-
function
|
|
1018
|
+
function be() {
|
|
962
1019
|
let e = globalThis.getShareString;
|
|
963
1020
|
return typeof e == "function" ? e : null;
|
|
964
1021
|
}
|
|
965
|
-
function
|
|
1022
|
+
function xe(e) {
|
|
966
1023
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
967
1024
|
}
|
|
968
|
-
function
|
|
1025
|
+
function Se() {
|
|
969
1026
|
let e = /* @__PURE__ */ new Date();
|
|
970
1027
|
return `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`;
|
|
971
1028
|
}
|
|
972
|
-
function
|
|
1029
|
+
function Ce(e) {
|
|
973
1030
|
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
974
1031
|
}
|
|
975
1032
|
/** Shown when Preview Kind = Text but the bundle doesn't export `getShareString`. */
|
|
976
|
-
var
|
|
977
|
-
function
|
|
1033
|
+
var we = "\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";
|
|
1034
|
+
function Te() {
|
|
978
1035
|
return {
|
|
979
1036
|
id: "thumb",
|
|
980
1037
|
label: "Thumb",
|
|
@@ -996,12 +1053,12 @@ function ve() {
|
|
|
996
1053
|
o == null || o.querySelectorAll(".simulator-segmented-btn").forEach((t) => {
|
|
997
1054
|
t.addEventListener("click", () => {
|
|
998
1055
|
let n = t.dataset.previewKind;
|
|
999
|
-
!n || n === e.state.previewKind || (e.state.previewKind = n,
|
|
1056
|
+
!n || n === e.state.previewKind || (e.state.previewKind = n, w(n), c(), s(), e.updateThumbnail());
|
|
1000
1057
|
});
|
|
1001
|
-
}), n && (e.state.renderHost || (e.state.renderHost = "game",
|
|
1002
|
-
e.state.renderHost = n.value,
|
|
1003
|
-
})), r && (e.state.renderContext || (e.state.renderContext = "preview",
|
|
1004
|
-
e.state.renderContext = r.value,
|
|
1058
|
+
}), n && (e.state.renderHost || (e.state.renderHost = "game", C(e.state.renderHost)), n.value = e.state.renderHost || "game", n.addEventListener("change", () => {
|
|
1059
|
+
e.state.renderHost = n.value, C(e.state.renderHost), s(), e.updateThumbnail();
|
|
1060
|
+
})), r && (e.state.renderContext || (e.state.renderContext = "preview", T(e.state.renderContext)), r.value = e.state.renderContext || "preview", r.addEventListener("change", () => {
|
|
1061
|
+
e.state.renderContext = r.value, T(e.state.renderContext), e.updateThumbnail();
|
|
1005
1062
|
})), c(), s();
|
|
1006
1063
|
},
|
|
1007
1064
|
onActivate(e) {
|
|
@@ -1010,26 +1067,26 @@ function ve() {
|
|
|
1010
1067
|
updatePreview: (e) => {
|
|
1011
1068
|
let t = e.getElement("#simulator-thumb-preview"), n = e.getElement("#simulator-thumb-fn");
|
|
1012
1069
|
if (t == null || t.style.setProperty("--sim-thumb-bg", e.state.selectedTheme.g_bg), e.state.previewKind === "text") {
|
|
1013
|
-
let s =
|
|
1070
|
+
let s = be();
|
|
1014
1071
|
if (!s) {
|
|
1015
|
-
t && (t.innerHTML =
|
|
1072
|
+
t && (t.innerHTML = we), n && (n.textContent = "");
|
|
1016
1073
|
return;
|
|
1017
1074
|
}
|
|
1018
1075
|
n && (n.textContent = "Using: getShareString()");
|
|
1019
1076
|
try {
|
|
1020
1077
|
var r, i, a, o;
|
|
1021
|
-
let n = (r = e.gameSlug) == null ? "game" : r, c = s((i = e.state.currentInputStr) == null ? "" : i,
|
|
1078
|
+
let n = (r = e.gameSlug) == null ? "game" : r, c = s((i = e.state.currentInputStr) == null ? "" : i, Ce(n), {
|
|
1022
1079
|
puzzleString: (a = e.state.puzzleData) == null ? "" : a,
|
|
1023
|
-
dateKey:
|
|
1080
|
+
dateKey: Se(),
|
|
1024
1081
|
gameplaySlug: `simulator:${n}`
|
|
1025
1082
|
}), l = (o = c == null ? void 0 : c.str) == null ? "" : o;
|
|
1026
|
-
t && (t.innerHTML = `<pre class="simulator-share-preview" style="color: ${e.state.selectedTheme.fg}">${
|
|
1083
|
+
t && (t.innerHTML = `<pre class="simulator-share-preview" style="color: ${e.state.selectedTheme.fg}">${xe(l)}</pre>`);
|
|
1027
1084
|
} catch (e) {
|
|
1028
1085
|
console.error("Simulator: Share string error", e), t && (t.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
|
|
1029
1086
|
}
|
|
1030
1087
|
return;
|
|
1031
1088
|
}
|
|
1032
|
-
let s =
|
|
1089
|
+
let s = ye();
|
|
1033
1090
|
if (!s) {
|
|
1034
1091
|
t && (t.innerHTML = "<span class=\"simulator-empty\">No thumbnail function found</span>"), n && (n.textContent = "");
|
|
1035
1092
|
return;
|
|
@@ -1043,7 +1100,7 @@ function ve() {
|
|
|
1043
1100
|
strict: !0,
|
|
1044
1101
|
renderHost: e.state.renderHost,
|
|
1045
1102
|
renderContext: e.state.renderContext
|
|
1046
|
-
}, { svg: i } =
|
|
1103
|
+
}, { svg: i } = k(s.fn(n, e.state.currentInputStr, r));
|
|
1047
1104
|
t && (t.innerHTML = i);
|
|
1048
1105
|
} catch (e) {
|
|
1049
1106
|
console.error("Simulator: Thumbnail error", e), t && (t.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
|
|
@@ -1052,7 +1109,7 @@ function ve() {
|
|
|
1052
1109
|
};
|
|
1053
1110
|
}
|
|
1054
1111
|
/** Generate theme preview HTML showing key colors */
|
|
1055
|
-
function
|
|
1112
|
+
function Ee(e) {
|
|
1056
1113
|
let t = [
|
|
1057
1114
|
e.key,
|
|
1058
1115
|
e.subBrand,
|
|
@@ -1063,7 +1120,7 @@ function ye(e) {
|
|
|
1063
1120
|
].map((e) => `<div class="simulator-theme-preview-cell" style="background: ${e}"></div>`).join("");
|
|
1064
1121
|
return `<div class="simulator-theme-preview" style="background: ${e.g_bg}">${t}</div>`;
|
|
1065
1122
|
}
|
|
1066
|
-
function
|
|
1123
|
+
function De() {
|
|
1067
1124
|
return {
|
|
1068
1125
|
id: "theme",
|
|
1069
1126
|
label: "Theme",
|
|
@@ -1075,17 +1132,17 @@ function be() {
|
|
|
1075
1132
|
t && n.forEach((n) => {
|
|
1076
1133
|
let r = document.createElement("div");
|
|
1077
1134
|
r.className = `simulator-theme-item${n.name === e.state.selectedTheme.name ? " selected" : ""}`, r.innerHTML = `
|
|
1078
|
-
${
|
|
1135
|
+
${Ee(n)}
|
|
1079
1136
|
<div class="simulator-theme-name">${n.name}</div>
|
|
1080
1137
|
<div class="simulator-theme-type">${n.type}</div>
|
|
1081
1138
|
`, r.addEventListener("click", () => {
|
|
1082
|
-
console.log("Simulator: Theme changed, reloading...", n.name),
|
|
1139
|
+
console.log("Simulator: Theme changed, reloading...", n.name), ae(n.name), window.location.reload();
|
|
1083
1140
|
}), t.appendChild(r);
|
|
1084
1141
|
});
|
|
1085
1142
|
}
|
|
1086
1143
|
};
|
|
1087
1144
|
}
|
|
1088
|
-
var
|
|
1145
|
+
var Oe = [
|
|
1089
1146
|
{
|
|
1090
1147
|
name: "app (desktop)",
|
|
1091
1148
|
context: [{
|
|
@@ -1132,8 +1189,8 @@ var xe = [
|
|
|
1132
1189
|
* The bootstrap is only read at game boot, so applying a change persists it to localStorage and
|
|
1133
1190
|
* restarts (reloads) the page — the same flow as the Theme tab.
|
|
1134
1191
|
*/
|
|
1135
|
-
function
|
|
1136
|
-
let t = [...
|
|
1192
|
+
function ke(e = []) {
|
|
1193
|
+
let t = [...Oe, ...e];
|
|
1137
1194
|
return {
|
|
1138
1195
|
id: "host",
|
|
1139
1196
|
label: "Host",
|
|
@@ -1150,7 +1207,7 @@ function Se(e = []) {
|
|
|
1150
1207
|
<div class="host-note" id="host-source"></div>
|
|
1151
1208
|
<select class="simulator-select" id="host-presets">
|
|
1152
1209
|
<option value="">Preset…</option>
|
|
1153
|
-
${t.map((e, t) => `<option value="${t}">${
|
|
1210
|
+
${t.map((e, t) => `<option value="${t}">${Ae(e.name)}</option>`).join("")}
|
|
1154
1211
|
</select>
|
|
1155
1212
|
<textarea class="simulator-textarea" id="host-json" spellcheck="false"></textarea>
|
|
1156
1213
|
<div class="host-actions">
|
|
@@ -1163,36 +1220,36 @@ function Se(e = []) {
|
|
|
1163
1220
|
},
|
|
1164
1221
|
bind(e) {
|
|
1165
1222
|
var n, r;
|
|
1166
|
-
let i = e.getElement("#host-json"),
|
|
1167
|
-
!i || !
|
|
1168
|
-
let e = t[Number(
|
|
1223
|
+
let i = e.getElement("#host-json"), a = e.getElement("#host-presets"), o = e.getElement("#host-error"), s = e.getElement("#host-source");
|
|
1224
|
+
!i || !a || !o || !s || (i.value = JSON.stringify(e.state.hostContext, null, 2), s.textContent = e.state.hostContextIsOverridden ? "Using this tab's override. Changes apply on restart." : "Using the vite config / default context. Changes apply on restart.", a.addEventListener("change", () => {
|
|
1225
|
+
let e = t[Number(a.value)];
|
|
1169
1226
|
e && (i.value = JSON.stringify(e.context, null, 2));
|
|
1170
1227
|
}), (n = e.getElement("#host-apply")) == null || n.addEventListener("click", () => {
|
|
1171
1228
|
let e;
|
|
1172
1229
|
try {
|
|
1173
1230
|
e = JSON.parse(i.value);
|
|
1174
1231
|
} catch (e) {
|
|
1175
|
-
|
|
1232
|
+
o.textContent = `Invalid JSON: ${e.message}`;
|
|
1176
1233
|
return;
|
|
1177
1234
|
}
|
|
1178
1235
|
if (!Array.isArray(e) || !e.every((e) => e && typeof e == "object" && typeof e.type == "string")) {
|
|
1179
|
-
|
|
1236
|
+
o.textContent = "hostContext must be an array of { type: string, ... } objects";
|
|
1180
1237
|
return;
|
|
1181
1238
|
}
|
|
1182
|
-
console.log("Simulator: hostContext changed, reloading...", e),
|
|
1239
|
+
console.log("Simulator: hostContext changed, reloading...", e), d(e), window.location.reload();
|
|
1183
1240
|
}), (r = e.getElement("#host-reset")) == null || r.addEventListener("click", () => {
|
|
1184
|
-
|
|
1241
|
+
f(), window.location.reload();
|
|
1185
1242
|
}));
|
|
1186
1243
|
}
|
|
1187
1244
|
};
|
|
1188
1245
|
}
|
|
1189
1246
|
/** Minimal HTML-escape so preset names can't break the simulator markup. */
|
|
1190
|
-
function
|
|
1247
|
+
function Ae(e) {
|
|
1191
1248
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
1192
1249
|
}
|
|
1193
|
-
var
|
|
1194
|
-
localStorage.setItem(
|
|
1195
|
-
}, V = null,
|
|
1250
|
+
var je = "puzzmo_sim_api_mode", z = "http://localhost:8911", Me = "https://api.puzzmo.com", B = () => localStorage.getItem(je) === "dev" ? "dev" : "prod", Ne = (e) => {
|
|
1251
|
+
localStorage.setItem(je, e);
|
|
1252
|
+
}, V = null, Pe = function() {
|
|
1196
1253
|
var e = t(function* () {
|
|
1197
1254
|
if (V !== null) return V;
|
|
1198
1255
|
try {
|
|
@@ -1206,23 +1263,23 @@ var we = "puzzmo_sim_api_mode", z = "http://localhost:8911", Te = "https://api.p
|
|
|
1206
1263
|
return e.apply(this, arguments);
|
|
1207
1264
|
};
|
|
1208
1265
|
}(), H = () => ({
|
|
1209
|
-
apiURL: B() === "dev" ? z :
|
|
1266
|
+
apiURL: B() === "dev" ? z : Me,
|
|
1210
1267
|
clientID: "protosdk:oauthclient",
|
|
1211
1268
|
redirectUri: `${window.location.origin}/oauth/callback`
|
|
1212
|
-
}),
|
|
1269
|
+
}), Fe = () => {
|
|
1213
1270
|
let e = new Uint8Array(32);
|
|
1214
1271
|
return crypto.getRandomValues(e), Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
1215
|
-
}, U = "puzzmo_sim_oauth_token", W = "puzzmo_sim_oauth_refresh_token",
|
|
1272
|
+
}, U = "puzzmo_sim_oauth_token", W = "puzzmo_sim_oauth_refresh_token", Ie = (e) => localStorage.setItem(U, e), Le = (e) => localStorage.setItem(W, e), G = () => {
|
|
1216
1273
|
let e = localStorage.getItem(U);
|
|
1217
1274
|
return e && `${e.substring(0, 20)}`, e;
|
|
1218
1275
|
}, K = () => localStorage.getItem(W), q = () => {
|
|
1219
1276
|
localStorage.removeItem(U), localStorage.removeItem(W);
|
|
1220
|
-
},
|
|
1221
|
-
let e = H(), t =
|
|
1277
|
+
}, Re = () => {
|
|
1278
|
+
let e = H(), t = Fe();
|
|
1222
1279
|
sessionStorage.setItem("oauth_state", t), sessionStorage.setItem("oauth_return_url", window.location.href);
|
|
1223
1280
|
let n = new URL(`${e.apiURL}/oauth/auth`);
|
|
1224
1281
|
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();
|
|
1225
|
-
},
|
|
1282
|
+
}, ze = (e) => {
|
|
1226
1283
|
try {
|
|
1227
1284
|
let t = e.split(".");
|
|
1228
1285
|
if (t.length !== 3) return !0;
|
|
@@ -1231,7 +1288,7 @@ var we = "puzzmo_sim_api_mode", z = "http://localhost:8911", Te = "https://api.p
|
|
|
1231
1288
|
} catch (e) {
|
|
1232
1289
|
return !0;
|
|
1233
1290
|
}
|
|
1234
|
-
},
|
|
1291
|
+
}, Be = function() {
|
|
1235
1292
|
var e = t(function* () {
|
|
1236
1293
|
let e = K();
|
|
1237
1294
|
if (!e) return !1;
|
|
@@ -1249,9 +1306,9 @@ var we = "puzzmo_sim_api_mode", z = "http://localhost:8911", Te = "https://api.p
|
|
|
1249
1306
|
if (!r.ok) return r.statusText, !1;
|
|
1250
1307
|
let i = yield r.json(), a = i.access_token || i.accessToken;
|
|
1251
1308
|
if (!a) return !1;
|
|
1252
|
-
|
|
1309
|
+
Ie(a);
|
|
1253
1310
|
let o = i.refresh_token || i.refreshToken;
|
|
1254
|
-
return o &&
|
|
1311
|
+
return o && Le(o), !0;
|
|
1255
1312
|
} catch (e) {
|
|
1256
1313
|
return !1;
|
|
1257
1314
|
}
|
|
@@ -1259,7 +1316,7 @@ var we = "puzzmo_sim_api_mode", z = "http://localhost:8911", Te = "https://api.p
|
|
|
1259
1316
|
return function() {
|
|
1260
1317
|
return e.apply(this, arguments);
|
|
1261
1318
|
};
|
|
1262
|
-
}(),
|
|
1319
|
+
}(), Ve = function() {
|
|
1263
1320
|
var e = t(function* (e, t) {
|
|
1264
1321
|
let n = H(), r = sessionStorage.getItem("oauth_state");
|
|
1265
1322
|
if (!r || r !== t) return null;
|
|
@@ -1283,11 +1340,11 @@ var we = "puzzmo_sim_api_mode", z = "http://localhost:8911", Te = "https://api.p
|
|
|
1283
1340
|
return function(t, n) {
|
|
1284
1341
|
return e.apply(this, arguments);
|
|
1285
1342
|
};
|
|
1286
|
-
}(),
|
|
1343
|
+
}(), He = function() {
|
|
1287
1344
|
var e = t(function* (e, t = {}) {
|
|
1288
1345
|
let n = H(), r = G();
|
|
1289
1346
|
if (!r) throw Error("Not authenticated");
|
|
1290
|
-
if (
|
|
1347
|
+
if (ze(r)) if (yield Be()) {
|
|
1291
1348
|
if (r = G(), !r) throw Error("Token refresh succeeded but no token available");
|
|
1292
1349
|
} else throw q(), Error("Session expired. Please log in again.");
|
|
1293
1350
|
let i = yield fetch(`${n.apiURL}/graphql`, {
|
|
@@ -1308,7 +1365,7 @@ var we = "puzzmo_sim_api_mode", z = "http://localhost:8911", Te = "https://api.p
|
|
|
1308
1365
|
return function(t) {
|
|
1309
1366
|
return e.apply(this, arguments);
|
|
1310
1367
|
};
|
|
1311
|
-
}(),
|
|
1368
|
+
}(), Ue = (e) => {
|
|
1312
1369
|
try {
|
|
1313
1370
|
let t = e.split(".");
|
|
1314
1371
|
return t.length, t.length === 3 ? JSON.parse(atob(t[1])) : null;
|
|
@@ -1316,15 +1373,15 @@ var we = "puzzmo_sim_api_mode", z = "http://localhost:8911", Te = "https://api.p
|
|
|
1316
1373
|
return null;
|
|
1317
1374
|
}
|
|
1318
1375
|
};
|
|
1319
|
-
function
|
|
1376
|
+
function We() {
|
|
1320
1377
|
let e = !1;
|
|
1321
1378
|
return {
|
|
1322
1379
|
id: "auth",
|
|
1323
1380
|
label: "Auth",
|
|
1324
1381
|
render() {
|
|
1325
|
-
let e = G(), t = !!e, n = B(), r = n === "dev" ? z :
|
|
1382
|
+
let e = G(), t = !!e, n = B(), r = n === "dev" ? z : Me, i = `<button class="simulator-btn tiny" id="auth-dev-toggle" style="display: none;">${n === "dev" ? "Using Dev" : "Dev"}</button>`;
|
|
1326
1383
|
if (t) {
|
|
1327
|
-
let t =
|
|
1384
|
+
let t = Ue(e), n = t != null && t.exp ? (/* @__PURE__ */ new Date(t.exp * 1e3)).toLocaleString() : "Unknown", a = !!K(), o = a ? Ue(K()) : null, s = o != null && o.exp ? (/* @__PURE__ */ new Date(o.exp * 1e3)).toLocaleString() : null;
|
|
1328
1385
|
return `
|
|
1329
1386
|
<div class="simulator-section">
|
|
1330
1387
|
<div class="simulator-section-title auth-title-row">
|
|
@@ -1376,21 +1433,21 @@ function Le() {
|
|
|
1376
1433
|
},
|
|
1377
1434
|
bind(n) {
|
|
1378
1435
|
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");
|
|
1379
|
-
e ? V && c && (c.style.display = "", B() === "dev" && c.classList.add("active")) : (e = !0,
|
|
1436
|
+
e ? V && c && (c.style.display = "", B() === "dev" && c.classList.add("active")) : (e = !0, Pe().then((e) => {
|
|
1380
1437
|
e && c && (c.style.display = "", B() === "dev" && c.classList.add("active"));
|
|
1381
1438
|
})), c == null || c.addEventListener("click", () => {
|
|
1382
|
-
|
|
1439
|
+
Ne(B() === "dev" ? "prod" : "dev"), q(), window.location.reload();
|
|
1383
1440
|
}), r == null || r.addEventListener("click", () => {
|
|
1384
|
-
|
|
1441
|
+
Re();
|
|
1385
1442
|
}), i == null || i.addEventListener("click", () => {
|
|
1386
1443
|
q(), window.location.reload();
|
|
1387
1444
|
}), a == null || a.addEventListener("click", t(function* () {
|
|
1388
|
-
a.disabled = !0, a.textContent = "Refreshing...", (yield
|
|
1445
|
+
a.disabled = !0, a.textContent = "Refreshing...", (yield Be()) ? window.location.reload() : (a.textContent = "Refresh Failed", a.disabled = !1);
|
|
1389
1446
|
})), o == null || o.addEventListener("click", t(function* () {
|
|
1390
1447
|
if (s) {
|
|
1391
1448
|
s.innerHTML = "<div class=\"loading\">Loading...</div>";
|
|
1392
1449
|
try {
|
|
1393
|
-
let t = yield
|
|
1450
|
+
let t = yield He("\n query {\n currentUser {\n id\n username\n usernameID\n name\n }\n }\n ");
|
|
1394
1451
|
if (t.errors) {
|
|
1395
1452
|
var e;
|
|
1396
1453
|
s.innerHTML = `<div class="error">Error: ${((e = t.errors[0]) == null ? void 0 : e.message) || "Unknown error"}</div>`;
|
|
@@ -1412,13 +1469,13 @@ function Le() {
|
|
|
1412
1469
|
if (n && r) {
|
|
1413
1470
|
let t = e.getElement("#auth-status");
|
|
1414
1471
|
t && (t.innerHTML = "<span class=\"indicator waiting\"></span><span>Exchanging code...</span>");
|
|
1415
|
-
let i = yield
|
|
1472
|
+
let i = yield Ve(n, r);
|
|
1416
1473
|
if (window.history.replaceState({}, "", window.location.pathname), i) {
|
|
1417
1474
|
let e = i.access_token || i.accessToken;
|
|
1418
1475
|
if (e) {
|
|
1419
|
-
|
|
1476
|
+
Ie(e);
|
|
1420
1477
|
let t = i.refresh_token || i.refreshToken;
|
|
1421
|
-
t &&
|
|
1478
|
+
t && Le(t);
|
|
1422
1479
|
}
|
|
1423
1480
|
window.location.reload();
|
|
1424
1481
|
} else {
|
|
@@ -1430,9 +1487,9 @@ function Le() {
|
|
|
1430
1487
|
}
|
|
1431
1488
|
};
|
|
1432
1489
|
}
|
|
1433
|
-
var
|
|
1490
|
+
var Ge = "puzzmo_sim_api_mode", Ke = "http://localhost:8911", qe = "https://api.puzzmo.com", J = "puzzmo_sim_oauth_token", Y = "puzzmo_sim_oauth_refresh_token", Je = () => localStorage.getItem(Ge) === "dev" ? "dev" : "prod", X = () => localStorage.getItem(J), Ye = () => localStorage.getItem(Y), Xe = (e) => localStorage.setItem(J, e), Ze = (e) => localStorage.setItem(Y, e), Qe = () => {
|
|
1434
1491
|
localStorage.removeItem(J), localStorage.removeItem(Y);
|
|
1435
|
-
},
|
|
1492
|
+
}, $e = (e) => {
|
|
1436
1493
|
try {
|
|
1437
1494
|
let t = e.split(".");
|
|
1438
1495
|
if (t.length !== 3) return !0;
|
|
@@ -1441,11 +1498,11 @@ var Re = "puzzmo_sim_api_mode", ze = "http://localhost:8911", Be = "https://api.
|
|
|
1441
1498
|
} catch (e) {
|
|
1442
1499
|
return !0;
|
|
1443
1500
|
}
|
|
1444
|
-
},
|
|
1501
|
+
}, et = function() {
|
|
1445
1502
|
var e = t(function* () {
|
|
1446
|
-
let e =
|
|
1503
|
+
let e = Ye();
|
|
1447
1504
|
if (!e) return !1;
|
|
1448
|
-
let t =
|
|
1505
|
+
let t = Je() === "dev" ? Ke : qe;
|
|
1449
1506
|
try {
|
|
1450
1507
|
let n = new URLSearchParams({
|
|
1451
1508
|
grant_type: "refresh_token",
|
|
@@ -1459,9 +1516,9 @@ var Re = "puzzmo_sim_api_mode", ze = "http://localhost:8911", Be = "https://api.
|
|
|
1459
1516
|
if (!r.ok) return !1;
|
|
1460
1517
|
let i = yield r.json(), a = i.access_token || i.accessToken;
|
|
1461
1518
|
if (!a) return !1;
|
|
1462
|
-
|
|
1519
|
+
Xe(a);
|
|
1463
1520
|
let o = i.refresh_token || i.refreshToken;
|
|
1464
|
-
return o &&
|
|
1521
|
+
return o && Ze(o), !0;
|
|
1465
1522
|
} catch (e) {
|
|
1466
1523
|
return !1;
|
|
1467
1524
|
}
|
|
@@ -1469,13 +1526,13 @@ var Re = "puzzmo_sim_api_mode", ze = "http://localhost:8911", Be = "https://api.
|
|
|
1469
1526
|
return function() {
|
|
1470
1527
|
return e.apply(this, arguments);
|
|
1471
1528
|
};
|
|
1472
|
-
}(),
|
|
1529
|
+
}(), tt = function() {
|
|
1473
1530
|
var e = t(function* (e, t = {}) {
|
|
1474
|
-
let n =
|
|
1531
|
+
let n = Je() === "dev" ? Ke : qe, r = X();
|
|
1475
1532
|
if (!r) throw Error("Not authenticated");
|
|
1476
|
-
if (
|
|
1533
|
+
if ($e(r)) if (yield et()) {
|
|
1477
1534
|
if (r = X(), !r) throw Error("Token refresh succeeded but no token available");
|
|
1478
|
-
} else throw
|
|
1535
|
+
} else throw Qe(), Error("Session expired. Please log in again.");
|
|
1479
1536
|
let i = yield fetch(`${n}/graphql`, {
|
|
1480
1537
|
method: "POST",
|
|
1481
1538
|
headers: {
|
|
@@ -1494,19 +1551,19 @@ var Re = "puzzmo_sim_api_mode", ze = "http://localhost:8911", Be = "https://api.
|
|
|
1494
1551
|
return function(t) {
|
|
1495
1552
|
return e.apply(this, arguments);
|
|
1496
1553
|
};
|
|
1497
|
-
}(),
|
|
1554
|
+
}(), nt = "\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", rt = "\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", it = (e, t) => {
|
|
1498
1555
|
let n = t - 1, r = Math.floor(n / 31), i = n % 31, a = [...e];
|
|
1499
1556
|
for (; a.length <= r;) a.push(0);
|
|
1500
1557
|
return a[r] = a[r] ^ 1 << i, a;
|
|
1501
1558
|
};
|
|
1502
|
-
const
|
|
1503
|
-
function
|
|
1559
|
+
const at = () => !!X();
|
|
1560
|
+
function ot() {
|
|
1504
1561
|
let n = null, r = !1, i = null, a = function() {
|
|
1505
1562
|
var e = t(function* (e) {
|
|
1506
1563
|
r = !0, i = null;
|
|
1507
1564
|
try {
|
|
1508
1565
|
var t;
|
|
1509
|
-
let r = yield
|
|
1566
|
+
let r = yield tt(nt, { slug: e });
|
|
1510
1567
|
if (r.errors) {
|
|
1511
1568
|
var a;
|
|
1512
1569
|
i = ((a = r.errors[0]) == null ? void 0 : a.message) || "Unknown error", n = null;
|
|
@@ -1523,10 +1580,10 @@ function $e() {
|
|
|
1523
1580
|
}(), o = function() {
|
|
1524
1581
|
var r = t(function* (t) {
|
|
1525
1582
|
if (!n) return;
|
|
1526
|
-
let r =
|
|
1583
|
+
let r = it(n.featuresArr, t);
|
|
1527
1584
|
try {
|
|
1528
1585
|
var i;
|
|
1529
|
-
let t = yield
|
|
1586
|
+
let t = yield tt(rt, {
|
|
1530
1587
|
gameSlug: n.slug,
|
|
1531
1588
|
input: { featuresArr: r }
|
|
1532
1589
|
});
|
|
@@ -1574,7 +1631,7 @@ function $e() {
|
|
|
1574
1631
|
id: "features",
|
|
1575
1632
|
label: "Features",
|
|
1576
1633
|
render() {
|
|
1577
|
-
return
|
|
1634
|
+
return at() ? `
|
|
1578
1635
|
<div class="features-view-container">
|
|
1579
1636
|
<div class="simulator-section">
|
|
1580
1637
|
<div class="simulator-section-title">Game Features</div>
|
|
@@ -1615,7 +1672,7 @@ function $e() {
|
|
|
1615
1672
|
e && (yield d(e));
|
|
1616
1673
|
})), i == null || i.addEventListener("keypress", (e) => {
|
|
1617
1674
|
e.key === "Enter" && (r == null || r.click());
|
|
1618
|
-
}), console.log("[FeaturesView] bind called, ctx.gameSlug:", e.gameSlug, "slugInput:", i), e.gameSlug && i && (i.value = e.gameSlug,
|
|
1675
|
+
}), console.log("[FeaturesView] bind called, ctx.gameSlug:", e.gameSlug, "slugInput:", i), e.gameSlug && i && (i.value = e.gameSlug, at() && !n && d(e.gameSlug)), u();
|
|
1619
1676
|
},
|
|
1620
1677
|
onActivate(e) {
|
|
1621
1678
|
let t = e.getElement("#simulator-tab-features");
|
|
@@ -1624,7 +1681,7 @@ function $e() {
|
|
|
1624
1681
|
};
|
|
1625
1682
|
}
|
|
1626
1683
|
/** Renders a single keyboard key as an HTML button string */
|
|
1627
|
-
var
|
|
1684
|
+
var st = (e, t) => {
|
|
1628
1685
|
var n, r;
|
|
1629
1686
|
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);
|
|
1630
1687
|
return `<button class="${[
|
|
@@ -1635,9 +1692,9 @@ var et = (e, t) => {
|
|
|
1635
1692
|
c ? "l" : "",
|
|
1636
1693
|
l ? "grow" : ""
|
|
1637
1694
|
].filter(Boolean).join(" ")}" data-key="${e}" ${a ? "disabled" : ""}>${i}</button>`;
|
|
1638
|
-
},
|
|
1639
|
-
function
|
|
1640
|
-
let e = null, t = () => e ?
|
|
1695
|
+
}, ct = (e) => `<div class="sim-kb">${e.layout.filter((e) => e != null).map((t) => `<div class="sim-kb-row">${[...t].map((t) => st(t, e)).join("")}</div>`).join("")}</div>`;
|
|
1696
|
+
function lt() {
|
|
1697
|
+
let e = null, t = () => e ? ct(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>";
|
|
1641
1698
|
return {
|
|
1642
1699
|
id: "kbd",
|
|
1643
1700
|
label: "Kbd",
|
|
@@ -1651,19 +1708,19 @@ function nt() {
|
|
|
1651
1708
|
`;
|
|
1652
1709
|
},
|
|
1653
1710
|
bind(e) {
|
|
1654
|
-
|
|
1711
|
+
ut(e);
|
|
1655
1712
|
},
|
|
1656
1713
|
onMessage(n, r, i) {
|
|
1657
1714
|
var a;
|
|
1658
1715
|
if (n !== "KEYBOARD_UPDATE_CONFIG") return;
|
|
1659
1716
|
e = !(!(r == null || (a = r.layout) == null) && a.length) || r.layout.every((e) => !e) ? null : r;
|
|
1660
1717
|
let o = i.getElement("#sim-kb-content");
|
|
1661
|
-
o && (o.innerHTML = t(),
|
|
1718
|
+
o && (o.innerHTML = t(), ut(i)), i.updateBadge("kbd", void 0);
|
|
1662
1719
|
}
|
|
1663
1720
|
};
|
|
1664
1721
|
}
|
|
1665
1722
|
/** Attach click handlers to all rendered keys */
|
|
1666
|
-
function
|
|
1723
|
+
function ut(e) {
|
|
1667
1724
|
var t;
|
|
1668
1725
|
let n = (t = e.getElement("#sim-kb-content")) == null ? void 0 : t.querySelectorAll(".sim-kb-key");
|
|
1669
1726
|
n == null || n.forEach((t) => {
|
|
@@ -1678,15 +1735,15 @@ function rt(e) {
|
|
|
1678
1735
|
* change values (persisted to localStorage and pushed to the game as SETTINGS_UPDATE, matching the
|
|
1679
1736
|
* production host) and reflects UPDATE_SETTINGS_FROM_EMBED writes coming from the game.
|
|
1680
1737
|
*/
|
|
1681
|
-
function
|
|
1738
|
+
function dt() {
|
|
1682
1739
|
let t = (e) => {
|
|
1683
1740
|
let t = e.state.settingsComponents;
|
|
1684
|
-
return !t || t.length === 0 ? "<div class=\"sim-settings-empty\">No settings registered by the game yet.<br>The game calls <code>sdk.settings.initialize(components)</code> to describe its settings UI.</div>" : `<div class="sim-settings-form">${t.map((t) =>
|
|
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) => ft(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>`;
|
|
1685
1742
|
}, n = (e) => {
|
|
1686
1743
|
let n = e.getElement("#sim-settings-content");
|
|
1687
1744
|
n && (n.innerHTML = t(e), i(e));
|
|
1688
1745
|
}, r = (e) => {
|
|
1689
|
-
|
|
1746
|
+
v(e.state.gameSettings), e.sendToGame("SETTINGS_UPDATE", e.state.gameSettings);
|
|
1690
1747
|
}, i = (t) => {
|
|
1691
1748
|
var i;
|
|
1692
1749
|
let a = t.getElement("#sim-settings-content");
|
|
@@ -1702,7 +1759,7 @@ function it() {
|
|
|
1702
1759
|
});
|
|
1703
1760
|
}), (i = a.querySelector("#sim-settings-reset")) == null || i.addEventListener("click", () => {
|
|
1704
1761
|
var e;
|
|
1705
|
-
|
|
1762
|
+
y(), t.state.gameSettings = pt((e = t.state.settingsComponents) == null ? [] : e), r(t), n(t);
|
|
1706
1763
|
}));
|
|
1707
1764
|
};
|
|
1708
1765
|
return {
|
|
@@ -1717,21 +1774,21 @@ function it() {
|
|
|
1717
1774
|
onMessage(t, r, i) {
|
|
1718
1775
|
if (t === "INITIALIZE_SETTINGS") {
|
|
1719
1776
|
var a;
|
|
1720
|
-
i.state.settingsComponents = (a = r == null ? void 0 : r.components) == null ? [] : a, i.state.gameSettings = e(e({}, r == null ? void 0 : r.settings), i.state.gameSettings),
|
|
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), v(i.state.gameSettings), n(i);
|
|
1721
1778
|
return;
|
|
1722
1779
|
}
|
|
1723
|
-
t === "UPDATE_SETTINGS_FROM_EMBED" && (i.state.gameSettings = e(e({}, i.state.gameSettings), r == null ? void 0 : r.settings),
|
|
1780
|
+
t === "UPDATE_SETTINGS_FROM_EMBED" && (i.state.gameSettings = e(e({}, i.state.gameSettings), r == null ? void 0 : r.settings), v(i.state.gameSettings), n(i));
|
|
1724
1781
|
}
|
|
1725
1782
|
};
|
|
1726
1783
|
}
|
|
1727
1784
|
/** Renders a single settings UI component as HTML, reading its current value from `settings` */
|
|
1728
|
-
function
|
|
1785
|
+
function ft(e, t) {
|
|
1729
1786
|
switch (e.type) {
|
|
1730
1787
|
case "title": return `<div class="sim-settings-heading">${Q(e.value)}</div>`;
|
|
1731
1788
|
case "subtitle": return `<div class="sim-settings-subheading">${Q(e.value)}</div>`;
|
|
1732
1789
|
case "paragraph": return `<p class="sim-settings-paragraph">${Q(e.value)}</p>`;
|
|
1733
1790
|
case "separator": return "<div class=\"simulator-divider\"></div>";
|
|
1734
|
-
case "split": return `<div class="sim-settings-split">${e.content.map((e) =>
|
|
1791
|
+
case "split": return `<div class="sim-settings-split">${e.content.map((e) => ft(e, t)).join("")}</div>`;
|
|
1735
1792
|
case "boolean": {
|
|
1736
1793
|
var n;
|
|
1737
1794
|
let r = ((n = t[e.name]) == null ? e.defaultValue : n) ? "checked" : "", i = e.subtitle ? `<div class="sim-settings-subtitle">${Q(e.subtitle)}</div>` : "";
|
|
@@ -1799,9 +1856,9 @@ function Z(e) {
|
|
|
1799
1856
|
return `<span class="simulator-label">${Q(e.title)}</span>${t}`;
|
|
1800
1857
|
}
|
|
1801
1858
|
/** Collects name → defaultValue pairs from components, recursing into split groups */
|
|
1802
|
-
function
|
|
1859
|
+
function pt(e) {
|
|
1803
1860
|
let t = {};
|
|
1804
|
-
for (let n of e) n.type === "split" ? Object.assign(t,
|
|
1861
|
+
for (let n of e) n.type === "split" ? Object.assign(t, pt(n.content)) : "name" in n && (t[n.name] = n.defaultValue);
|
|
1805
1862
|
return t;
|
|
1806
1863
|
}
|
|
1807
1864
|
function Q(e) {
|
|
@@ -1809,11 +1866,11 @@ function Q(e) {
|
|
|
1809
1866
|
}
|
|
1810
1867
|
var $ = null;
|
|
1811
1868
|
/** True when the game is embedded in the real Puzzmo app, which sets `?developer=true` on the iframe. */
|
|
1812
|
-
function
|
|
1869
|
+
function mt() {
|
|
1813
1870
|
return typeof window > "u" ? !1 : new URLSearchParams(window.location.search).has("developer");
|
|
1814
1871
|
}
|
|
1815
1872
|
/** Inert instance returned when the simulator declines to boot (the app is the host). */
|
|
1816
|
-
var
|
|
1873
|
+
var ht = {
|
|
1817
1874
|
updateFixtures: () => {},
|
|
1818
1875
|
sendToGame: () => {},
|
|
1819
1876
|
loadPuzzle: function() {
|
|
@@ -1862,36 +1919,36 @@ var ct = {
|
|
|
1862
1919
|
* Fixtures are loaded as raw strings and passed to the game verbatim (any text format works; the game parses it).
|
|
1863
1920
|
* This will show dropdowns in the Ctrl tab to select category and puzzle.
|
|
1864
1921
|
*/
|
|
1865
|
-
function
|
|
1922
|
+
function gt(e = {}) {
|
|
1866
1923
|
var n, r, i;
|
|
1867
|
-
if (
|
|
1924
|
+
if (mt()) return console.log("[Simulator] developer=true in URL — running inside the Puzzmo app, skipping simulator boot"), ht;
|
|
1868
1925
|
if (console.log("[Simulator] createSimulator called with config:", {
|
|
1869
1926
|
slug: e.slug,
|
|
1870
1927
|
hasFixtures: !!e.fixtures
|
|
1871
1928
|
}), $) return e.fixtures && (console.log("[Simulator] Instance already exists, updating fixtures"), $.updateFixtures(e.fixtures)), $;
|
|
1872
|
-
let a = (n = e.autoStart) == null ? !0 : n, o = e.fixtures ?
|
|
1873
|
-
se(),
|
|
1874
|
-
ce(),
|
|
1875
|
-
c,
|
|
1929
|
+
let a = (n = e.autoStart) == null ? !0 : n, o = e.fixtures ? le(e.fixtures) : null, s = o ? Array.from(o.keys()).sort() : [], c = ge(), l = Te(), u = [
|
|
1876
1930
|
ue(),
|
|
1877
1931
|
de(),
|
|
1932
|
+
c,
|
|
1933
|
+
_e(),
|
|
1934
|
+
ve(),
|
|
1878
1935
|
l,
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1936
|
+
De(),
|
|
1937
|
+
ke(e.hostContextPresets),
|
|
1938
|
+
We(),
|
|
1939
|
+
ot(),
|
|
1940
|
+
lt(),
|
|
1941
|
+
dt(),
|
|
1885
1942
|
...(r = e.views) == null ? [] : r
|
|
1886
|
-
], d = u.map((e) => e.id), f =
|
|
1943
|
+
], d = u.map((e) => e.id), f = _(e, s, d), p = {
|
|
1887
1944
|
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>",
|
|
1888
1945
|
play: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><polygon points=\"2,1 9,5 2,9\"/></svg>",
|
|
1889
1946
|
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>",
|
|
1890
1947
|
cog: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><path d=\"M9.5 5.8l-.8-.5c0-.2.1-.5.1-.8s0-.5-.1-.8l.8-.5c.1-.1.2-.2.1-.4l-.8-1.4c-.1-.1-.2-.2-.4-.1l-1 .3c-.3-.3-.7-.5-1.1-.6L6.1.2C6.1.1 6 0 5.8 0H4.2c-.2 0-.3.1-.3.2l-.2 1c-.4.1-.7.3-1.1.6l-1-.3c-.2 0-.3 0-.4.1l-.8 1.4c-.1.2 0 .3.1.4l.8.5c0 .2-.1.5-.1.8s0 .5.1.8l-.8.5c-.1.1-.2.2-.1.4l.8 1.4c.1.1.2.2.4.1l1-.3c.3.3.7.5 1.1.6l.2 1c0 .1.1.2.3.2h1.6c.2 0 .3-.1.3-.2l.2-1c.4-.1.7-.3 1.1-.6l1 .3c.2 0 .3 0 .4-.1l.8-1.4c.1-.2 0-.3-.1-.4zM5 6.5c-.8 0-1.5-.7-1.5-1.5S4.2 3.5 5 3.5 6.5 4.2 6.5 5 5.8 6.5 5 6.5z\"/></svg>",
|
|
1891
1948
|
minimize: "<svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"currentColor\"><rect x=\"1\" y=\"4\" width=\"8\" height=\"2\"/></svg>",
|
|
1892
1949
|
expand: "<svg width=\"8\" height=\"8\" viewBox=\"0 0 8 8\" fill=\"currentColor\"><polygon points=\"1,1 7,4 1,7\"/></svg>"
|
|
1893
|
-
},
|
|
1894
|
-
|
|
1950
|
+
}, m = document.createElement("div");
|
|
1951
|
+
m.id = "simulator", m.innerHTML = `
|
|
1895
1952
|
<style>
|
|
1896
1953
|
:root {
|
|
1897
1954
|
--sim-bg: #1a1a2e;
|
|
@@ -2271,6 +2328,19 @@ function lt(e = {}) {
|
|
|
2271
2328
|
letter-spacing: 1px;
|
|
2272
2329
|
margin-bottom: 4px;
|
|
2273
2330
|
}
|
|
2331
|
+
.simulator-override-tag {
|
|
2332
|
+
display: inline-block;
|
|
2333
|
+
margin-left: 6px;
|
|
2334
|
+
padding: 0 4px;
|
|
2335
|
+
border-radius: 2px;
|
|
2336
|
+
background: var(--sim-accent);
|
|
2337
|
+
color: var(--sim-bg);
|
|
2338
|
+
font-size: 8px;
|
|
2339
|
+
letter-spacing: 0.5px;
|
|
2340
|
+
}
|
|
2341
|
+
.simulator-override-tag[hidden] {
|
|
2342
|
+
display: none;
|
|
2343
|
+
}
|
|
2274
2344
|
.simulator-textarea {
|
|
2275
2345
|
width: 100%;
|
|
2276
2346
|
min-height: 40px;
|
|
@@ -3224,30 +3294,31 @@ function lt(e = {}) {
|
|
|
3224
3294
|
</div>
|
|
3225
3295
|
</div>
|
|
3226
3296
|
</div>
|
|
3227
|
-
`, document.body.appendChild(
|
|
3228
|
-
let
|
|
3229
|
-
|
|
3230
|
-
},
|
|
3231
|
-
let n =
|
|
3232
|
-
n && (n.textContent = e), r && (r.className = `indicator ${t}`, r.textContent = i),
|
|
3233
|
-
},
|
|
3234
|
-
t && t !== "0" ?
|
|
3235
|
-
},
|
|
3297
|
+
`, document.body.appendChild(m);
|
|
3298
|
+
let ee = m.querySelector("#simulator-panel"), te = m.querySelector("#simulator-header"), h = m.querySelector("#simulator-header-indicator"), ne = m.querySelector("#simulator-header-status-text"), g = m.querySelector("#simulator-header-pause"), v = m.querySelector("#simulator-header-retry"), y = m.querySelector("#simulator-header-settings"), ae = m.querySelector("#simulator-toggle"), b = m.querySelector("#simulator-timer"), x = m.querySelector("#simulator-tabs"), S = m.querySelector("#simulator-content"), C = (e) => m.querySelector(e), w = (e) => {
|
|
3299
|
+
g.innerHTML = e ? p.play : p.pause, g.title = e ? "Resume" : "Pause";
|
|
3300
|
+
}, T = (e, t) => {
|
|
3301
|
+
let n = C("#simulator-status .text"), r = C("#simulator-status .indicator"), i = t === "complete" ? "✓" : "";
|
|
3302
|
+
n && (n.textContent = e), r && (r.className = `indicator ${t}`, r.textContent = i), h.className = t, h.textContent = i, ne.textContent = e;
|
|
3303
|
+
}, E = (e, t) => {
|
|
3304
|
+
t && t !== "0" ? b.innerHTML = `${e}<span class="penalty">+${t}</span>` : b.textContent = e;
|
|
3305
|
+
}, D = (e) => {
|
|
3236
3306
|
var t;
|
|
3237
|
-
f.activeTab = e,
|
|
3307
|
+
f.activeTab = e, S.classList.remove("hidden"), ie(e), x.querySelectorAll(".simulator-tab").forEach((t) => {
|
|
3238
3308
|
t.classList.toggle("active", t.getAttribute("data-tab") === e);
|
|
3239
|
-
}),
|
|
3309
|
+
}), m.querySelectorAll(".simulator-tab-content").forEach((t) => {
|
|
3240
3310
|
t.classList.toggle("active", t.id === `simulator-tab-${e}`);
|
|
3241
|
-
}),
|
|
3311
|
+
}), y.classList.toggle("active", e === "auth");
|
|
3242
3312
|
let n = u.find((t) => t.id === e);
|
|
3243
|
-
n == null || (t = n.onActivate) == null || t.call(n,
|
|
3244
|
-
},
|
|
3245
|
-
f.isCollapsed = e,
|
|
3246
|
-
},
|
|
3247
|
-
l.updatePreview(
|
|
3248
|
-
},
|
|
3313
|
+
n == null || (t = n.onActivate) == null || t.call(n, P);
|
|
3314
|
+
}, O = (e) => {
|
|
3315
|
+
f.isCollapsed = e, ee.classList.toggle("collapsed", e), re(e), e ? (S.classList.add("hidden"), x.querySelectorAll(".simulator-tab").forEach((e) => e.classList.remove("active"))) : D(f.activeTab);
|
|
3316
|
+
}, k = () => {
|
|
3317
|
+
l.updatePreview(P);
|
|
3318
|
+
}, A = function() {
|
|
3249
3319
|
var e = t(function* () {
|
|
3250
3320
|
var e, t;
|
|
3321
|
+
if (f.appliedPuzzleOverride !== null) return f.appliedPuzzleOverride;
|
|
3251
3322
|
if (f.puzzleData) return f.puzzleData;
|
|
3252
3323
|
if (!o || o.size === 0) throw Error("No fixtures configured. Add puzzle fixture files (.json or .toml) to a fixtures directory and pass fixturesGlob to the simulator.");
|
|
3253
3324
|
let n = (e = f.selectedCategory) == null ? s[0] : e, r = n ? o.get(n) : void 0;
|
|
@@ -3258,58 +3329,58 @@ function lt(e = {}) {
|
|
|
3258
3329
|
category: n,
|
|
3259
3330
|
puzzle: i
|
|
3260
3331
|
}), f.originalPuzzle = a;
|
|
3261
|
-
let c =
|
|
3262
|
-
return c && (c.value = f.originalPuzzle), f.activeTab === "thumb" &&
|
|
3332
|
+
let c = C("#simulator-puzzle");
|
|
3333
|
+
return c && (c.value = f.originalPuzzle), f.activeTab === "thumb" && k(), f.puzzleData;
|
|
3263
3334
|
});
|
|
3264
3335
|
return function() {
|
|
3265
3336
|
return e.apply(this, arguments);
|
|
3266
3337
|
};
|
|
3267
|
-
}(),
|
|
3268
|
-
c.addLogEntry(e,
|
|
3269
|
-
}),
|
|
3270
|
-
|
|
3271
|
-
},
|
|
3272
|
-
let n =
|
|
3338
|
+
}(), j = oe((e) => {
|
|
3339
|
+
c.addLogEntry(e, P);
|
|
3340
|
+
}), M = (e, t) => {
|
|
3341
|
+
se(e, t, j);
|
|
3342
|
+
}, N = (e, t) => {
|
|
3343
|
+
let n = m.querySelector(`[data-badge="${e}"]`);
|
|
3273
3344
|
n && (n.textContent = t && t > 0 ? String(t) : "");
|
|
3274
|
-
},
|
|
3345
|
+
}, P = {
|
|
3275
3346
|
state: f,
|
|
3276
|
-
getElement:
|
|
3277
|
-
sendToGame:
|
|
3278
|
-
logMessage:
|
|
3279
|
-
loadPuzzle:
|
|
3280
|
-
updateStatus:
|
|
3281
|
-
updateTimer:
|
|
3282
|
-
setCollapsed:
|
|
3283
|
-
switchTab:
|
|
3284
|
-
updateThumbnail:
|
|
3285
|
-
updateBadge:
|
|
3347
|
+
getElement: C,
|
|
3348
|
+
sendToGame: M,
|
|
3349
|
+
logMessage: j.log,
|
|
3350
|
+
loadPuzzle: A,
|
|
3351
|
+
updateStatus: T,
|
|
3352
|
+
updateTimer: E,
|
|
3353
|
+
setCollapsed: O,
|
|
3354
|
+
switchTab: D,
|
|
3355
|
+
updateThumbnail: k,
|
|
3356
|
+
updateBadge: N,
|
|
3286
3357
|
fixtures: o,
|
|
3287
3358
|
fixtureCategories: s,
|
|
3288
3359
|
gameSlug: (i = e.slug) == null ? null : i
|
|
3289
3360
|
};
|
|
3290
|
-
console.log("[Simulator] Context created with gameSlug:",
|
|
3361
|
+
console.log("[Simulator] Context created with gameSlug:", P.gameSlug), u.forEach((e) => e.bind(P)), x.querySelectorAll(".simulator-tab").forEach((e) => {
|
|
3291
3362
|
e.addEventListener("click", () => {
|
|
3292
3363
|
let t = e.getAttribute("data-tab");
|
|
3293
|
-
|
|
3364
|
+
D(t), N(t, 0);
|
|
3294
3365
|
});
|
|
3295
|
-
}),
|
|
3296
|
-
e.stopPropagation(),
|
|
3297
|
-
}),
|
|
3298
|
-
e.stopPropagation(), f.isPaused ? (
|
|
3299
|
-
let t =
|
|
3366
|
+
}), ae.addEventListener("click", (e) => {
|
|
3367
|
+
e.stopPropagation(), O(!0);
|
|
3368
|
+
}), g.addEventListener("click", (e) => {
|
|
3369
|
+
e.stopPropagation(), f.isPaused ? (M("RESUME_GAME", {}), f.isPaused = !1, w(!1), T("Running", "ready")) : (M("PAUSE_GAME", {}), f.isPaused = !0, w(!0), T("Paused", "paused"));
|
|
3370
|
+
let t = C("#simulator-pause");
|
|
3300
3371
|
t && (t.textContent = f.isPaused ? "Resume" : "Pause");
|
|
3301
|
-
}),
|
|
3302
|
-
e.stopPropagation(),
|
|
3303
|
-
let t =
|
|
3372
|
+
}), v.addEventListener("click", (e) => {
|
|
3373
|
+
e.stopPropagation(), M("RETRY_PUZZLE", {}), f.hasStarted = !1, f.isPaused = !1, w(!1), g.disabled = !0, T("Ready to retry", "ready");
|
|
3374
|
+
let t = C("#simulator-pause"), n = C("#simulator-start");
|
|
3304
3375
|
t && (t.disabled = !0, t.textContent = "Pause"), n && (n.textContent = "Start");
|
|
3305
|
-
}),
|
|
3306
|
-
e.stopPropagation(), f.isCollapsed &&
|
|
3376
|
+
}), y.addEventListener("click", (e) => {
|
|
3377
|
+
e.stopPropagation(), f.isCollapsed && O(!1), D("auth");
|
|
3307
3378
|
}), te.addEventListener("click", (e) => {
|
|
3308
|
-
f.isCollapsed && e.target !==
|
|
3309
|
-
}), f.isCollapsed ||
|
|
3310
|
-
let
|
|
3311
|
-
(
|
|
3312
|
-
let
|
|
3379
|
+
f.isCollapsed && e.target !== ae && O(!1);
|
|
3380
|
+
}), f.isCollapsed || D(f.activeTab);
|
|
3381
|
+
let F = new URLSearchParams(window.location.search);
|
|
3382
|
+
(F.has("code") || F.has("error")) && (O(!1), D("auth"));
|
|
3383
|
+
let I = (e) => ({
|
|
3313
3384
|
userState: {
|
|
3314
3385
|
gameSettings: { "proto-game": f.gameSettings },
|
|
3315
3386
|
id: "simulator-user",
|
|
@@ -3351,42 +3422,42 @@ function lt(e = {}) {
|
|
|
3351
3422
|
theme: f.selectedTheme,
|
|
3352
3423
|
hostContext: f.hostContext,
|
|
3353
3424
|
appRuntimeContract: "1.0"
|
|
3354
|
-
}),
|
|
3425
|
+
}), L = function() {
|
|
3355
3426
|
var e = t(function* () {
|
|
3356
|
-
|
|
3427
|
+
T("Loading puzzle...", "waiting");
|
|
3357
3428
|
try {
|
|
3358
|
-
let e =
|
|
3359
|
-
|
|
3429
|
+
let e = I(yield A());
|
|
3430
|
+
T("Sending READY_DATA...", "waiting"), M("READY_DATA", e), T("Waiting for game to load...", "waiting");
|
|
3360
3431
|
} catch (e) {
|
|
3361
|
-
|
|
3432
|
+
T(`Error: ${e}`, "paused");
|
|
3362
3433
|
}
|
|
3363
3434
|
});
|
|
3364
3435
|
return function() {
|
|
3365
3436
|
return e.apply(this, arguments);
|
|
3366
3437
|
};
|
|
3367
|
-
}(),
|
|
3368
|
-
console.log("Simulator: Game loaded, ready to start"),
|
|
3438
|
+
}(), R = () => {
|
|
3439
|
+
console.log("Simulator: Game loaded, ready to start"), v.disabled = !1, u.forEach((e) => {
|
|
3369
3440
|
var t;
|
|
3370
|
-
return (t = e.onMessage) == null ? void 0 : t.call(e, "READY_GAME_LOADED", void 0,
|
|
3441
|
+
return (t = e.onMessage) == null ? void 0 : t.call(e, "READY_GAME_LOADED", void 0, P);
|
|
3371
3442
|
}), a && !f.hasStarted && setTimeout(() => {
|
|
3372
|
-
let e =
|
|
3373
|
-
e == null || e.click(),
|
|
3443
|
+
let e = C("#simulator-start");
|
|
3444
|
+
e == null || e.click(), g.disabled = !1, f.hasStarted = !0, T("Running", "ready");
|
|
3374
3445
|
}, 100);
|
|
3375
3446
|
};
|
|
3376
|
-
return
|
|
3447
|
+
return ce((e, t) => {
|
|
3377
3448
|
var n, r;
|
|
3378
3449
|
if (e === "READY") {
|
|
3379
|
-
console.log("Simulator: Received READY from game"),
|
|
3450
|
+
console.log("Simulator: Received READY from game"), L();
|
|
3380
3451
|
return;
|
|
3381
3452
|
}
|
|
3382
3453
|
if (e === "READY_GAME_LOADED") {
|
|
3383
|
-
|
|
3454
|
+
R();
|
|
3384
3455
|
return;
|
|
3385
3456
|
}
|
|
3386
3457
|
if (e === "TIMER_TICK") {
|
|
3387
3458
|
if (t != null && t.display) {
|
|
3388
3459
|
let [e, n] = t.display;
|
|
3389
|
-
|
|
3460
|
+
E(e, n);
|
|
3390
3461
|
}
|
|
3391
3462
|
return;
|
|
3392
3463
|
}
|
|
@@ -3397,28 +3468,28 @@ function lt(e = {}) {
|
|
|
3397
3468
|
}
|
|
3398
3469
|
u.forEach((n) => {
|
|
3399
3470
|
var r;
|
|
3400
|
-
return (r = n.onMessage) == null ? void 0 : r.call(n, e, t,
|
|
3471
|
+
return (r = n.onMessage) == null ? void 0 : r.call(n, e, t, P);
|
|
3401
3472
|
});
|
|
3402
3473
|
let i = (n = t == null || (r = t.input) == null ? void 0 : r.boardState) == null ? t == null ? void 0 : t.boardState : n;
|
|
3403
|
-
e === "UPLOAD_NEW_GAME_STATE" && i && (f.currentInputStr = i, f.activeTab === "thumb" &&
|
|
3404
|
-
},
|
|
3474
|
+
e === "UPLOAD_NEW_GAME_STATE" && i && (f.currentInputStr = i, f.activeTab === "thumb" && k(), console.log("Simulator: Game state uploaded", t)), e === "GAME_COMPLETED" && (console.log("Simulator: Game completed!", t), g.disabled = !0, f.hasStarted = !1, T("Completed!", "complete"));
|
|
3475
|
+
}, j), console.log("Simulator initialized"), $ = {
|
|
3405
3476
|
updateFixtures: (e) => {
|
|
3406
|
-
o =
|
|
3477
|
+
o = le(e), s = Array.from(o.keys()).sort(), P.fixtures = o, P.fixtureCategories = s;
|
|
3407
3478
|
let t = localStorage.getItem("simulator-fixture-category");
|
|
3408
3479
|
if (!f.selectedCategory || !s.includes(f.selectedCategory)) {
|
|
3409
3480
|
var n;
|
|
3410
3481
|
f.selectedCategory = t && s.includes(t) ? t : (n = s[0]) == null ? null : n;
|
|
3411
3482
|
}
|
|
3412
3483
|
let r = u.find((e) => e.id === "ctrl");
|
|
3413
|
-
r == null || r.bind(
|
|
3484
|
+
r == null || r.bind(P), console.log("Simulator: Fixtures updated", {
|
|
3414
3485
|
categories: s,
|
|
3415
3486
|
selectedCategory: f.selectedCategory
|
|
3416
3487
|
});
|
|
3417
3488
|
},
|
|
3418
|
-
sendToGame:
|
|
3419
|
-
loadPuzzle:
|
|
3489
|
+
sendToGame: M,
|
|
3490
|
+
loadPuzzle: A
|
|
3420
3491
|
}, $;
|
|
3421
3492
|
}
|
|
3422
|
-
export {
|
|
3493
|
+
export { gt as t };
|
|
3423
3494
|
|
|
3424
|
-
//# sourceMappingURL=createSimulator-
|
|
3495
|
+
//# sourceMappingURL=createSimulator-CRoIrAmo.js.map
|