@puzzmo/sdk 1.0.26 → 1.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{createSimulator-HNzTnWZh.cjs → createSimulator-CC0PhepL.cjs} +7 -7
- package/dist/createSimulator-CC0PhepL.cjs.map +1 -0
- package/dist/{createSimulator-D9Nzqxwl.js → createSimulator-CWwSv8gh.js} +18 -25
- 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/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-D9Nzqxwl.js.map +0 -1
- package/dist/createSimulator-HNzTnWZh.cjs.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
|
});
|
|
@@ -2815,7 +2808,7 @@ function Re(t = {}) {
|
|
|
2815
2808
|
puzzle: {
|
|
2816
2809
|
id: "simulator-puzzle",
|
|
2817
2810
|
name: "Proto Jig Puzzle",
|
|
2818
|
-
puzzle:
|
|
2811
|
+
puzzle: e,
|
|
2819
2812
|
game: {
|
|
2820
2813
|
displayName: "Proto Game",
|
|
2821
2814
|
jsPath: "",
|
|
@@ -2905,4 +2898,4 @@ function Re(t = {}) {
|
|
|
2905
2898
|
}
|
|
2906
2899
|
export { Re as t };
|
|
2907
2900
|
|
|
2908
|
-
//# sourceMappingURL=createSimulator-
|
|
2901
|
+
//# sourceMappingURL=createSimulator-CWwSv8gh.js.map
|