@puzzmo/sdk 1.0.25 → 1.0.27
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-BVMKhHqV.cjs → createSimulator-CC0PhepL.cjs} +7 -7
- package/dist/createSimulator-CC0PhepL.cjs.map +1 -0
- package/dist/{createSimulator-D-hDsmgQ.js → createSimulator-CWwSv8gh.js} +34 -37
- package/dist/createSimulator-CWwSv8gh.js.map +1 -0
- package/dist/simulator/createSimulator.d.ts +3 -2
- 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/types.d.ts +6 -5
- package/dist/simulator/types.d.ts.map +1 -1
- package/dist/simulator/views/DataView.d.ts.map +1 -1
- package/dist/types.d.ts +72 -24
- package/dist/types.d.ts.map +1 -1
- package/dist/vite.cjs +1 -1
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.ts +3 -2
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +2 -2
- package/dist/vite.js.map +1 -1
- package/package.json +1 -1
- package/dist/createSimulator-BVMKhHqV.cjs.map +0 -1
- package/dist/createSimulator-D-hDsmgQ.js.map +0 -1
|
@@ -438,7 +438,7 @@ function v(e) {
|
|
|
438
438
|
console.log("Simulator: Parsing fixtures", Object.keys(e));
|
|
439
439
|
for (let [o, s] of Object.entries(e)) {
|
|
440
440
|
var n, r, i, a;
|
|
441
|
-
let e = o.split("/"), c = (n = (r = e.pop()) == null ? void 0 : r.replace(
|
|
441
|
+
let e = o.split("/"), c = (n = (r = e.pop()) == null ? void 0 : r.replace(/\.[^.]+$/, "")) == null ? "" : n, l = (i = e.pop()) == null ? "default" : i;
|
|
442
442
|
t.has(l) || t.set(l, /* @__PURE__ */ new Map());
|
|
443
443
|
let u = (a = s.default) == null ? s : a;
|
|
444
444
|
t.get(l).set(c, u);
|
|
@@ -508,7 +508,7 @@ function re() {
|
|
|
508
508
|
category: e.state.selectedCategory,
|
|
509
509
|
puzzle: e.state.selectedPuzzle,
|
|
510
510
|
hasPuzzleData: !!r
|
|
511
|
-
}), r && (e.state.puzzleData = r, e.state.originalPuzzle =
|
|
511
|
+
}), r && (e.state.puzzleData = r, e.state.originalPuzzle = r, e.state.selectedCategory && p(e.state.selectedCategory), e.state.selectedPuzzle && m(e.state.selectedPuzzle)), t.addEventListener("change", () => {
|
|
512
512
|
console.log("Simulator: Category changed, reloading...", t.value), p(t.value), h(), window.location.reload();
|
|
513
513
|
}), n.addEventListener("change", () => {
|
|
514
514
|
console.log("Simulator: Puzzle changed, reloading...", n.value), m(n.value), window.location.reload();
|
|
@@ -544,13 +544,14 @@ function w(e, t) {
|
|
|
544
544
|
let n = C();
|
|
545
545
|
if (!n) return "";
|
|
546
546
|
try {
|
|
547
|
-
|
|
547
|
+
var r;
|
|
548
|
+
let i = (r = e.state.puzzleData) == null ? "" : r, a = {
|
|
548
549
|
viewerIsOwner: !0,
|
|
549
550
|
theme: e.state.selectedTheme,
|
|
550
551
|
strict: !0,
|
|
551
552
|
renderHost: "game"
|
|
552
553
|
};
|
|
553
|
-
return n.fn(
|
|
554
|
+
return n.fn(i, t, a);
|
|
554
555
|
} catch (e) {
|
|
555
556
|
return "";
|
|
556
557
|
}
|
|
@@ -597,12 +598,7 @@ function ie() {
|
|
|
597
598
|
}), o == null || o.addEventListener("click", () => {
|
|
598
599
|
i && (i.value = n.state.originalPuzzle, e = n.state.originalPuzzle, E(i), s && (s.disabled = !0));
|
|
599
600
|
}), s == null || s.addEventListener("click", () => {
|
|
600
|
-
|
|
601
|
-
let t = JSON.parse(i.value);
|
|
602
|
-
n.state.puzzleData = t, n.state.originalPuzzle = i.value, e = i.value, n.sendToGame("RETRY_PUZZLE", {}), n.state.hasStarted = !1, n.state.isPaused = !1, d && (d.disabled = !0, d.textContent = "Pause"), u && (u.textContent = "Start"), n.updateStatus("Puzzle updated", "ready"), s.disabled = !0;
|
|
603
|
-
} catch (e) {
|
|
604
|
-
console.error("Simulator: Invalid puzzle JSON", e), n.updateStatus("Invalid JSON", "paused");
|
|
605
|
-
}
|
|
601
|
+
i && (n.state.puzzleData = i.value, n.state.originalPuzzle = i.value, e = i.value, n.sendToGame("RETRY_PUZZLE", {}), n.state.hasStarted = !1, n.state.isPaused = !1, d && (d.disabled = !0, d.textContent = "Pause"), u && (u.textContent = "Start"), n.updateStatus("Puzzle updated", "ready"), s.disabled = !0);
|
|
606
602
|
}), c == null || c.addEventListener("click", () => {
|
|
607
603
|
a && (a.value = t, E(a), l && (l.disabled = !0));
|
|
608
604
|
}), l == null || l.addEventListener("click", () => {
|
|
@@ -714,12 +710,7 @@ function k(e) {
|
|
|
714
710
|
t.addEventListener("click", (t) => {
|
|
715
711
|
let r = n[parseInt(t.target.getAttribute("data-save-idx") || "0")];
|
|
716
712
|
if (r) {
|
|
717
|
-
|
|
718
|
-
e.state.puzzleData = JSON.parse(r.puzzleStr), e.state.originalPuzzle = r.puzzleStr;
|
|
719
|
-
} catch (t) {
|
|
720
|
-
e.state.originalPuzzle = r.puzzleStr;
|
|
721
|
-
}
|
|
722
|
-
e.state.currentInputStr = r.inputStr;
|
|
713
|
+
e.state.puzzleData = r.puzzleStr, e.state.originalPuzzle = r.puzzleStr, e.state.currentInputStr = r.inputStr;
|
|
723
714
|
let t = e.getElement("#simulator-puzzle"), n = e.getElement("#simulator-input");
|
|
724
715
|
t && (t.value = r.puzzleStr, E(t)), n && (n.value = r.inputStr, E(n)), e.updateStatus(`Loaded: ${r.name}`, "ready");
|
|
725
716
|
let i = e.getElement(".data-subtab[data-subtab=\"edit\"]");
|
|
@@ -909,14 +900,15 @@ function ce() {
|
|
|
909
900
|
}
|
|
910
901
|
n && (n.textContent = `Using: ${r.name}()`);
|
|
911
902
|
try {
|
|
912
|
-
|
|
903
|
+
var i;
|
|
904
|
+
let n = (i = e.state.puzzleData) == null ? "" : i, a = {
|
|
913
905
|
viewerIsOwner: !0,
|
|
914
906
|
theme: e.state.selectedTheme,
|
|
915
907
|
strict: !0,
|
|
916
908
|
renderHost: e.state.renderHost,
|
|
917
909
|
renderContext: e.state.renderContext
|
|
918
|
-
},
|
|
919
|
-
t && (t.innerHTML =
|
|
910
|
+
}, o = r.fn(n, e.state.currentInputStr, a);
|
|
911
|
+
t && (t.innerHTML = o);
|
|
920
912
|
} catch (e) {
|
|
921
913
|
console.error("Simulator: Thumbnail error", e), t && (t.innerHTML = `<span class="simulator-empty">Error: ${e}</span>`);
|
|
922
914
|
}
|
|
@@ -1469,12 +1461,13 @@ var $ = null;
|
|
|
1469
1461
|
* ```html
|
|
1470
1462
|
* <script type="module">
|
|
1471
1463
|
* import { createSimulator } from "@puzzmo/sdk/simulator"
|
|
1472
|
-
* const fixtures = import.meta.glob("./fixtures/puzzles/**\/*.json", { eager: true })
|
|
1464
|
+
* const fixtures = import.meta.glob("./fixtures/puzzles/**\/*.{json,toml}", { query: "?raw", import: "default", eager: true })
|
|
1473
1465
|
* createSimulator({ fixtures })
|
|
1474
1466
|
* <\/script>
|
|
1475
1467
|
* ```
|
|
1476
1468
|
*
|
|
1477
|
-
* The fixtures folder structure should be: fixtures/puzzles/{category}/{puzzle}.json
|
|
1469
|
+
* The fixtures folder structure should be: fixtures/puzzles/{category}/{puzzle}.{json,toml,...}
|
|
1470
|
+
* Fixtures are loaded as raw strings and passed to the game verbatim (any text format works; the game parses it).
|
|
1478
1471
|
* This will show dropdowns in the Ctrl tab to select category and puzzle.
|
|
1479
1472
|
*/
|
|
1480
1473
|
function Re(t = {}) {
|
|
@@ -2725,7 +2718,7 @@ function Re(t = {}) {
|
|
|
2725
2718
|
var t = e(function* () {
|
|
2726
2719
|
var e, t;
|
|
2727
2720
|
if (m.puzzleData) return m.puzzleData;
|
|
2728
|
-
if (!a || a.size === 0) throw Error("No fixtures configured. Add puzzle
|
|
2721
|
+
if (!a || a.size === 0) throw Error("No fixtures configured. Add puzzle fixture files (.json or .toml) to a fixtures directory and pass fixturesGlob to the simulator.");
|
|
2729
2722
|
let n = (e = m.selectedCategory) == null ? o[0] : e, r = n ? a.get(n) : void 0;
|
|
2730
2723
|
if (!r || r.size === 0) throw Error(`No puzzles found in fixture category "${n}"`);
|
|
2731
2724
|
let i = (t = m.selectedPuzzle) == null ? r.keys().next().value : t, s = i ? r.get(i) : void 0;
|
|
@@ -2733,7 +2726,7 @@ function Re(t = {}) {
|
|
|
2733
2726
|
m.puzzleData = s, console.log("Simulator: Puzzle loaded from fixtures", {
|
|
2734
2727
|
category: n,
|
|
2735
2728
|
puzzle: i
|
|
2736
|
-
}), m.originalPuzzle =
|
|
2729
|
+
}), m.originalPuzzle = s;
|
|
2737
2730
|
let c = k("#simulator-puzzle");
|
|
2738
2731
|
return c && (c.value = m.originalPuzzle), m.activeTab === "thumb" && F(), m.puzzleData;
|
|
2739
2732
|
});
|
|
@@ -2789,43 +2782,47 @@ function Re(t = {}) {
|
|
|
2789
2782
|
userState: {
|
|
2790
2783
|
gameSettings: {},
|
|
2791
2784
|
id: "simulator-user",
|
|
2792
|
-
nakamaLogin: "simulator",
|
|
2793
2785
|
ownerID: "simulator-owner"
|
|
2794
2786
|
},
|
|
2795
|
-
currentUser:
|
|
2787
|
+
currentUser: {
|
|
2788
|
+
id: "simulator-user",
|
|
2789
|
+
name: "Simulator",
|
|
2790
|
+
username: "simulator",
|
|
2791
|
+
usernameID: "0000",
|
|
2792
|
+
type: "User",
|
|
2793
|
+
roles: "",
|
|
2794
|
+
nakamaID: null
|
|
2795
|
+
},
|
|
2796
2796
|
startOrFindGameplay: { gamePlayed: {
|
|
2797
2797
|
additionalTimeAddedSecs: 0,
|
|
2798
2798
|
boardState: m.currentInputStr,
|
|
2799
|
-
cheatsUsed: 0,
|
|
2800
2799
|
combinedTimeSecs: 0,
|
|
2801
2800
|
completed: !1,
|
|
2802
2801
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2803
2802
|
elapsedTimeSecs: 0,
|
|
2804
|
-
hintsUsed: 0,
|
|
2805
2803
|
id: `simulator-gameplay-${Date.now()}`,
|
|
2806
2804
|
ownerID: "simulator-owner",
|
|
2807
2805
|
pointsAwarded: 0,
|
|
2808
|
-
resetsUsed: 0,
|
|
2809
2806
|
slug: "simulator-game",
|
|
2810
2807
|
viewerOwnsPuzzle: !0,
|
|
2811
2808
|
puzzle: {
|
|
2812
2809
|
id: "simulator-puzzle",
|
|
2813
2810
|
name: "Proto Jig Puzzle",
|
|
2814
|
-
puzzle:
|
|
2815
|
-
seriesNumber: 1,
|
|
2811
|
+
puzzle: e,
|
|
2816
2812
|
game: {
|
|
2817
|
-
assetsPath: "./assets/",
|
|
2818
|
-
assetsSha: "",
|
|
2819
2813
|
displayName: "Proto Game",
|
|
2820
|
-
exposedGlobalFunction: "startGame",
|
|
2821
2814
|
jsPath: "",
|
|
2822
2815
|
slug: "proto-game"
|
|
2823
|
-
}
|
|
2816
|
+
},
|
|
2817
|
+
mostRecentDaily: null
|
|
2824
2818
|
}
|
|
2825
2819
|
} },
|
|
2826
2820
|
theme: m.selectedTheme,
|
|
2827
|
-
|
|
2828
|
-
|
|
2821
|
+
hostContext: [{
|
|
2822
|
+
type: "app",
|
|
2823
|
+
layout: "desktop",
|
|
2824
|
+
host: null
|
|
2825
|
+
}],
|
|
2829
2826
|
appRuntimeContract: "1.0"
|
|
2830
2827
|
}), U = function() {
|
|
2831
2828
|
var t = e(function* () {
|
|
@@ -2901,4 +2898,4 @@ function Re(t = {}) {
|
|
|
2901
2898
|
}
|
|
2902
2899
|
export { Re as t };
|
|
2903
2900
|
|
|
2904
|
-
//# sourceMappingURL=createSimulator-
|
|
2901
|
+
//# sourceMappingURL=createSimulator-CWwSv8gh.js.map
|