@energy8platform/shell 0.6.0 → 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/dist/pixi.d.ts CHANGED
@@ -513,7 +513,7 @@ declare class ShellController extends EventEmitter<ShellEvents> implements Shell
513
513
  tokens: ShellTokens;
514
514
  layout: ShellLayoutMode;
515
515
  soundOn: boolean;
516
- readonly engineVersion = "0.6.0";
516
+ readonly engineVersion = "0.6.2";
517
517
  readonly actions: ShellActions;
518
518
  private renderer;
519
519
  private i18n;
@@ -555,7 +555,12 @@ declare class ShellController extends EventEmitter<ShellEvents> implements Shell
555
555
  deactivateFeature(): void;
556
556
  private money;
557
557
  setBalance(n: number): void;
558
- setWin(n: number): void;
558
+ /** Set the WIN readout. Counts up/down from the previous value by default. Pass
559
+ * `{ animate: false }` to SNAP instantly (renderBar cancels any in-flight count-up) — used by the
560
+ * host to clear WIN to 0 at spin start, where an animated count-DOWN would look wrong. */
561
+ setWin(n: number, opts?: {
562
+ animate?: boolean;
563
+ }): void;
559
564
  setBet(n: number): void;
560
565
  setMode(mode: ShellMode): void;
561
566
  setBusy(busy: boolean): void;
@@ -590,7 +595,7 @@ interface I18n {
590
595
  declare function createI18n(opts: I18nOptions): I18n;
591
596
 
592
597
  /** The @energy8platform/shell package version, stamped into the game-info footer. */
593
- declare const PACKAGE_VERSION = "0.6.0";
598
+ declare const PACKAGE_VERSION = "0.6.2";
594
599
 
595
600
  /** A shell: the renderer-agnostic controller plus the surface facade (safeArea/barHeight/setVisible)
596
601
  * an embedding host reads. `createShell`, `createGameShell` and `createPixiShell` all return this. */
package/dist/pixi.esm.js CHANGED
@@ -1447,7 +1447,7 @@ class KeyboardController {
1447
1447
 
1448
1448
  // AUTO-GENERATED by scripts/gen-version.mjs — do not edit. Mirrors package.json "version".
1449
1449
  /** The @energy8platform/shell package version, stamped into the game-info footer. */
1450
- const PACKAGE_VERSION = '0.6.0';
1450
+ const PACKAGE_VERSION = '0.6.2';
1451
1451
 
1452
1452
  /** Apply defaults to the raw config (the mount target lives on the renderer, not here). */
1453
1453
  function resolveConfig(config) {
@@ -1725,10 +1725,17 @@ class ShellController extends EventEmitter {
1725
1725
  this.prevBalance = n;
1726
1726
  this.money('balance', from, n);
1727
1727
  }
1728
- setWin(n) {
1728
+ /** Set the WIN readout. Counts up/down from the previous value by default. Pass
1729
+ * `{ animate: false }` to SNAP instantly (renderBar cancels any in-flight count-up) — used by the
1730
+ * host to clear WIN to 0 at spin start, where an animated count-DOWN would look wrong. */
1731
+ setWin(n, opts) {
1729
1732
  const from = this.prevWin;
1730
1733
  this.state.win = n;
1731
1734
  this.prevWin = n;
1735
+ if (opts?.animate === false) {
1736
+ this.renderer.renderBar(); // instant repaint from state; cancels running money anims
1737
+ return;
1738
+ }
1732
1739
  this.money('win', from, n);
1733
1740
  }
1734
1741
  setBet(n) {
@@ -4625,7 +4632,7 @@ function sectionCustom(host, s, width) {
4625
4632
  const sec = section(host, s.title != null ? host.t(s.title) : undefined);
4626
4633
  const inner = width - SECTION_PAD;
4627
4634
  if (s.node) {
4628
- sec.add(s.node); // game-supplied Pixi content owns its own layout
4635
+ sec.add(persistentSlot(s.node)); // game-supplied Pixi content owns its own layout
4629
4636
  }
4630
4637
  else if (s.html) {
4631
4638
  const text = s.html.replace(/<[^>]*>/g, ' ').replace(/\s+/g, ' ').trim();
@@ -4682,6 +4689,23 @@ function spacerBox(w, h) {
4682
4689
  g.rect(0, 0, w, h).fill({ color: 0xffffff, alpha: 0 });
4683
4690
  return g;
4684
4691
  }
4692
+ /** Wrap a GAME-supplied custom `node` so the shell BORROWS it instead of owning it. The overlay is
4693
+ * torn down with `destroy({ children: true })` on every close; that would recursively destroy the
4694
+ * game's node, so the section renders blank on reopen. This slot's `destroy` DETACHES the node
4695
+ * (leaving it intact) and destroys only the empty wrapper — the SAME node instance is re-mounted,
4696
+ * with all its drawing, the next time Game info opens. Mirrors the HTML shell, where the game's DOM
4697
+ * node simply persists in config across open/close. The game owns the node's lifetime, not us. */
4698
+ function persistentSlot(node) {
4699
+ const slot = new Container();
4700
+ slot.addChild(node);
4701
+ const destroySelf = Container.prototype.destroy.bind(slot);
4702
+ slot.destroy = () => {
4703
+ if (node.parent === slot)
4704
+ slot.removeChild(node); // keep the game node alive for the next open
4705
+ destroySelf({ children: false });
4706
+ };
4707
+ return slot;
4708
+ }
4685
4709
  /** A fixed box that loads an image into it (object-fit: contain) once the texture resolves. */
4686
4710
  function imageBox(url, w, h) {
4687
4711
  const c = new Container();
@@ -5924,6 +5948,13 @@ class PixiRenderer {
5924
5948
  // make sure the stage delivers global pointer moves (drag, sliders)
5925
5949
  this.app.stage.eventMode = 'static';
5926
5950
  this.app.renderer.on('resize', this.onResize);
5951
+ // Seed the layout from the CURRENT screen size. The renderer was resized to the container during
5952
+ // boot (ViewportManager.refresh) BEFORE this shell mounted and subscribed above, so that initial
5953
+ // 'resize' event is already gone and won't fire again on a stationary device. Without this seed
5954
+ // the controller's layout stays at its 'wide' DEFAULT — a portrait mobile would show the DESKTOP
5955
+ // bar. (The HTML renderer gets this for free: its ResizeObserver fires immediately on observe.)
5956
+ if (this.screenW > 0)
5957
+ this.host.notifyResize(this.screenW, this.screenH);
5927
5958
  whenFontReady(() => {
5928
5959
  if (!this.destroyed)
5929
5960
  this.renderBar();