@wasm-gaming/engine-specs 0.2.5 → 0.2.6
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/demo/demo.js +22 -7
- package/package.json +1 -1
package/demo/demo.js
CHANGED
|
@@ -307,7 +307,11 @@ const demo = {
|
|
|
307
307
|
assetKey: "rom",
|
|
308
308
|
});
|
|
309
309
|
|
|
310
|
-
|
|
310
|
+
// Handlers bound to a jq79 mount are called as (event, payload) — the
|
|
311
|
+
// DOM CustomEvent first, the emitted value second. `demo.on()` below is
|
|
312
|
+
// a different emitter that passes the payload alone, so the two must not
|
|
313
|
+
// be read the same way.
|
|
314
|
+
const handleSaveRom = (_event, file) => {
|
|
311
315
|
loadedFiles.rom = file;
|
|
312
316
|
saveStoredAsset("rom", file);
|
|
313
317
|
const payload = { file, key: "rom", type: "rom", action: "save" };
|
|
@@ -327,7 +331,7 @@ const demo = {
|
|
|
327
331
|
demo.emit("file", payload);
|
|
328
332
|
};
|
|
329
333
|
|
|
330
|
-
const handleSaveBios = (file) => {
|
|
334
|
+
const handleSaveBios = (_event, file) => {
|
|
331
335
|
loadedFiles.bios = file;
|
|
332
336
|
saveStoredAsset("bios", file);
|
|
333
337
|
const payload = { file, key: "bios", type: "bios", action: "save" };
|
|
@@ -377,7 +381,7 @@ const demo = {
|
|
|
377
381
|
.on("remove:rom", handleRemoveRom)
|
|
378
382
|
.on("save:bios", handleSaveBios)
|
|
379
383
|
.on("remove:bios", handleRemoveBios)
|
|
380
|
-
.on("launch", (payload) => bootWithFiles(payload))
|
|
384
|
+
.on("launch", (_event, payload) => bootWithFiles(payload))
|
|
381
385
|
.mount(mainEl);
|
|
382
386
|
};
|
|
383
387
|
|
|
@@ -468,6 +472,17 @@ const demo = {
|
|
|
468
472
|
customItems: escMenuConfig.items || [],
|
|
469
473
|
messages,
|
|
470
474
|
})
|
|
475
|
+
.mount(escContainer);
|
|
476
|
+
};
|
|
477
|
+
|
|
478
|
+
// Bound once, not per render. The $emit channel lives on the
|
|
479
|
+
// Component79 instance and deliberately survives destroy() — that is
|
|
480
|
+
// what lets it work while detached — so re-registering these inside
|
|
481
|
+
// updateEscMenu() stacked a fresh set of listeners on every open,
|
|
482
|
+
// close and restore-defaults. After N re-renders a single click
|
|
483
|
+
// reached the handler N times, growing without bound.
|
|
484
|
+
const bindEscMenuEvents = () => {
|
|
485
|
+
CEscMenu
|
|
471
486
|
.on("close", () => closeMenu())
|
|
472
487
|
.on("reset", () => {
|
|
473
488
|
closeMenu();
|
|
@@ -499,7 +514,7 @@ const demo = {
|
|
|
499
514
|
escMenuConfig.onRestoreDefaults(currentInstance);
|
|
500
515
|
}
|
|
501
516
|
})
|
|
502
|
-
.on("option-change", ({ key, value, option }) => {
|
|
517
|
+
.on("option-change", (_event, { key, value, option }) => {
|
|
503
518
|
if (currentInstance && typeof currentInstance.setOption === "function") {
|
|
504
519
|
currentInstance.setOption(key, value);
|
|
505
520
|
}
|
|
@@ -533,14 +548,13 @@ const demo = {
|
|
|
533
548
|
}
|
|
534
549
|
exitToLauncher();
|
|
535
550
|
})
|
|
536
|
-
.on("custom-action", (item) => {
|
|
551
|
+
.on("custom-action", (_event, item) => {
|
|
537
552
|
closeMenu();
|
|
538
553
|
demo.emit("customAction", { item, instance: currentInstance });
|
|
539
554
|
if (typeof item?.action === "function") {
|
|
540
555
|
item.action(currentInstance);
|
|
541
556
|
}
|
|
542
|
-
})
|
|
543
|
-
.mount(escContainer);
|
|
557
|
+
});
|
|
544
558
|
};
|
|
545
559
|
|
|
546
560
|
const openMenu = () => {
|
|
@@ -581,6 +595,7 @@ const demo = {
|
|
|
581
595
|
if (typeof window !== "undefined") {
|
|
582
596
|
window.addEventListener("keydown", handleKeyDown);
|
|
583
597
|
}
|
|
598
|
+
bindEscMenuEvents();
|
|
584
599
|
updateEscMenu();
|
|
585
600
|
}
|
|
586
601
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wasm-gaming/engine-specs",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "The wasm-gaming engine contract: the single shared interface every WASM game/emulator engine and the host app conform to. TypeScript types + JSON Schema + a Zod runtime validator.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|