@energy8platform/platform-core 0.26.1 → 0.28.0

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/index.d.ts CHANGED
@@ -570,404 +570,6 @@ interface LogoSVGOptions {
570
570
  */
571
571
  declare function buildLogoSVG(opts: LogoSVGOptions): string;
572
572
 
573
- type ShellMode = 'base' | 'freeSpins' | 'replay';
574
- interface CurrencyConfig {
575
- symbol: string;
576
- position: 'left' | 'right';
577
- /** Maximum fraction digits (default 2). Win / total-win readouts are rounded to this precision;
578
- * balance / bet / prices stay fixed at `minDecimals`. */
579
- maxDecimals?: number;
580
- /** Minimum fraction digits (defaults to `maxDecimals`). For win / total-win, trailing zeros are
581
- * trimmed down to this many places so small wins keep their significant digits (e.g. 0.0673)
582
- * while round amounts stay compact (e.g. 0.30). Everything else is shown at exactly this many. */
583
- minDecimals?: number;
584
- separator?: {
585
- thousands?: string;
586
- decimal?: string;
587
- };
588
- }
589
- interface BonusOption {
590
- id: string;
591
- /** 'bonus' buys into a bonus round, 'feature' toggles a base-game modifier (e.g. Ante).
592
- * Drives the card/button label and accent. Defaults to 'bonus'. */
593
- type?: 'feature' | 'bonus';
594
- title: string;
595
- description: string;
596
- /** Transparent art image shown at the top of the card (no background plate). */
597
- thumbnail?: string;
598
- volatility?: 1 | 2 | 3 | 4 | 5;
599
- /** Card price = priceMultiplier × current bet, rendered in the shell currency. */
600
- priceMultiplier: number;
601
- /** Per-option accent override. Falls back to the type default (bonus → purple, feature → gold). */
602
- accentColor?: string;
603
- /** Override the card UI. Return the card's inner content; the shell keeps the grid wrapper,
604
- * accent vars and live re-pricing, and runs the normal buy flow when you call `ctx.select()`. */
605
- custom?: (ctx: BonusCardContext) => HTMLElement;
606
- }
607
- /** Context passed to a `BonusOption.custom` renderer. Render the card however you like and wire
608
- * your own control to `select()` — the buy/confirm flow stays internal to the shell. */
609
- interface BonusCardContext {
610
- bonus: BonusOption;
611
- /** Current bet. */
612
- bet: number;
613
- /** Card price = `bonus.priceMultiplier × bet`. */
614
- price: number;
615
- /** `price` formatted in the shell currency. */
616
- priceText: string;
617
- /** True when the option can't be bought right now (unaffordable / busy / buy-bonus disabled);
618
- * reflect it in your UI. `select()` is a no-op while disabled. */
619
- disabled: boolean;
620
- /** Card accent (per-option override or the type default); also set as the `--card-acc` CSS var. */
621
- accent: string;
622
- /** Proceed through the shell's normal flow: opens the confirm modal, then emits `buyBonusSelect`
623
- * / activates the feature. No-op while `disabled`. */
624
- select: () => void;
625
- }
626
- interface ThemeConfig {
627
- /** Palette scheme: 'dark' (default) for dark games, 'light' for light backgrounds. */
628
- scheme?: 'dark' | 'light';
629
- /** Brand accent — active states, the SPIN hover glow, and the BUY BONUS button.
630
- * (Per-bonus card accents are set on each `BonusOption.accentColor`.) */
631
- accent?: string;
632
- }
633
- /** One paytable entry: a symbol (text/image) and its win tiers, rendered "<count> x<multiplier>". */
634
- interface PaytableRow {
635
- symbol: {
636
- text?: string;
637
- image?: string;
638
- };
639
- wins: Array<{
640
- count?: string;
641
- multiplier: number;
642
- }>;
643
- }
644
- /** One payline over a cols×rows grid: the row index (0 = top) the line takes in each column. */
645
- interface PaylineDef {
646
- /** length must equal grid.cols; each value in 0..rows-1 */
647
- pattern: number[];
648
- label?: string;
649
- }
650
- /** A single grid cell, 0-based, row 0 = top. */
651
- type CellRef = [col: number, row: number];
652
- /** A named winning shape: an arbitrary set of grid cells (not one-per-column like a payline),
653
- * shown as a grid illustration with its name and optional description. */
654
- interface ShapeDef {
655
- /** The lit cells, in any pattern. */
656
- cells: CellRef[];
657
- name: string;
658
- description?: string;
659
- }
660
- /** How a game pays — drives the GameInfo win-section illustration. One section = one kind.
661
- * `example`/`winExample`/`loseExample` are optional; omit them for an auto-drawn illustration
662
- * sized to `grid`. */
663
- type WinSection = {
664
- type: 'wins';
665
- title?: string;
666
- order?: number;
667
- grid: {
668
- cols: number;
669
- rows: number;
670
- };
671
- /** Optional prose shown alongside the illustration. */
672
- description?: string;
673
- } & ({
674
- kind: 'classic';
675
- lines: Array<number[] | PaylineDef>;
676
- } | {
677
- kind: 'cluster';
678
- minCount: number;
679
- example?: CellRef[];
680
- } | {
681
- kind: 'anywhere';
682
- minCount: number;
683
- example?: CellRef[];
684
- } | {
685
- kind: 'ways';
686
- winExample?: CellRef[];
687
- loseExample?: CellRef[];
688
- } | {
689
- kind: 'shapes';
690
- shapes: ShapeDef[];
691
- });
692
- /** A playable mode / bonus-buy option, shown for comparison (informational only). */
693
- interface GameMode {
694
- title: string;
695
- price?: string;
696
- rtp?: number;
697
- maxWin?: string;
698
- description?: string;
699
- }
700
- /** A preset game-info section. `order` overrides placement; by default `modes` comes
701
- * first, `controls` second, and the rest follow in declaration order. */
702
- type GameInfoSection = {
703
- type: 'modes';
704
- title?: string;
705
- order?: number;
706
- modes: GameMode[];
707
- } | {
708
- type: 'controls';
709
- title?: string;
710
- order?: number;
711
- } | {
712
- type: 'hotkeys';
713
- title?: string;
714
- order?: number;
715
- } | {
716
- type: 'paytable';
717
- title?: string;
718
- order?: number;
719
- rows: PaytableRow[];
720
- } | WinSection | {
721
- type: 'custom';
722
- title?: string;
723
- order?: number;
724
- node?: HTMLElement;
725
- html?: string;
726
- };
727
- interface GameInfoContent {
728
- sections?: GameInfoSection[];
729
- }
730
- /** Autoplay limits. Presence of this object (vs `null`) is what enables autoplay. */
731
- interface AutoplayConfig {
732
- /** Maximum selectable spin count in the autoplay picker. Caps the built-in presets and
733
- * drops the unlimited (∞) choice; if it isn't already a preset it becomes the top choice.
734
- * Omit for the default presets (including ∞). */
735
- maxCount?: number;
736
- }
737
- interface ShellFeatures {
738
- turbo: 0 | 1 | 2 | 3;
739
- /** Master keyboard-shortcut switch. Defaults to `true`; set `false` to disable ALL hotkeys
740
- * (overrides `spacebar` and any future hotkey). */
741
- hotkeys?: boolean;
742
- /** Spacebar starts a spin in base mode. Defaults to `true`; set `false` to disable the
743
- * keyboard shortcut (e.g. jurisdictions that forbid quick-spin keys). */
744
- spacebar?: boolean;
745
- /** Autoplay: `null` (or omitted) disables it; an object enables it (optionally with limits). */
746
- autoplay?: AutoplayConfig | null;
747
- buyBonus: BonusOption[] | false;
748
- }
749
- interface AutoplayOptions {
750
- active: boolean;
751
- remaining: number;
752
- }
753
- interface FreeSpinsState {
754
- /** Spin index for the `current / total` counter. Set to `null` (or omit) to instead show just
755
- * `total` as a single number — drive a countdown by decrementing `total` each spin. */
756
- current?: number | null;
757
- total: number;
758
- totalWin: number;
759
- }
760
- /** One footer button of a generic modal. Clicking it runs `on` (if any), then closes the modal. */
761
- interface ModalAction {
762
- title: string;
763
- /** Button fill colour (any CSS colour). Omit for a neutral/secondary button. */
764
- color?: string;
765
- on?: () => void;
766
- }
767
- /** Options for `shell.openReplay()` — a non-dismissable replay summary modal.
768
- * `bonusId` is matched against `features.buyBonus` to label the mode and read the cost
769
- * multiplier. There is no ✕ and the backdrop never closes it; the only action is START
770
- * REPLAY, which closes the modal, runs `onReplay`, then reopens it. */
771
- interface ReplayModalOptions {
772
- bonusId: string;
773
- /** Base bet the replay was recorded at. */
774
- bet: number;
775
- payoutMultiplier: number;
776
- /** Runs after the modal closes; the modal reopens once it resolves (immediately for sync). */
777
- onReplay: () => void | Promise<void>;
778
- }
779
- /** Options for `shell.openModal()` — a generic, externally-triggered card modal. */
780
- interface ModalOptions {
781
- /** Show the ✕ in the overlay's top-right corner. */
782
- availableClose: boolean;
783
- title: string;
784
- body: string;
785
- /** Footer buttons; each closes the modal (after running its `on`). */
786
- actions?: ModalAction[];
787
- /** Backdrop blur in px (defaults to the shell's standard blur). */
788
- blurLevel?: number;
789
- /** Optional keyboard handler — called by the shell keyboard controller while this modal is
790
- * open. Return true to consume the key (prevents bar actions + Escape close); false to let
791
- * the controller handle it (Escape → closeModal). */
792
- onKey?: (e: KeyboardEvent) => boolean;
793
- }
794
- interface ShellConfig {
795
- mount: HTMLElement;
796
- theme?: ThemeConfig;
797
- gameInfo: GameInfoContent;
798
- language: string;
799
- /** Game version shown in the game-info footer (e.g. '1.2.0'). Defaults to '1.0.0'. The footer
800
- * stamp is `${version}.${engineVersionWithoutDots}` — e.g. game 1.0.0 on engine 0.24.6 → '1.0.0.0246'. */
801
- version?: string;
802
- /** When true, all built-in shell text is shown in the social-casino vocabulary (derived from
803
- * English via word-swap rules), regardless of `language`. Game-supplied content is untouched. */
804
- isSocial?: boolean;
805
- currency: CurrencyConfig;
806
- availableBets: number[];
807
- defaultBet: number;
808
- currentBet: number | null;
809
- balance: number;
810
- win: number;
811
- mode: ShellMode;
812
- /** Mark this shell as a read-only historical-round replay. A replay never shows the player's
813
- * balance (there's no live wallet), even while its free-spins phase runs in `freeSpins` mode.
814
- * Defaults to `mode === 'replay'`; set explicitly when a replay starts in another mode. */
815
- replay?: boolean;
816
- features: ShellFeatures;
817
- /** Override the BUY BONUS bar button's action: when set, tapping it calls this instead of
818
- * opening the built-in buy-bonus overlay (e.g. the game shows its own bonus UI). The button
819
- * is shown whenever this OR `features.buyBonus` is set. */
820
- onBonusBuy?: () => void;
821
- }
822
- interface ShellState {
823
- mode: ShellMode;
824
- /** Sticky replay marker — true for a historical-round replay, regardless of the current
825
- * `mode`. Set once (from config or when `mode` becomes 'replay') and never cleared, since a
826
- * shell instance is either a live game or a replay viewer for its whole lifetime. */
827
- replay: boolean;
828
- balance: number;
829
- win: number;
830
- bet: number;
831
- availableBets: number[];
832
- busy: boolean;
833
- autoplay: AutoplayOptions;
834
- turbo: number;
835
- buyBonusEnabled: boolean;
836
- freeSpins: FreeSpinsState;
837
- /** The currently activated `feature` option (e.g. Ante), or null. Drives the
838
- * effective-bet readout tint and the BUY BONUS → DISABLE toggle on the bar. */
839
- activeFeature: BonusOption | null;
840
- }
841
- interface ShellEvents {
842
- spin: void;
843
- betChange: number;
844
- autoplayStart: AutoplayOptions;
845
- autoplayStop: void;
846
- turboChange: number;
847
- buyBonusSelect: {
848
- id: string;
849
- };
850
- featureActivate: {
851
- id: string;
852
- };
853
- featureDeactivate: {
854
- id: string;
855
- };
856
- menuOpen: void;
857
- settingsOpen: void;
858
- infoOpen: void;
859
- settingChange: {
860
- key: string;
861
- value: unknown;
862
- };
863
- }
864
-
865
- declare class GameShell extends EventEmitter<ShellEvents> {
866
- readonly config: ShellConfig;
867
- state: ShellState;
868
- private root;
869
- private styleEl;
870
- private barHost;
871
- private modalHost;
872
- private destroyed;
873
- layout: 'wide' | 'mobile';
874
- private ro;
875
- private prevBalance;
876
- private prevWin;
877
- private moneyAnims;
878
- private kbd;
879
- private i18n;
880
- /** onKey handler of the currently open modal/overlay, if any (set in showModal, cleared in closeModal). */
881
- private modalOnKey;
882
- /** Shared sound on/off state — Settings speaker toggle and the Shift+M hotkey stay in sync. The
883
- * game listens to `settingChange({ key: 'sound' })` to (un)mute audio. */
884
- soundOn: boolean;
885
- /** Set by the open Settings modal so Shift+M live-updates its speaker icon; cleared on close. */
886
- private soundRefresh;
887
- constructor(config: ShellConfig);
888
- render(): void;
889
- private cancelMoneyAnims;
890
- /** Keep the WIN pill inline between the groups; float it above when it won't fit. */
891
- /**
892
- * Landscape bar fills the width when it fits. When it overflows, the WIN pill is
893
- * lifted above the bar (unscaled, so it stays readable) and the remaining row is
894
- * centred and scaled down to fit — keeping the controls as large as possible.
895
- */
896
- private applyFitScale;
897
- /** Pull window focus into the iframe on first pointer interaction so `document` keydown (the
898
- * spacebar shortcut) fires. No-op / harmless when already focused or full-page. */
899
- private pullFocus;
900
- setLayout(layout: 'wide' | 'mobile'): void;
901
- /** Resolve a built-in shell string through the i18n resolver (translation + optional socialize). */
902
- t(text: string): string;
903
- /** Toggle the social vocabulary at runtime (rebuilds resolver, re-renders bar). */
904
- setSocial(isSocial: boolean): void;
905
- /** Swap the active language at runtime (rebuilds resolver, re-renders bar). */
906
- setLanguage(lang: string): void;
907
- /** Recolour the shell at runtime (e.g. switch dark/light scheme). */
908
- setTheme(theme: ThemeConfig): void;
909
- private observeLayout;
910
- private animateMoney;
911
- setBalance(n: number): void;
912
- setWin(n: number): void;
913
- setBet(n: number): void;
914
- setMode(mode: ShellMode): void;
915
- setBusy(busy: boolean): void;
916
- setAutoplay(a: AutoplayOptions): void;
917
- setTurbo(level: number): void;
918
- /** Currency-aware money formatter for WIN amounts (variable decimals: 0.0041 stays 0.0041, not
919
- * 0.00). The host hands this to a scene so games format money without knowing the currency. */
920
- formatWin(value: number): string;
921
- setBuyBonusEnabled(enabled: boolean): void;
922
- setFreeSpins(fs: FreeSpinsState): void;
923
- private showModal;
924
- /** Uniformly scale every open centred card modal (`.ge-sheet`) down so it fits a short/narrow
925
- * popout — the same idea as the bar's fit-scale. Covers the pickers, generic + replay modals,
926
- * AND the buy-bonus confirm (which is hosted inside the overlay, not directly in modalHost).
927
- * Full-screen overlays handle their own responsiveness (scroll + vh-clamp). */
928
- fitModals(): void;
929
- /** Fraction of the frame a card modal may occupy; the rest is breathing-room margin. Keeps
930
- * modals from filling a small popout edge-to-edge (so even short pickers scale down there). */
931
- private static readonly MODAL_FIT;
932
- /** The bar's design width (px). When the frame is narrower, the bar fit-scales DOWN with the
933
- * screen — the SAME factor in every mode, so replay/free-spins shrink like base instead of
934
- * staying full-size on a popout. */
935
- private static readonly BAR_REF_WIDTH;
936
- /** Lower bound on the bar fit-scale (guards a degenerate near-zero frame). */
937
- private static readonly BAR_MIN_SCALE;
938
- private fitSheet;
939
- /** Activate a `feature` option (e.g. Ante): the bar shows the effective bet, tinted with
940
- * the feature accent, and BUY BONUS becomes DISABLE. */
941
- activateFeature(bonus: BonusOption): void;
942
- /** Clear the active feature — reverts the bet readout and the BUY BONUS button. */
943
- deactivateFeature(): void;
944
- openMenu(): void;
945
- openSettings(): void;
946
- openInfo(): void;
947
- openBuyBonus(): void;
948
- /** Open a generic, externally-driven modal (title + body + optional action buttons).
949
- * Each action runs its `on` then closes; the ✕ shows when `availableClose` is true. */
950
- openModal(opts: ModalOptions): void;
951
- /** Programmatically dismiss whatever modal/overlay is currently shown (e.g. auto-close the
952
- * reconnect overlay once the link is restored). No-op when nothing is open. */
953
- closeModal(): void;
954
- /** Flip the shared sound state, notify the game (`settingChange({ key: 'sound' })`), and live-update
955
- * the Settings speaker icon if that modal is open. Used by both the Settings toggle and Shift+M. */
956
- setSound(on: boolean): void;
957
- /** The Settings modal registers an icon-updater while open (cleared on close). */
958
- setSoundRefresh(fn: ((on: boolean) => void) | null): void;
959
- /** Open the non-dismissable replay summary modal (START REPLAY → onReplay → reopen). */
960
- openReplay(opts: ReplayModalOptions): void;
961
- /** Bet picker — list of available bets with an accent Confirm. */
962
- openBetPicker(): void;
963
- /** Autoplay picker — spin-count list; Confirm starts autoplay. */
964
- openAutoplayPicker(): void;
965
- destroy(): Promise<void>;
966
- }
967
-
968
- declare function createGameShell(config: ShellConfig): GameShell;
969
- declare function removeGameShell(): Promise<void>;
970
-
971
573
  type NativeRNGKind = 'provably-fair' | 'fast';
972
574
  /**
973
575
  * Replay mode parameters. Forces single-worker deterministic execution over a
@@ -1055,5 +657,5 @@ interface NativeSimulationResult extends SimulationResult {
1055
657
  replay?: NativeReplayParams;
1056
658
  }
1057
659
 
1058
- export { DevBridge, EventEmitter, GameShell, LOADER_BAR_MAX_WIDTH, PlatformSession, buildLogoSVG, createCSSPreloader, createGameShell, createPlatformSession, removeCSSPreloader, removeGameShell, setCSSPreloaderProgress, waitCSSPreloaderTap };
1059
- export type { ActionDefinition, AssetBundle, AssetEntry, AssetManifest, AutoplayConfig, AutoplayOptions, BetLevelsConfig, BonusCardContext, BonusOption, CurrencyConfig, DevBridgeConfig, DistributionBucket, FreeSpinsState, GameDefinition, GameInfoContent, LoadingScreenConfig, LuaEngineConfig, LuaPlayResult, MaxWinConfig, NativeSimulationConfig, NativeSimulationResult, PersistentStateConfig, PlatformSessionConfig, PlatformSessionEvents, ReplayConfig, ReplayLaunch, SDKOptions, SessionConfig, ShellConfig, ShellEvents, ShellFeatures, ShellMode, ShellState, SimulationConfig, SimulationRawAccumulators, SimulationResult, StageStats, ThemeConfig, TransitionRule };
660
+ export { DevBridge, EventEmitter, LOADER_BAR_MAX_WIDTH, PlatformSession, buildLogoSVG, createCSSPreloader, createPlatformSession, removeCSSPreloader, setCSSPreloaderProgress, waitCSSPreloaderTap };
661
+ export type { ActionDefinition, AssetBundle, AssetEntry, AssetManifest, BetLevelsConfig, DevBridgeConfig, DistributionBucket, GameDefinition, LoadingScreenConfig, LuaEngineConfig, LuaPlayResult, MaxWinConfig, NativeSimulationConfig, NativeSimulationResult, PersistentStateConfig, PlatformSessionConfig, PlatformSessionEvents, ReplayConfig, ReplayLaunch, SDKOptions, SessionConfig, SimulationConfig, SimulationRawAccumulators, SimulationResult, StageStats, TransitionRule };