@energy8platform/shell 0.6.1 → 0.6.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@energy8platform/shell",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "Energy8 branded game shell — one logic core, pluggable html/pixi renderers behind a stable contract.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs.js",
@@ -1,3 +1,3 @@
1
1
  // AUTO-GENERATED by scripts/gen-version.mjs — do not edit. Mirrors package.json "version".
2
2
  /** The @energy8platform/shell package version, stamped into the game-info footer. */
3
- export const PACKAGE_VERSION = '0.6.1';
3
+ export const PACKAGE_VERSION = '0.6.2';
@@ -523,7 +523,7 @@ function sectionCustom(host: PixiComponentContext, s: Extract<GameInfoSection, {
523
523
  const sec = section(host, s.title != null ? host.t(s.title) : undefined);
524
524
  const inner = width - SECTION_PAD;
525
525
  if (s.node) {
526
- sec.add(s.node as Container); // game-supplied Pixi content owns its own layout
526
+ sec.add(persistentSlot(s.node as Container)); // game-supplied Pixi content owns its own layout
527
527
  } else if (s.html) {
528
528
  const text = s.html.replace(/<[^>]*>/g, ' ').replace(/\s+/g, ' ').trim();
529
529
  if (text) sec.add(paragraph(host, text, inner, { size: 15 }));
@@ -579,6 +579,23 @@ function spacerBox(w: number, h: number): Graphics {
579
579
  return g;
580
580
  }
581
581
 
582
+ /** Wrap a GAME-supplied custom `node` so the shell BORROWS it instead of owning it. The overlay is
583
+ * torn down with `destroy({ children: true })` on every close; that would recursively destroy the
584
+ * game's node, so the section renders blank on reopen. This slot's `destroy` DETACHES the node
585
+ * (leaving it intact) and destroys only the empty wrapper — the SAME node instance is re-mounted,
586
+ * with all its drawing, the next time Game info opens. Mirrors the HTML shell, where the game's DOM
587
+ * node simply persists in config across open/close. The game owns the node's lifetime, not us. */
588
+ function persistentSlot(node: Container): Container {
589
+ const slot = new Container();
590
+ slot.addChild(node);
591
+ const destroySelf = Container.prototype.destroy.bind(slot);
592
+ slot.destroy = () => {
593
+ if (node.parent === slot) slot.removeChild(node); // keep the game node alive for the next open
594
+ destroySelf({ children: false });
595
+ };
596
+ return slot;
597
+ }
598
+
582
599
  /** A fixed box that loads an image into it (object-fit: contain) once the texture resolves. */
583
600
  function imageBox(url: string, w: number, h: number): Container {
584
601
  const c = new Container();